# $$\text{LogNormalVariate}$$¶

You can use the $$\text{LogNormalVariate}$$ function to calculate one or more random variates in a log-normal distribution.

You can use the \lognormalv backslash command to insert this function.

The following variants of this function are available:

• $$\text{real } \text{LogNormalVariate} \left ( \text{<}\mu\text{>} \right )$$

• $$\text{real } \text{LogNormalVariate} \left ( \text{<}\mu\text{>}, \text{<}\sigma\text{>} \right )$$

• $$\text{real matrix } \text{LogNormalVariate} \left ( \text{<number rows>}, \text{<number columns>}, \text{<}\mu\text{>} \right )$$

• $$\text{real matrix } \text{LogNormalVariate} \left ( \text{<number rows>}, \text{<number columns>}, \text{<}\mu\text{>}, \text{<}\sigma\text{>} \right )$$

Where $$x$$, $$\mu$$, and $$\sigma$$ are scalar values representing the value of interest, the mean value and the standard deviation. If not specified, the mean value will be 0 and the standard deviation will be 1. Note that this function is defined over the range $$x > 0$$ and $$\sigma > 0$$. The $$\text{LogNormalVariate}$$ function will generate a runtime error or return NaN or a matrix of NaN for values for which the function is not defined.

The one and two parameter versions of the $$\text{LogNormalVariate}$$ function will return a single random variate in a log normal distribution. The three and four parameter versions of the $$\text{LogNormalVariate}$$ function will return a real matrix of random variates in a log normal distribution. The $$\text{<number rows>}$$ and $$\text{<number columns>}$$ specify the size of the desired matrix.

The $$\text{LogNormalVariate}$$ uses Marsaglia’s polar method [5] to calculate random variates in a normal distribution. The $$\text{LogNormalVariate}$$ function then simply calculates $$e ^ x$$ for each term. The matrix version of the $$\text{LogNormalVariate}$$ function has been optimized to rapidly produce a large number of simultaneous normal random variates and SIMD instructions are used to calculate $$e ^ x$$ on multiple terms simultaneously.

Figure 174 shows the basic use of the $$\text{LogNormalVariate}$$ function.

Figure 174 Example Use Of The LogNormalVariate Function