radioactiveshrimp 0.1.1__cp39-abi3-manylinux_2_28_x86_64.whl → 0.1.2__cp39-abi3-manylinux_2_28_x86_64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ """
2
+ Distribution subpackage containing distrobution functions.
3
+ """
4
+ from .cvdistributions import uniform, exponentialdist, poissondist
5
+ __all__=['uniform,exponentialdist, poissondist']
@@ -0,0 +1,111 @@
1
+ import secrets
2
+ import numpy as np
3
+ # import matplotlib.pyplot as plt
4
+ import math as m
5
+
6
+ def uniform(a:float = 0.0, b:float = 1.0)->float:
7
+ """
8
+ Generate cryptographically Secure uniform sample
9
+
10
+ Args:
11
+ a (float): lower bound value (default 0.0)
12
+ b (float): upper bound value (default 1.0)
13
+
14
+ Returns:
15
+ float representing uniform sample
16
+
17
+ Example:
18
+ >>> uniform()
19
+ 0.3546927444895387
20
+ >>> uniform()
21
+ 0.21098189931876055
22
+ """
23
+ # 53 random bits gives 53-bit precision double
24
+ u = secrets.randbits(53)/(1<<53) # in [0,1)
25
+ return a+(b-a)*u
26
+
27
+ def exponentialdist(lamb):
28
+ """
29
+ Generate exponentially distributed sample
30
+
31
+ Args:
32
+ lamb (float or int >0): lambda value of exponential distrobution
33
+
34
+ Returns:
35
+ x: float representing the exponentially distributed sample
36
+
37
+ Raises:
38
+ ValueError: if lambda is not greater than 0
39
+
40
+ Example:
41
+ >>> uexponentialdist(1)
42
+ 0.6839328417240588
43
+ >>> uexponentialdist(1)
44
+ 2.901353101723147
45
+ >>> exponentialdist(.5)
46
+ 2.451134119865936
47
+ """
48
+ if lamb<=0:
49
+ raise ValueError('Lambda must be greater than 0')
50
+
51
+ y = uniform()
52
+ x = -(1/lamb)*np.log(y)
53
+ return x
54
+
55
+
56
+ def poissondist(lamb):
57
+ """
58
+ Generate poisson distributed sample
59
+
60
+ Args:
61
+ lamb (int or float > 0): lambda value of poisson distribution
62
+
63
+ Returns:
64
+ i: int representing poisson distributed sample
65
+
66
+ Example:
67
+ >>> poissondist(1)
68
+ 1
69
+ >>> poissondist(1)
70
+ 3
71
+ >>> poissondist(10)
72
+ 9
73
+ """
74
+ if lamb<=0:
75
+ raise ValueError('Lambda must be greater than 0')
76
+
77
+ elamb = np.exp(-lamb)
78
+ i = 0
79
+ y = uniform()
80
+ prob = elamb
81
+ while y>prob:
82
+ i = i+1
83
+ factorial = m.factorial(i)
84
+ power = lamb**i
85
+ # print(y,i,elamb, power, factorial)
86
+ prob = prob + (power/factorial)*elamb
87
+
88
+ return i
89
+
90
+
91
+ # # draw histogram of 100,000 randomly distributed samples using exponential distribution
92
+ # samplexs = []
93
+ # for _ in range(100000):
94
+ # samplexs.append(exponentialdist(1))
95
+
96
+ # plt.figure()
97
+ # hist = plt.hist(samplexs, bins='auto', orientation='horizontal', histtype='bar')
98
+ # plt.xlabel('count')
99
+ # plt.ylabel('X')
100
+ # plt.show()
101
+
102
+ # # draw histogram of 100,000 randomly distributed samples using exponential distribution
103
+ # samplexs = []
104
+ # for _ in range(100000):
105
+ # samplexs.append(poissondist(10))
106
+
107
+ # plt.figure()
108
+ # hist = plt.hist(samplexs, bins='auto', histtype='bar')
109
+ # plt.xlabel('X')
110
+ # plt.ylabel('count')
111
+ # plt.show()
@@ -1,6 +1,7 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: radioactiveshrimp
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
+ Requires-Dist: matplotlib>=3.10.6
4
5
  Requires-Dist: numpy>=2.3.3
5
6
  Requires-Dist: torch>=2.8.0
6
7
  Requires-Dist: twine>=6.1.0
@@ -1,11 +1,13 @@
1
- radioactiveshrimp-0.1.1.dist-info/METADATA,sha256=4miZ8FtVUImI28hoh1lyXSbo-IuHwLBUmaK838D378Y,378
2
- radioactiveshrimp-0.1.1.dist-info/WHEEL,sha256=VCoUqQjnl5wExkC-2PG3I2s7-FBXYum-vf1jh8qiYg8,97
1
+ radioactiveshrimp-0.1.2.dist-info/METADATA,sha256=eIFvbRoU_QV2ADRG--hldQQI256vfOcPQ6leK0jYZXI,412
2
+ radioactiveshrimp-0.1.2.dist-info/WHEEL,sha256=VCoUqQjnl5wExkC-2PG3I2s7-FBXYum-vf1jh8qiYg8,97
3
3
  radioactiveshrimp/__init__.py,sha256=QY4ait-Lo2WQdyx7MU8N6a1v2ZYyAmYRqzYqdNbiavI,101
4
4
  radioactiveshrimp/_core.abi3.so,sha256=3IMwsP7UrgNWdKdw2Pl11_VUQF8NqPy1xyyPuzkREdA,489672
5
5
  radioactiveshrimp/_core.pyi,sha256=b6oJaUXUzEzqUE5rpqefV06hl8o_JCU8pgKgIIzQgmc,33
6
6
  radioactiveshrimp/differential/__init.py__,sha256=jOhQKr6xM_7TVUt0GWRddtkgBvNn5I873WZcArT-GtE,101
7
7
  radioactiveshrimp/differential/discrete.py,sha256=9-w6Avz4MZfu8gFhJU8kTvryn9oT2xS1TvvYQ_8pmPU,1371
8
+ radioactiveshrimp/distributions/__init.py__,sha256=hZX2UFt54wJG4zDLuTTTonDSA-anWvfjhDmR-akYcn4,182
9
+ radioactiveshrimp/distributions/cvdistributions.py,sha256=UEiO_RYFQYqHybI_wcOdpOrxHToXRpLFsB58dwvI4vU,2599
8
10
  radioactiveshrimp/matrix/__init.py__,sha256=EoerrXlfmd2lI9grb3jxqIhHn-bzLtYhRKyxI0RVgaE,166
9
11
  radioactiveshrimp/matrix/elementary.py,sha256=zPiBG24F5zIncrrVWbiXEp1oFnHw2xNKy5quF0GBOuc,6333
10
12
  radioactiveshrimp/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
- radioactiveshrimp-0.1.1.dist-info/RECORD,,
13
+ radioactiveshrimp-0.1.2.dist-info/RECORD,,