## distributions.Lognormal


Lognormal distribution implementation.


Usage

``` python
distributions.Lognormal(
    mean,
    stdev,
    random_seed=None,
)
```


A continuous probability distribution where the logarithm of a random variable is normally distributed. It is useful for modeling variables that are the product of many small independent factors.

This class conforms to the Distribution protocol and provides methods to sample from a lognormal distribution with a specified mean and standard deviation.


## Methods

| Name | Description |
|----|----|
| [__init__()](#__init__) | Initialize a lognormal distribution. |
| [normal_moments_from_lognormal()](#normal_moments_from_lognormal) | Calculate mu and sigma of the normal distribution underlying |
| [sample()](#sample) | Generate random samples from the lognormal distribution. |

------------------------------------------------------------------------


#### \_\_init\_\_()


Initialize a lognormal distribution.


Usage

``` python
__init__(mean, stdev, random_seed=None)
```


##### Parameters


`mean: float`  
Mean of the lognormal distribution.

`stdev: float`  
Standard deviation of the lognormal distribution.

`random_seed: Optional[Union[int, SeedSequence]] = None`  
A random seed or SeedSequence to reproduce samples. If None, a unique sample sequence is generated.


------------------------------------------------------------------------


#### normal_moments_from_lognormal()


Calculate mu and sigma of the normal distribution underlying


Usage

``` python
normal_moments_from_lognormal(m, v)
```


a lognormal with mean m and variance v.


##### Parameters


`m: float`  
Mean of lognormal distribution.

`v: float`  
Variance of lognormal distribution.


##### Returns


`Tuple[float, float]`  
The mu and sigma parameters of the underlying normal distribution.


##### Notes

Formula source: https://blogs.sas.com/content/iml/2014/06/04/simulate-lognormal-data- with-specified-mean-and-variance.html

------------------------------------------------------------------------


#### sample()


Generate random samples from the lognormal distribution.


Usage

``` python
sample(size=None)
```


##### Parameters


`size: Optional[Union[int, Tuple[int, …]]] = None`  
The number/shape of samples to generate:

- If None: returns a single sample as a float
- If int: returns a 1-D array with that many samples
- If tuple of ints: returns an array with that shape


##### Returns


`Union[float, NDArray[np.float64]]`  
Random samples from the lognormal distribution:

- A single float when size is None
- A numpy array of floats with shape determined by size parameter
