0% found this document useful (0 votes)
42 views2 pages

Import As: in (1) : in (2) : in (3) : in (4) : in

The document contains code that calculates the weighted mean and uncertainty of the mean of a dataset. It defines arrays for lifetime measurements (lt) and their uncertainties (sigma). It calculates the weighted mean (ltmean) as the sum of each measurement divided by its uncertainty squared, divided by the total sum of the inverse of uncertainties squared. It then calculates the uncertainty of the mean (unctymean) as the standard deviation of the measurements from the mean, divided by the square root of the number of measurements. The weighted mean lifetime is printed as 0.912278008012 with uncertainty of the mean as 0.01861.

Uploaded by

surujJD
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views2 pages

Import As: in (1) : in (2) : in (3) : in (4) : in

The document contains code that calculates the weighted mean and uncertainty of the mean of a dataset. It defines arrays for lifetime measurements (lt) and their uncertainties (sigma). It calculates the weighted mean (ltmean) as the sum of each measurement divided by its uncertainty squared, divided by the total sum of the inverse of uncertainties squared. It then calculates the uncertainty of the mean (unctymean) as the standard deviation of the measurements from the mean, divided by the square root of the number of measurements. The weighted mean lifetime is printed as 0.912278008012 with uncertainty of the mean as 0.01861.

Uploaded by

surujJD
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

QUESTION 4

January 24, 2018

In [1]: import numpy as np

In [2]: lt=np.array([0.8920,0.881,0.8913,0.9837,0.8958])

In [3]: sigma=np.array([0.00044,0.009,0.00032,0.00048,0.00045])

In [4]: sigmasq=sigma**2

In [5]: sigmasq

Out[5]: array([ 1.93600000e-07, 8.10000000e-05, 1.02400000e-07,


2.30400000e-07, 2.02500000e-07])

In [9]: num=0
for i in range(len(lt)-1):
num+=lt[i]/sigmasq[i]

In [10]: num

Out[10]: 17591947.3722388

In [11]: den=0
for i in range(len(lt)-1):
den+=1/sigmasq[i]

In [12]: den

Out[12]: 19283537.712988466

In [13]: ltmean=num/den

In [14]: ltmean

Out[14]: 0.91227800801248771

In [15]: E=0
for i in range(len(lt)-1):
E+=(lt[i]-ltmean)**2
s=np.sqrt(E/(len(lt)-1))

1
In [16]: s

Out[16]: 0.041625380340064258

In [17]: unctymean=s/np.sqrt(len(lt))

In [18]: unctymean

Out[18]: 0.018615436005933399

In [19]: print('The weighted mean lifetime of K Meson is',ltmean, 'and uncertainty of the mean

The weighted mean lifetime of K Meson is 0.912278008012 and uncertainty of the mean is 0.01861

You might also like