0% found this document useful (0 votes)
17 views1 page

distribution

Uploaded by

donruffcorn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views1 page

distribution

Uploaded by

donruffcorn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

import matplotlib.

pyplot as plt
import numpy as np
import scipy.stats as stats
import math

mu = 0
variance = 1
sigma = math.sqrt(variance)
x = np.linspace(mu - 3*sigma, mu + 3*sigma, 100)
dx= (2*3*sigma)/100.
sum=0.0
for i in x: sum = sum + stats.norm.pdf(i, mu, sigma)*dx
print ("sum =",sum)
plt.plot(x, stats.norm.pdf(x, mu, sigma))
#plt.show()

pi=3.14
e=2.71828
u=1
Q= 1.0
def normal_dist(x):
return (1/(Q*(2 * pi)**.5))*e** (-( (x-u)**2) / (2 *Q**2) )

plt.plot(x, normal_dist(x))
plt.show()

import numpy as np
from scipy.stats import lognorm
import matplotlib.pyplot as plt

# Calculate moments
s = 0.954
mean, var, skew, kurt = lognorm.stats(s, moments='mvsk')

# Display PDF
x = np.linspace(lognorm.ppf(0.01, s), lognorm.ppf(0.99, s), 100)
plt.plot(x, lognorm.pdf(x, s) )#, 'r-', lw=5, alpha=0.6, label='lognorm pdf')

dx= (-.01+lognorm.ppf(0.99, s))/100.


sum=0.0
for i in x: sum = sum + lognorm.pdf(i, s)*dx
print ("sum =",sum)
# Generate random numbers
r = lognorm.rvs(s, size=1000)
#plt.hist(r, density=True, bins='auto', histtype='stepfilled', alpha=0.2)
#plt.plot(x, stats.norm.pdf(x, mu, sigma))
plt.xlabel('x')
plt.ylabel('Density')
plt.title('Log-Normal Distribution')
#plt.legend(loc='best', frameon=False)
plt.show()

You might also like