forked from greyson-newton/Muon_Sim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexpDecay.py
More file actions
26 lines (24 loc) · 795 Bytes
/
expDecay.py
File metadata and controls
26 lines (24 loc) · 795 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import matplotlib.pyplot as plt
from math import exp
from scipy.stats import norm
class expDecay:
def __init__(self, xInit, xFinal, momentum):
self.momentum = int(momentum)
self.x = range(xInit, xFinal)
self.Y = [self.momentum*exp(-0.5*_) for _ in self.x]
self.size = len(self.x)
self.error = norm.rvs(0, scale=0.0001, size=self.size)
self.simulated_data = [max(0, y+e) for (y,e) in zip(self.Y[:self.size],self.error)]
#print(self.simulated_data)
def returnStepSize(self, index):
return self.Y[index]
def returnStepSizes(self):
return self.Y
# def plot(self):
#plt.plot(self.x, self.Y, 'b-')
#plt.plot(self.x[:self.size], self.simulated_data, '')
#xx=1
#xPt = [xx,xx]
#yLine = [0,self.Y[xx]]
#plt.plot(xPt, yLine, 'k-')
#plt.show()