Plotting of 1-dimensional Gaussian distribution function

后端 未结 5 428
忘掉有多难
忘掉有多难 2021-02-04 01:09

How do I make plots of a 1-dimensional Gaussian distribution function using the mean and standard deviation parameter values (μ, σ) = (−1, 1), (0, 2), and (2, 3)?

I\'m n

5条回答
  •  被撕碎了的回忆
    2021-02-04 01:53

    you can read this tutorial for how to use functions of statistical distributions in python. http://docs.scipy.org/doc/scipy/reference/tutorial/stats.html

    from scipy.stats import norm
    import matplotlib.pyplot as plt
    import numpy as np 
    
    #initialize a normal distribution with frozen in mean=-1, std. dev.= 1
    rv = norm(loc = -1., scale = 1.0)
    rv1 = norm(loc = 0., scale = 2.0)
    rv2 = norm(loc = 2., scale = 3.0)
    
    x = np.arange(-10, 10, .1)
    
    #plot the pdfs of these normal distributions 
    plt.plot(x, rv.pdf(x), x, rv1.pdf(x), x, rv2.pdf(x))
    

提交回复
热议问题