import numpy as npimport matplotlib.pyplot as pltfrom scipy.stats import norm # Observationsobs = [ 0.4 , 0.4343 , 0.4571 , 0.48 , 0.5086 , 0.5543 , 0.5714 , 0.5943 , 0.6457 , 0.68 , 0.7086 , 0.7371 , 0.7543 , 0.8 , 0.8286 , 0.8514 , 0.8914 , 0.9086 , 0.9486 , 0.9829 , 1.0057 , 1.0229 , 1.0514 , 1.08 , 1.0914 , 1.12 , 1.1371 , 1.16 , 1.2 , 1.2229 , 1.28 , 1.2971 , 1.32 , 1.3429 , 1.3714 , 1.4171 , 1.44] # Descriptive statisticsminimum = min(obs) maximum = max(obs) m = np.mean(obs, axis=None) s = np.std(obs, axis=None) # Debugprint "mean:", mprint "standard deviation:", sprint "cdf:", "\n", norm.cdf(obs, m, s)print "pdf:", "\n", norm.pdf(obs, m, s) # Plot between min and max with .001 sized stepsx_axis = np.arange(minimum, maximum, 0.001) plt.ylabel('Density') plt.xlabel('Values') plt.plot(x_axis, norm.pdf(x_axis, m, s)) plt.show()
2019-02-05
Python - Probability Density Function & Cumulative Density Function, from sample vector of values
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment