Generate non-normal distributions with known mean, variance, skewness and kurtosis
Project description
non-normal
Generate a non-normal distributions with given a mean, variance, skewness and kurtosis using the Fleishman Method, essentially a cubic transformation on a standard normal [X~N(0, 1)]
$$ Y =a +bX +cX^2 +dX^3 $$
where the coefficients ($a, b, c, d$) are tuned to create a distribution with the desired statistic
Figure 1. A non-normal field generated in the usage
section below. The title
shows the input parameters, and the emperically measured statistics of the
generated distribution
Installation
Installs cleanly with a single invocation of the standard Python package tool:
$ pip install non-normal
Usage
from non_normal import fleishman
# Input parameters for non-normal field
mean = 0
var = 1
skew = 1
ekurt = 2
size = 2**20
# Create an instance of the Fleishman class
ff = fleishman.Fleishman(mean=mean, var=var, skew=skew, ekurt=ekurt, size=size)
# Generate the field
ff.gen_field()
non_normal_data = ff.field
# Measure the stats of the generated samples
ff.field_stats
>>> {'mean': 0.000203128504124,
'var': 1.001352686678266,
'skew': 1.005612915524984,
'ekurt': 2.052527629375554,}
References
- A method for simulating non-normal distributions
- Functions for Simulating Data by Using Fleishman’s Transformation
- Generation of Non-normal Data – A Study of Fleishman’s Power Method
- Computing the real solutions of Fleishman's equations for simulating non-normal data
- Simulating multivariate nonnormal distributions
- https://gist.github.com/zeimusu/7432603b85dc6406c6ea
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for non_normal-0.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30820a766d3e24cbf19b73337e77aa79d7f997dfb581c3a1930465a2f8598dfb |
|
MD5 | f828ca617876f5ec13337fbb9d052cbe |
|
BLAKE2b-256 | cea73a583059688a12a5f011238c2cb8fa8400498559681c7a13d37ae91a5eec |