import numpy as np import numpy as np from matplotlib import pyplot as plt import qqplot as qq import scipy.stats as stats import math sulphur=np.array([52.7,53.9,41.7,71.5,47.6,55.1, 62.2,56.5,33.4,61.8,54.3,50.0, 45.3,63.4,53.9,65.5,66.6,70.0, 52.4,38.6,46.1,44.4,60.7,56.4]) qq.qqplots(sulphur,title='',xlabel='z-score',ylabel='normal vaue') plt.show() print "===============================" print " Problem 4 " shap = stats.shapiro(sulphur) print "shapiro output\n",shap print "mean shulpur = ",np.mean(sulphur) print "std shulpur = ",np.std(sulphur) print np.mean(sulphur),"+/-",stats.norm.ppf(1-0.05/2)*np.std(sulphur)/math.sqrt(24) print "Z=",(54.3333-50)/(np.std(sulphur)/math.sqrt(24))
#Box plot import matplotlib.pyplot as plt fig = plt.figure(figsize=(10,6)) fig.canvas.set_window_title('A Boxplot Example') bp = plt.boxplot(rain, notch=0, sym='+', vert=1, whis=1.5) ax1 = fig.add_subplot(111) # Add a horizontal grid to the plot, but make it very light in color # so we can use it for reading data values but not be distracting ax1.yaxis.grid(True, linestyle='-', which='major', color='lightgrey', alpha=0.5) plt.setp(bp['boxes'], color='black') plt.setp(bp['whiskers'], color='black') plt.setp(bp['fliers'], color='red', marker='+') # QQ-plot : import qqplot as qq qq.qqplots(rain) plt.show() #plot iii