Integer variables are modelled as RooAbsCategory
derived objects.
However, in their nature they are indeed categories,
rather than
variables. They can be used for example to tag datasets.
There is legitimate usage, however, for truly discrete
variables.
For example the Poisson distribution, or binned
functions or
datasets.
Let's consider the Poisson distribution example on
interval [0,100]
I would much rather write something like:
RooIntVar x("x","x",0,100);
than
RooCategory x("x","x");
x.defineType("0",0);
...
...
x.defineType("100",100);
To test whether it's possible to generate discrete
variables according
to a pdf I created a simple pdf function that depends
on one
category variable and when evaluated returns the
category index.
I tried generating a discrete dataset using this pdf,
but generation
failed, no matter how many events I tried to generate a
dataset
containing only one event was generated.
I aslo tried a more complicated two dimensional pdf, and
ran into the following problems (they can be potential
bugs)
in RooRealIntegral.cc The pdf depended on a
RooSuperCategory
xy which depended on two Category variables x, y, which
I attempted to generate. In step B) the variables x,y were
re-expressed in terms of xy which is higher in the
dependency
tree. However, at RooRealIntegral.cc:334 only PDF
dependents
are added to the numeric integration/summation list. As
a result
no sum over xy category variable is performed and a
PassThrough
integration mode is forced which gives wrong value for
pdf normalization. (There is a similar problem in
RooRealSumPdf.cc:268 where analytic integral is only
performed
for dependents, and there will be trouble when some terms
have been re-expressed)
Further, when there are no RooRealVar
dependent variables a call to integrate() seems to be
ill-defined.
In short, it there is no built in support for discrete
variables,
and trying to use categories instead leads to rather
obscure
problems, (super categories are probably especially
problematic).
Being able to generate and fit discrete datasets would be
a valuable addition.
Note: there is of course RooSimultaneous, which has
probably been
debugged and works. But again, it's well suited for the
case
when two _different_ datasets are fitted by two
different pdf
simultaneously. Generating a Poisson distribution
mentioned
above using a category variable with 100 categories and
100 pdf functions for each point is not a good solution.