Nieves,

I'm also curious why you wish to generate random numbers.    However, FORTRAN 
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 just 
fine.

However, if you wish to generate Normal deviates, the procedure is slightly 
more complicated.  You can transform uniform deviates to normal deviates using 
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 transform 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: [email protected] [mailto:[email protected]] On 
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 random 
number at every time then the simplest and most efficient way to do this is to 
create the random number as a data item in your data set. You can use 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 number value.

On the other hand if you want a different random number every time you reach a 
particular record then that is a more complicated matter. I expect it can 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 function 
"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 
NONMEM? Does anybody know how?
This is part of the code that does not work (it's not working because the 
condition ICALL.EQ.4 never happens and for that it's not getting into the "if", 
but on the other hand, in order to use the function RANDOM(2,R), such function 
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 PRINT=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

[email protected]<mailto:[email protected]>

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



--

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: [email protected]<mailto:[email protected]>

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 
representative of an intended recipient, you are prohibited from using, copying 
or distributing the information in this e-mail or its attachments. If you have 
received this e-mail in error, please notify the sender immediately by return 
e-mail and delete all copies of this message and any attachments.

Thank you.

Reply via email to