NONMEM Users Network Archive

Hosted by Cognigen

Re: Random number generation

From: Tingjie Guo <iam>
Date: Wed, 5 Jun 2019 10:08:44 +0000

Hi Sebastien,

It worked perfectly for me in $ERROR, but I tested it on NONMEM 7.4.3. Maybe nm version matters.

Warm regards,

From: Sebastien Bihorel <sebastien.bihorel
Date: Monday, 3 June 2017 at 22:54
To: Tingjie Guo <iam
Cc: "nmusers
Subject: Re: Random number generation

Thanks Tingjie for your suggestion

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).

      FUNCB = RAND()

Control stream:
  VECTRA(1) = 0
  VECTRA(2) = 0
  VECTRA(3) = 0


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:

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,

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


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

Thank you

Sebastien Bihorel

Received on Wed Jun 05 2019 - 06:08:44 EDT

The NONMEM Users Network is maintained by ICON plc. Requests to subscribe to the network should be sent to:

Once subscribed, you may contribute to the discussion by emailing: