-
Graphing Data 4
-
Lecture1.1
-
Lecture1.2
-
Lecture1.3
-
Lecture1.4
-
-
Mean and Standard Deviation 5
-
Lecture2.1
-
Lecture2.2
-
Lecture2.3
-
Lecture2.4
-
Lecture2.5
-
-
Distributions 6
-
Lecture3.1
-
Lecture3.2
-
Lecture3.3
-
Lecture3.4
-
Lecture3.5
-
Lecture3.6
-
-
Correlation and Linear Regression 7
-
Lecture4.1
-
Lecture4.2
-
Lecture4.3
-
Lecture4.4
-
Lecture4.5
-
Lecture4.6
-
Lecture4.7
-
-
Probability 3
-
Lecture5.1
-
Lecture5.2
-
Lecture5.3
-
-
Counting Principles 3
-
Lecture6.1
-
Lecture6.2
-
Lecture6.3
-
-
Binomial Distribution 3
-
Lecture7.1
-
Lecture7.2
-
Lecture7.3
-
-
Confidence Interval 7
-
Lecture8.1
-
Lecture8.2
-
Lecture8.3
-
Lecture8.4
-
Lecture8.5
-
Lecture8.6
-
Lecture8.7
-
-
Proportion Confidence Interval 3
-
Lecture9.1
-
Lecture9.2
-
Lecture9.3
-
-
Hypothesis Testing 5
-
Lecture10.1
-
Lecture10.2
-
Lecture10.3
-
Lecture10.4
-
Lecture10.5
-
-
Comparing Two Means 5
-
Lecture11.1
-
Lecture11.2
-
Lecture11.3
-
Lecture11.4
-
Lecture11.5
-
-
Chi-squared Test 3
-
Lecture12.1
-
Lecture12.2
-
Lecture12.3
-
Solution
Solution
class normalPlotter:
def __init__(self,dist):
self.dist = dist
def plot(self,xPoint,end,zScore = False):
xVals = list(range(end+1))
yVals = [self.dist.pdf(x) for x in xVals]
xVals2 = list(range(xPoint+1))
yVals2 = [self.dist.pdf(x) for x in xVals2]
if zScore:
xVals = [(x-self.dist.mean())/self.dist.std() for x in xVals]
xVals2 = [(x-self.dist.mean())/self.dist.std() for x in xVals2]
plt.plot(xVals,yVals)
if zScore:
plt.xlabel("Z Score")
else:
plt.xlabel("Value")
plt.ylabel("Density")
plt.fill_between(xVals2, yVals2)
plt.show()
xVals = list(range(end+1))
yVals = [self.dist.cdf(x) for x in xVals]
if zScore:
xVals = [(x-self.dist.mean())/self.dist.std() for x in xVals]
plt.plot(xVals,yVals)
plt.xlabel("Z Score")
plt.ylabel("Cummulative Percentage")
if zScore:
plt.xlabel("Z Score")
plt.plot((xPoint-self.dist.mean())/self.dist.std(),dist.cdf(xPoint),"ro")
else:
plt.xlabel("Value")
plt.plot(xPoint,dist.cdf(xPoint),"ro")
plt.show()
x = normalPlotter(scipy.stats.norm(400,100))
x.plot(350,800)
x.plot(350,800,zScore=True)
The only new thing here may be how we use zScore = False in the plot function. This sets up an optional parameter, it is by default false, but the user could change it to true.
Source Code
Prev
Plotting
Next
Introduction