# Re: Re: Random number generation

From: Sebastien Bihorel <sebastien.bihorel>
Date: Tue, 4 Jun 2019 09:03:22 -0400 (EDT)

ERRATUM:
runif.f90:
FUNCTION FUNCA(X,X1,X2)
USE SIZES, ONLY: DPSIZE
REAL(KIND=DPSIZE) :: X,X1,X2,FUNCA
FUNCA = RAND()
RETURN
END

From: Sebastien Bihorel <sebastien.bihorel
To: "Tingjie Guo" <iam
Cc: nmusers
Sent: Monday, June 3, 2019 4:54:46 PM
Subject: [NMusers] Re: Random number generation

Unfortunately, as is, the suggested code is rejected by NONMEM 7.3 if used in \$ERROR. Some additional setup calls might be required.

An (admittedly heavy-handed) alternative that actually works is to create and import a fortran routine (see NONMEM help topic about FUNCA, or VECTRA).

runif.f90:
FUNCTION FUNCA(X,X1,X2)
USE SIZES, ONLY: DPSIZE
REAL(KIND=DPSIZE) :: X,X1,X2,FUNCA
FUNCB = RAND()
RETURN
END

Control stream:
...
...
\$ERROR
VECTRA(1) = 0
VECTRA(2) = 0
VECTRA(3) = 0

RND = FUNCA(VECTRA)
...

From: Tingjie Guo <iam
To: "Sebastien Bihorel" <sebastien.bihorel
Sent: Monday, June 3, 2019 12:58:56 PM
Subject: Re: Random number generation

Hi Sebastien,

As far as I know, you could write verbatim code to generate random numbers during estimation. E.g:

\$PK|\$DES|\$ERROR
RAN = any value ; initialization
"RAN = RAND(0) ; start verbatim code

A random number between 0 and 1 from uniform distribution will be assigned to RAN. This function is called for each record of your input data. I believe it's also possible to call it more/fewer times through checking ICALL.

Warm regards,
Tingjie

From: owner-nmusers
Sent: Thursday, May 30, 2019 12:34
To: nmusers
Subject: [NMusers] Random number generation

Hi,

Is it possible for NONMEM to generate a random number during an estimation run?

Thank you

Sebastien Bihorel

Received on Tue Jun 04 2019 - 09:03:22 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.