# random() and randomg() pseudo-random number generators

*This page is for the current JSim version 2.0. Click here for the earlier JSim 1.6 version.*

This document describes the syntax and use of the **random()** and **randomg()** pseudo-random number generators.
(MML).

Prerequisites:

- Introductory Survey of MML (required)
- Introduction to the JSim GUI (recommended)
- Using Function Generators in JSim (recommended)

Contents:

- random() syntax
- randomg() syntax
- random() and randomg() examples
- Comments or Questions?

## random() syntax

The **random()** function generates a pseudo-random number from a uniform distribution between 0 and 1 inclusive.

Syntax for generating a real number between 0 and 10:

real var, var2; var=10; var2 = var*random();To set 'seed' value for random number generation:

- Compile model and then go to 'Run Time' page.
- Then chose 'Pages' -> 'Solvers'. The page should have 'Random number generator' listed.
- A seed of '0' generates a different set of random numbers each time the model is run. A non-zero seed will generate the same 'random' numbers each time model is run.

## randomg() syntax

The **randomg()** function generates a pseudo-random number from a Gaussian (normal) distribution of mean 0 and standard deviation 1.

Syntax for generating a real number between 0 and 10:

real var, var2; var=10; var2 = var*randomg();

## random() and randomg() examples:

*(Java plugin required)*

Comments or Questions?

[This page was last modified 07Jun16, 2:54 pm.]

**Model development and archiving support at
physiome.org provided by the following grants:** NIH/NIBIB BE08407 Software Integration,
JSim and SBW 6/1/09-5/31/13; NIH/NHLBI T15 HL88516-01 Modeling for Heart, Lung and Blood: From Cell to Organ,
4/1/07-3/31/11; NSF BES-0506477 Adaptive Multi-Scale Model Simulation,
8/15/05-7/31/08; NIH/NHLBI R01 HL073598 Core 3: 3D Imaging and Computer
Modeling of the Respiratory Tract, 9/1/04-8/31/09; as well as prior
support from NIH/NCRR P41 RR01243 Simulation Resource in Circulatory Mass
Transport and Exchange, 12/1/1980-11/30/01 and NIH/NIBIB R01 EB001973
JSim: A Simulation Analysis Platform, 3/1/02-2/28/07.