    36 Pages
English

# Python for Science and Engg: Basic data processing (session 3)

-

Learn all about the services we offer Description

Python for Science and Engg:Basic data processingFOSSEEDepartment of Aerospace EngineeringIIT BombaySciPy 2010, Introductory tutorials,Day 1, Session 3FOSSEE (IIT Bombay) Statistics 1 / 36Computing the meanOutline1 Computing the mean2 Processing voluminous dataData processingDictionariesVisualizing dataObtaining statisticsFOSSEE (IIT Bombay) Statistics 2 / 36Computing the meanValue of acceleration due to gravity?We already havependulum.txtqLWe know that T = 2g24 LSo g= 2TCalculate g - acceleration due to gravity for eachpair of L and THence calculate mean gFOSSEE (IIT Bombay) Statistics 3 / 36Computing the meanAcceleration due to gravity - g. . .In []: g_list = []In []: for line in open(’pendulum.txt’):.... point = line.split() L = float(point).... t = float(point) g = 4 pi pi L / (t t)* * * *.... g_list.append(g)FOSSEE (IIT Bombay) Statistics 4 / 36Computing the meanMean g - Classical methodIn []: total = 0In []: for g in g_list:....: total += gIn []: g_mean = total / len(g_list)In []: print ’Mean: ’, g_meanFOSSEE (IIT Bombay) Statistics 5 / 36Computing the meanMean g - Slightly improved methodIn []: g_mean = sum(g_list) / len(g_list)In []: print ’Mean: ’, g_meanFOSSEE (IIT Bombay) Statistics 6 / 36Computing the meanMean g - One linerIn []: g_mean = mean(g_list)In []: print ’Mean: ’, g_mean10 mFOSSEE (IIT Bombay) Statistics 7 / 36Processing voluminous dataOutline1 Computing the mean2 Processing voluminous ...

Subjects

##### Calcul (mathématiques)

Informations OFSSE
Python for Science and Engg: Basic data processing
EI(ITBom
FOSSEE
Department of Aerospace Engineering IIT Bombay
SciPy 2010, Introductory tutorials, Day 1, Session 3
bay)Statistics1/63 S)yabmoBcitsitatFOIT(IEESS6
1
Computing the mean
s2/3
2
Processing voluminous Data processing Dictionaries Visualizing data Obtaining statistics
data
upitCmolinenOutemeangth SSOFEE(IITBombay)Staittsci3s3/6
We already havenepttxm.ludu We know thatT=2πqgL
Sog4π2L =T2 Calculateg- acceleration due to gravity for each pair ofLandT Hence calculate meang
hegtanmempCoinutgravity?ionduetoccleretaaVuloeaf Computing the mean Acceleration due to gravity -g. . . In []: g_ ist = [] l In []:forlineinopen(txpe.tumulnd): .... point = line.split() .... L = float(point) .... t = float(point) .... g = 4 * pi * pi * L / (t * t) .... g_list.append(g) FOSSEE (IIT Bombay) Statistics 4 / 36 I(EESSOFsicalmetang-ClasohdThIeomBebamnyMaeSm)pauttiitntgstics5/36oC
In []: In []: ....: ....:
total = 0 forging_stli: total += g
In []: In []:
g_mean = total / len(g_list) print’Mean: ’, g_mean g_mean = sum(g_list) / print’Mean: ’, g_mean
63/6scitsitatSy)baomTBIIE(SEOS
[]: []:
In In
(nelodthFg_list)utinCompnaemehtglS-gnaeMimlyhtigmeedovpr EESSFOmbBoIT(I
[]: []:
g_mean = mean(g_list) print’Mean: ’, g mean _
6
10 m
In In
atityaS)7s3/tscieanM-OnglinernemoCituphtgnaeme Computing the mean
1
Processing voluminous Data processing Dictionaries Visualizing data Obtaining statistics
2
data
EESSOFbmoBTII(tita)Say/3s8icst We have a huge data ﬁle–180,000 records. How do we dotenecifstatistical computations, i.e. ﬁnd mean, median, standard deviation etc.; How do we draw pie charts?
atisy)St9/36ticsES(EFSOmoabIIBT icst0/s1)SaytitaTII(bmoBOFEESS
A;015162;JENIL T P;081;060;77;41;74;333;P;;
63
Understanding the structure of.tc1xtsls Each line in the ﬁle has a student’s details(record) Each record consists of ﬁelds separated by ’;’
leaStructureofthenivglomuniuodstaroPssce 