# lognstat

Lognormal mean and variance

## Syntax

``[m,v] = lognstat(mu,sigma)``

## Description

example

````[m,v] = lognstat(mu,sigma)` returns the mean and variance of the lognormal distribution with the distribution parameters `mu` (mean of logarithmic values) and `sigma` (standard deviation of logarithmic values).```

## Examples

collapse all

Compute the mean and variance of the lognormal distribution with parameters `mu` and `sigma`.

```mu = 0; sigma = 1; [m,v] = lognstat(mu,sigma)```
```m = 1.6487 ```
```v = 4.6708 ```

## Input Arguments

collapse all

Mean of logarithmic values for the lognormal distribution, specified as a scalar value or an array of scalar values.

To compute the means and variances of multiple distributions, specify distribution parameters using an array of scalar values. If both `mu` and `sigma` are arrays, then the array sizes must be the same. If either `mu` or `sigma` is a scalar, then `lognstat` expands the scalar argument into a constant array of the same size as the other argument. Each element in `m` and `v` is the mean and variance of the distribution specified by the corresponding elements in `mu` and `sigma`.

Example: `[0 1 2; 0 1 2]`

Data Types: `single` | `double`

Standard deviation of logarithmic values for the lognormal distribution, specified as a positive scalar value or an array of positive scalar values.

To compute the means and variances of multiple distributions, specify distribution parameters using an array of scalar values. If both `mu` and `sigma` are arrays, then the array sizes must be the same. If either `mu` or `sigma` is a scalar, then `lognstat` expands the scalar argument into a constant array of the same size as the other argument. Each element in `m` and `v` is the mean and variance of the distribution specified by the corresponding elements in `mu` and `sigma`.

Example: `[1 1 1; 2 2 2]`

Data Types: `single` | `double`

## Output Arguments

collapse all

Mean of the lognormal distribution, returned as a scalar value or an array of scalar values. `m` is the same size as `mu` and `sigma` after any necessary scalar expansion. Each element in `m` is the mean of the lognormal distribution specified by the corresponding elements in `mu` and `sigma`.

Variance of the lognormal distribution, returned as a scalar value or an array of scalar values. `v` is the same size as `mu` and `sigma` after any necessary scalar expansion. Each element in `v` is the variance of the lognormal distribution specified by the corresponding elements in `mu` and `sigma`.

collapse all

### Lognormal Distribution

The lognormal distribution is a probability distribution whose logarithm has a normal distribution.

The mean m and variance v of a lognormal random variable are functions of the lognormal distribution parameters µ and σ:

`$\begin{array}{l}m=\mathrm{exp}\left(\mu +{\sigma }^{2}/2\right)\\ v=\mathrm{exp}\left(2\mu +{\sigma }^{2}\right)\left(\mathrm{exp}\left({\sigma }^{2}\right)-1\right)\end{array}$`

Also, you can compute the lognormal distribution parameters µ and σ from the mean m and variance v:

`$\begin{array}{l}\mu =\mathrm{log}\left({m}^{2}/\sqrt{v+{m}^{2}}\right)\\ \sigma =\sqrt{\mathrm{log}\left(v/{m}^{2}+1\right)}\end{array}$`

## References

[1] Mood, A. M., F. A. Graybill, and D. C. Boes. Introduction to the Theory of Statistics. 3rd ed., New York: McGraw-Hill, 1974. pp. 540–541.

[2] Evans, M., N. Hastings, and B. Peacock. Statistical Distributions. 2nd ed., Hoboken, NJ: John Wiley & Sons, Inc., 1993.