NONMEM Users Network Archive

Hosted by Cognigen

RE: How to generate a random number with $EST

From: Fidler,Matt,FORT WORTH,R&D <Matt.Fidler>
Date: Mon, 14 Mar 2011 09:10:56 -0500

Nieves,

I'm also curious why you wish to generate random numbers. However, FORTR=
AN has a built-in uniform random number generator:
http://gcc.gnu.org/onlinedocs/gfortran/RAND.html


I'm assuming you wish to use a uniform distribution, so this should work ju=
st fine.

However, if you wish to generate Normal deviates, the procedure is slightly=
 more complicated. You can transform uniform deviates to normal deviates u=
sing the Box-Muller method. The basic idea is to take two uniform deviates=
 from -1 to 1, until they are in the unit circle. When they are, you can t=
ransform them to two normal deviates; The second deviate is saved for the =
next call.

Fortran 90 code is available in Numeric Recipes in Fortran on page 279-280,=
 see:

http://apps.nrbook.com/fortran/index.html


Matt.




From: owner-nmusers
 Behalf Of Nick Holford
Sent: Monday, March 14, 2011 4:09 AM
To: nmusers
Subject: Re: [NMusers] How to generate a random number with $EST

Nieves,

I have no idea why you want to do this but if you want to have the same ran=
dom number at every time then the simplest and most efficient way to do thi=
s is to create the random number as a data item in your data set. You can u=
se the rand() function in Excel to generate a pseudo-random uniform sample =
at each time. It is a waste of computer cycles to have to keep calling the =
random number generator for every record if you want the same random numbe=
r value.

On the other hand if you want a different random number every time you reac=
h a particular record then that is a more complicated matter. I expect it c=
an be done with a verbatim code call but I do not know how. Perhaps you can=
 use?
" CALL RANDOM(2,R)

It would be interesting to know why you want the random number when you are=
 not doing simulation.

Best wishes,

Nick

On 14/03/2011 10:32 a.m., Nieves Vélez de Mendizabal wrote:
Dear NONMEM Users,


I'm developing a model with NONMEM6|7. In this model, I need to generate a =
random number at every time step. The problem is that the use of the functi=
on "CALL RANDOM (2,R)" is supposed to be only for simulation, isn't it?
Thus, is it possible to generate a random number at every time step with NO=
NMEM? Does anybody know how?
This is part of the code that does not work (it's not working because the c=
ondition ICALL.EQ.4 never happens and for that it's not getting into the "i=
f", but on the other hand, in order to use the function RANDOM(2,R), such f=
unction requires ICALL.EQ.4):
...
$SUBS ADVAN6 TOL=5
$MODEL
...
$PK
...
IF (ICALL.EQ.4) THEN
                CALL RANDOM (2,R) ;Rand number in[0,1[
                T=1-R
...
ENDIF
$DES
...
$ERROR
...
$ESTIMATION MAXEVAL=0 NUMERICAL METHOD=COND LAPLACE LIKE CENTERING PRIN=
T=2 MSFO=msfo3

Thank you!
Nieves

--

--------------------------------

Nieves Velez de Mendizabal, Ph.D

Departamento de Farmacia y Tecnología Farmacéutica

Facultad de Farmacia

Universidad de Navarra

Phone: (+34) 658 732 851

Phone: (+34) 948 255 400 ext. 5827

nvelez

--------------------------------



--

Nick Holford, Professor Clinical Pharmacology

Dept Pharmacology & Clinical Pharmacology

University of Auckland,85 Park Rd,Private Bag 92019,Auckland,New Zealand

tel:+64(9)923-6730 fax:+64(9)373-7090 mobile:+64(21)46 23 53

email: n.holford

http://www.fmhs.auckland.ac.nz/sms/pharmacology/holford

________________________________
This e-mail (including any attachments) is confidential and may be legally =
privileged. If you are not an intended recipient or an authorized represent=
ative of an intended recipient, you are prohibited from using, copying or d=
istributing the information in this e-mail or its attachments. If you have =
received this e-mail in error, please notify the sender immediately by retu=
rn e-mail and delete all copies of this message and any attachments.

Thank you.

Received on Mon Mar 14 2011 - 10:10:56 EDT

The NONMEM Users Network is maintained by ICON plc. Requests to subscribe to the network should be sent to: nmusers-request@iconplc.com.

Once subscribed, you may contribute to the discussion by emailing: nmusers@globomaxnm.com.