## distributions.PearsonV


Pearson Type V distribution implementation (inverse Gamma distribution).


Usage

``` python
distributions.PearsonV(
    alpha,
    beta,
    random_seed=None,
)
```


Where alpha = shape, and beta = scale (both \> 0).

Law (2007, pg 293-294) defines the distribution as PearsonV(alpha, beta) = 1/Gamma(alpha, 1/beta) and notes that the PDF is similar to that of lognormal, but has a larger spike close to 0. It can be used to model the time to complete a task.

For certain values of the shape parameter the mean and variance can be directly computed:

mean = beta / (alpha - 1) for alpha \> 1.0 var = beta^2 / (alpha - 1)^2 × (alpha - 2) for alpha \> 2.0

This class conforms to the Distribution protocol.


## Alternative Sources:

\[1\] https://riskwiki.vosesoftware.com/PearsonType5distribution.php \[2\] https://modelassist.epixanalytics.com/display/EA/Pearson+Type+5


## Note

A good R package for Pearson distributions is PearsonDS https://www.rdocumentation.org/packages/PearsonDS/versions/1.3.0


## Attributes

| Name | Description |
|----|----|
| [mean](#mean) | Calculate the mean of the Pearson Type V distribution. |
| [variance](#variance) | Calculate the variance of the Pearson Type V distribution. |

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


#### mean


Calculate the mean of the Pearson Type V distribution.


`mean: float`


##### Raises


`ValueError`  
If alpha \<= 1.0, as the mean is not defined in this case.


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


#### variance


Calculate the variance of the Pearson Type V distribution.


`variance: float`


##### Raises


`ValueError`  
If alpha \<= 2.0, as the variance is not defined in this case.


## Methods

| Name | Description |
|----|----|
| [__init__()](#__init__) | Initialize a Pearson Type V distribution. |
| [sample()](#sample) | Generate random samples from the Pearson Type V distribution. |

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


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


Initialize a Pearson Type V distribution.


Usage

``` python
__init__(alpha, beta, random_seed=None)
```


##### Parameters


`alpha: float`  
Shape parameter. Must be \> 0.

`beta: float`  
Scale parameter. Must be \> 0.

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


##### Raises


`ValueError`  
If alpha or beta are not positive.


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


#### sample()


Generate random samples from the Pearson Type V 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 Pearson Type V distribution:

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