# Documentation

### This is machine translation

Translated by
Mouseover text to see original. Click the button below to return to the English verison of the page.

# `stats`::`lognormalRandom`

Generate a random number generator for log-normal deviates

MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.

## Syntax

```stats::lognormalRandom(`m`, `v`, <`Seed = s`>)
```

## Description

`stats::normalRandom(m, v)` returns a procedure that produces lognormal deviates (random numbers) with location parameter m and shape parameter v > 0.

A random variable X is log-normally distributed if ln(X) is a normally distributed variable. The “location parameter” m of X is the mean of ln(X) and the “shape parameter” v is the variance of ln(X).

The procedure `f := stats::lognormalRandom(m, v)` can be called in the form `f()`. The return value of `f()` is either a floating-point number or a symbolic expression:

If `m` and `v` can be converted to floating-point numbers, `f()` returns a real floating point number. Otherwise, the symbolic call ```stats::lognormalRandom(m, v)()``` is returned.

Numerical values of `m` and `v` are only accepted if they are real and v is positive.

The values `X = f()` are distributed randomly according to the cumulative distribution function of the log-normal distribution with parameters `m` and `v`. For any real x, the probability that Xx is given by

.

Without the option `Seed = s`, an initial seed is chosen internally. This initial seed is set to a default value when MuPAD® is started. Thus, each time MuPAD is started or re-initialized with the `reset` function, random generators produce the same sequences of numbers.

### Note

In contrast to the function `random`, the generators produced by `stats::normalRandom` do not react to the environment variable `SEED`.

For efficiency, it is recommended to produce sequences of K random numbers via `f := stats::lognormalRandom(m, v): f() \$k = 1..K` rather than by `stats::lognormalRandom(m, v)() \$k = 1..K`. The latter call produces a sequence of generators each of which is called once. Also note that ```stats::lognormalRandom(m, v, Seed = n)() \$k = 1..K``` does not produce a random sequence, because a sequence of freshly initialized generators would be created each of them producing the same number.

## Environment Interactions

The function is sensitive to the environment variable `DIGITS` which determines the numerical working precision.

## Examples

### Example 1

We generate log-normal deviates with location parameter 2 and shape parameter :

```f := stats::normalRandom(2, 3/4): f() \$ k = 1..4```

`delete f:`

### Example 2

With symbolic parameters, no random floating-point numbers can be produced:

```f := stats::lognormalRandom(m, v): f()```

When m and v evaluate to real numbers, `f` starts to produce random floating point numbers:

```m := PI/10: v := 1/8: f() \$ k = 1..4```

`delete f, m, v:`

### Example 3

We use the option `Seed = s` to reproduce a sequence of random numbers:

```f := stats::lognormalRandom(1, 3, Seed = 1): f() \$ k = 1..4```

```g := stats::lognormalRandom(1, 3, Seed = 1): g() \$ k = 1..4```

`f() = g(), f() = g()`

`delete f, g:`

## Parameters

 `m` The location parameter: an arithmetical expression representing a real value `v` The shape parameter: an arithmetical expression representing a positive real value

## Options

 `Seed` Option, specified as `Seed = s` Initializes the random generator with the integer seed `s`. `s` can also be the option `CurrentTime`, to make the seed depend on the current time. This option serves for generating generators that return predictable sequences of pseudo-random numbers. The generator is initialized with the seed `s` which may be an arbitrary integer. Several generators with the same initial seed produce the same sequence of numbers. When this option is used, the parameters `m` and `v` must be convertible to suitable floating-point numbers at the time when the random generator is generated.

## Algorithms

The implementation uses `stats::normalRandom`.