Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168732
Image: ubuntu2004
from pylab import * x = loadtxt(DATA+'thermocouples.dat',skiprows=1) hold(True) plot(x[:,0],x[:,1],'b') savefig('.') t = x[:,0] x = x[:,1] x_mean = mean(x) x_median = median(x) x_variance = var(x) x_std = std(x) x_modes = histogram(x) x_mode_ind = argmax(x_modes[0]) x_mode_count = x_modes[0][x_mode_ind] x_mode_val = x[x_mode_ind] # print "Data:"; print x print "Mean: %f " % x_mean print "Median: %f" % x_median print "Variance: %f" % x_variance print "STD: %f " % x_std print "Mode of x %f appears %d times" % (x_mode_val,x_mode_count) xr = x_mean + x_std*rand(10000) figure() n, bins, patches = hist(x, 20, normed=1, facecolor='green', alpha=0.75) from matplotlib.mlab import normpdf y = normpdf( bins, x_mean, x_std) l = plot(bins, y, 'r--', linewidth=2) savefig('.')
Mean: 31.009320 Median: 31.015000 Variance: 2.212082 STD: 1.487307 Mode of x 29.250000 appears 245 times