Re: Random numbers according to histos and functions.

Rene Brun (Rene.Brun@cern.ch)
Tue, 20 May 1997 14:50:00 +0200


OLSZEWSKI@vsk02.ifj.edu.pl wrote:
>
> Hi,
>
> it would be nice to have a function generating random numbers according
> to a histogram or function.
>

This already exists. Look at tutorial
http://root.cern.ch/root/html/examples/fillrandom.C.html

> Another question: how to define a variable in a function being loaded to ROOT
> under CINT, so that its value would not be lost between consecutive executions.
>

Do you mean between ROOT sessions or between 2 consecutive calls ?
Otherwise, look at :
http://root.cern.ch/root/CintInterpreter.html

> Remark/question: Double_t *y = new Double_t(100); doesn't seem to work properly
> under CINT? Storing into 4'th element of y generates segmentation violation.
>

I suppose you mean:
Double_t *y = new Double_t[100]

I know that this is a very frequent mistake when coming from Fortran.
the instruction new Double_t(100) means in C++:
Allocate a new object at address 100 !!

Rene Brun