简体   繁体   中英

How to draw random numbers from a normal distribution with given mean, variance, skewness and kurtosis

I'm trying to draw random numbers from a normal distribution with given mean , variance , skewness and kurtosis .

My first attempt was to use the numpy function random.normal however to this function as far as i understand i can only pass a location ( mean ) and a scale ( std ) parameter.

Second attempt is to draw random numbers from the uniform distribution in the interval [0,1] and then pass them through the scipy.stats.norm method ppf. I see that scipy has the ability to treat skewness and kurtosis, however i cannot see how i can pass skewness and kurtosis values into the function.

If the problem should be solved in an entirely different way please let me know.

Attempt 1:

import numpy as np

def draw_normal():
    return np.random.normal(loc=0, scale=1) # how to pass skew and kurtosis (excess kurtosis) to the function 

Attempt 2

import numpy as np
from scipy.stats import norm


def draw_uniform():
    return np.random.uniform(0,1)

def draw_normal_alt():
    return norm.ppf(draw_uniform(),loc=0, scale=1) #how to pass skew and kurtosis (excess kurtosis) to func

What you want is not a normal distribution anymore. You should look into other kinds of distributions.
Note that there are many distributions with the same mean, variance, skewness, and kurtosis.
For a python function that generates what you want, see this .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM