Question: Write a python program that demonstrates your knowledge of the following topics. How to plot histograms using matplotlib How to populate a figure using matplotlib
Write a python program that demonstrates your knowledge of the following topics.
How to plot histograms using matplotlib
How to populate a figure using matplotlib
How to decorate a figure using matplotlib
How to find the mean and standard deviation of a dataset
How to create a normal distribution curve for a given mean and standard deviation
How to overlay a normal distribution curve on a histogram
Write and submit a Python module named ProjRunner.py that works in conjunction with the driver source code contained in the file named Projpy
The program must terminate and return control to the operating system when the user dismisses the image by clicking the Xbutton on the image window.
You may not modify the code in the file named Projpy for the purpose of meeting this specification. The normed parameter has been removed from the hist method in later versions of pyplot. Don't use "normedTrue". Use "densityTrue" instead.
Here is Projpy:
from ProjRunner import Runner
import sys
import random
#Define a utility function that will be used later to create
#several datasets.
def normalRandomGeneratorseeddataLengthnumberSamples
lowLimhighLim:
Create a new dataset of dataLength values consisting of the
average of numberSamples samples taken from a population of
uniformly distributed values between lowLim and highLim
generated with a seed of seed.
Input keyword parameters and their default values:
seed seed used to generate the uniformly distributed values
dataLength number of samples in the returned list of values
numberSamples number of samples taken from the uniformly
distributed population and averaged into the output
lowLim lower limit value of the uniformly distributed population
highLim high limit value of the uniformly distributed population
returns: a list containing the dataset
data
random.seedseed
for cnt in rangedataLength:
theSum
for cnt in rangenumberSamples:
theSum random.uniformlowLimhighLim
data.appendtheSumnumberSamples
return data
##
#Populate variables that will be used to create four datasets.
xSeed
xDataLength
xNumberSamples
xLowLim
xHighLim
print
xSeed xSeed
printxDataLength xDataLength
printxNumberSamples xNumberSamples
printxLowLim xLowLim
printxHighLim xHighLim
print
#Create four datasets
data normalRandomGeneratorseedxSeed,dataLengthxDataLength,
numberSamplesxNumberSamples,
lowLimxLowLim,
highLimxHighLim
data normalRandomGeneratorseedxSeed,dataLengthxDataLength,
numberSamples xNumberSamples
lowLimxLowLim,
highLimxHighLim
data normalRandomGeneratorseedxSeed,dataLengthxDataLength,
numberSamples xNumberSamples
lowLimxLowLim,
highLimxHighLim
data normalRandomGeneratorseedxSeed,dataLengthxDataLength,
numberSamples xNumberSamples
lowLimxLowLim,
highLimxHighLim
printOutput from student code begins here."
#Call the student's run method in the class named Runner in the
#file named ProjRunner.py passing four datasets as parameters.
Runner.rundatadatadatadata
#end of proj program
My questions is is my runner file okay?
Here is my ProjRunner.py file:
import matplotlib.pyplot as plt
import numpy as np
class Runner:
@staticmethod
def rundata data data data:
# Create histograms for each dataset
pltfigurefigsize
plthistdata bins densityTrue, alpha label'Dataset
plthistdata bins densityTrue, alpha label'Dataset
plthistdata bins densityTrue, alpha label'Dataset
plthistdata bins densityTrue, alpha label'Dataset
# Calculate mean and standard deviation for each dataset
mean std npmeandata npstddata
mean std npmeandata npstddata
mean std npmeandata npstddata
mean std npmeandata npstddata
# Plot normal distribution curves
x nplinspacemindata data data data maxdata data data data
pltplotxstd npsqrt nppi npexpx mean std label'Normal Dist.
pltplotxstd npsqrt nppi npexpx mean std label'Normal Dist.
pltplotxstd npsqrt nppi npexp
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
