-
Notifications
You must be signed in to change notification settings - Fork 0
/
statisticalDistributions.py
55 lines (35 loc) · 1.08 KB
/
statisticalDistributions.py
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
""" Here definitions and attributes of all statistical distributions that are used in the simulation are defined"""
from abc import ABCMeta, abstractmethod
import random
#import np
class StatDis(object):
__metaclass__ = ABCMeta
def __init__(self):
pass
@abstractmethod
def generate(self):
pass
class UniformDis(StatDis):
def __init__(self, minVal, maxVal):
self.minVal = minVal
self.maxVal = maxVal
def generate(self):
return random.uniform(self.minVal, self.maxVal)
class NormalDis(StatDis):
def __init__(self, mean, std):
self.mean = mean
self.std = std
def generate(self):
return np.random.normal(self.mean, self.std, 1)[0]
class ConstantDis(StatDis):
def __init__(self, val):
self.val = val
def generate(self):
return self.val
class TriangularDis(StatDis):
def __init__(self, low, high, mode):
self.low = low
self.high = high
self.mode = mode
def generate(self):
return random.triangular(self.low, self.high, self.mode)