Home
Locate
CS 101
CS 496
Login
Tutors
Marks
About
Send
Close
Add comments:
(status displays here)
Got it!
This site uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website.
nbsp; Note: This appears on each machine/browser from which this site is accessed.
Python: Normal and exponential distributions
by RS
admin@ycp.powersoftwo.org
c
go
java
js
lua
py
vbs
rkt
scm
pro
1. Python: Normal and exponential distributions
2. Normal distribution
Here is the Python code.
import matplotlib.pyplot as plt import rsPlot import numpy as np import scipy.stats as stats import math plot1 = rsPlot.plot("dist11-1") mean1 = 0.0 variance1 = 1.0 sigma1 = math.sqrt(variance1) colorList1 = [ "#CCCCFF", "#9999FF", "#6666FF", ] for factor0 in range(0,3): print("{0:d}".format(factor0)) factor1 = float(3-factor0) xmin1 = mean1 - factor1*sigma1 xmax1 = mean1 + factor1*sigma1 points1 = 100 xData1 = np.linspace(xmin1, xmax1, points1) yData1 = stats.norm.pdf(xData1, mean1, sigma1) plt.plot(xData1, yData1, color="#0000FF") color1 = colorList1[factor0] plt.fill_between(xData1,yData1,color=color1) plot1.save()
Here is the output of the Python code.
(module rsPlot imported) 0 1 2 ./dist11-1-01.png : 571 x 414 , 23,688 bytes
3. Exponential distribution
Here is the Python code.
import matplotlib.pyplot as plt import rsPlot import numpy as np from scipy.stats import expon plot1 = rsPlot.plot("dist11-2") points1 = 100 xData1 = np.linspace(expon.ppf(0.01),expon.ppf(0.99), points1) yData1 = expon.pdf(xData1) plt.plot(xData1, yData1, color="#0000FF") plt.fill_between(xData1,yData1,color="#9999FF") plot1.save()
Here is the output of the Python code.
(module rsPlot imported) ./dist11-2-01.png : 557 x 414 , 15,275 bytes
4. End of page
by RS
admin@ycp.powersoftwo.org