from matplotlib import pyplot as plt
from symbulate import *
Exponential Distributions
Exponential distributions
= RV(Exponential(rate = 1 / 30))
W
= W.sim(10000)
w
w
Index | Result |
---|---|
0 | 19.31839707102859 |
1 | 38.907071499553666 |
2 | 21.927303602168685 |
3 | 15.075911145136045 |
4 | 14.569965399393402 |
5 | 68.87110665884259 |
6 | 22.488723125132488 |
7 | 2.264654223306332 |
8 | 26.614583774147018 |
... | ... |
9999 | 33.17331598333397 |
;
plt.figure()
w.plot()
= 1 / 30).plot()
Exponential(rate
; plt.show()
45) / 10000, 1 - Exponential(rate = 1 / 30).cdf(45) w.count_gt(
(0.2227, 0.2231301601484298)
Scaling
= RV(Exponential(rate = 1))
U
= U / (1 / 30)
W
;
plt.figure()
10000).plot()
W.sim(
= 1 / 30).plot()
Exponential(rate
; plt.show()
= RV(Exponential(rate = 1))
U
= U / 2
V
;
plt.figure()
10000).plot()
V.sim(
= 2).plot()
Exponential(rate
; plt.show()
Memoryless property
;
plt.figure()
10000).plot()
W.sim(
- 120 | (W > 120) ).sim(10000).plot()
(W
; plt.show()
Exponential race
= RV(Exponential(rate = 1 / 10) * Exponential(rate = 1 / 20))
X, Y
= (X & Y).apply(min) W
= (X & Y & W).sim(10000)
xyw xyw
Index | Result |
---|---|
0 | (4.983024727303675, 1.8686496510707014, 1.8686496510707014) |
1 | (3.532554503008326, 9.05367112944098, 3.532554503008326) |
2 | (24.918965681064886, 13.345421877996436, 13.345421877996436) |
3 | (1.0775484149017658, 42.42848811731041, 1.0775484149017658) |
4 | (8.548471948094639, 7.969724384024137, 7.969724384024137) |
5 | (2.799644404617912, 44.18113902851118, 2.799644404617912) |
6 | (13.52302122544879, 5.549623631722809, 5.549623631722809) |
7 | (2.222538632722782, 7.602869821226346, 2.222538632722782) |
8 | (3.3007495617180953, 8.126766296265734, 3.3007495617180953) |
... | ... |
9999 | (23.287665393006094, 0.410007076623495, 0.410007076623495) |
xyw.mean()
(9.853554692021284, 20.148862821285917, 6.602680210076662)
;
plt.figure()
10000).plot()
W.sim(
= 1 / 10 + 1 / 20).plot()
Exponential(rate
; plt.show()
> X).sim(10000).tabulate(normalize = True) (Y
Outcome | Relative Frequency |
---|---|
False | 0.339 |
True | 0.661 |
Total | 1.0 |
;
plt.figure()
| (Y > X) ).sim(10000).plot()
(W
| (Y < X) ).sim(10000).plot()
(W
= 1 / 10 + 1 / 20).plot()
Exponential(rate
; plt.show()
Gamma distributions
= RV(Exponential(rate = 2) ** 3)
W1, W2, W3
= W1 + W2 + W3 T
= (W1 & W2 & W3 & T).sim(10000)
sim
sim
Index | Result |
---|---|
0 | (0.4052504524799489, 0.5114739087659492, 0.2816990600116868, 1.198423421257585) |
1 | (0.2845006034749414, 0.784147170615129, 0.06580140653945067, 1.1344491806295212) |
2 | (0.29037566745592863, 0.40689436589149, 1.2309530778525988, 1.9282231112000174) |
3 | (0.3761683472390624, 0.3912870039018704, 1.7872597578528382, 2.554715108993771) |
4 | (0.601298208076717, 0.14219483464185464, 0.503822210308268, 1.2473152530268397) |
5 | (1.3643831264151047, 0.6027998436707337, 0.005046870394153958, 1.9722298404799925) |
6 | (2.131537555459863, 0.8582450938251214, 0.01889120059840637, 3.0086738498833903) |
7 | (0.004463730964075298, 0.12675742084063174, 0.2831797269746502, 0.4144008787793573) |
8 | (0.7406988438093932, 0.17534287199045778, 0.025007696913787885, 0.941049412713639) |
... | ... |
9999 | (0.4468714918036265, 1.2508675378247072, 0.4194708243947566, 2.1172098540230904) |
sim.mean()
(0.4994192595452543, 0.5008799046109623, 0.5030317990526548, 1.5033309632088712)
sim.var()
(0.2519628669400152, 0.25448442216859424, 0.25792731168795424, 0.7653816655218177)
sim.sd()
(0.5019590291448249, 0.5044644904932301, 0.5078654464402498, 0.8748609406767557)
;
plt.figure()
10000).plot()
T.sim(
= 3, rate = 2).plot()
Gamma(shape
; plt.show()