A python project for various probability-related explorations. Work with, sample, visualize, combine, compare all your favorite random variables, play poker, or take a random walk on the numberline.
RandomVariable
class with other distributions and/or other conditions of the same distributionplot.py
)]poker
directory for another READMEX = Geometric(0.3)
print(X.pdf(5))
> 0.072029
verbose
to true will print the intermediate derivatives, using the Laplace transform in the case of the Exponential distribution
X = Exponential(.1)
print(X.moment(4,verbose=True)) # should be 4!/(.1^4) = 240000
> 0.1/(x + 0.1)
> -0.1/(x + 0.1)**2
> 0.2/(x + 0.1)**3
> -0.6/(x + 0.1)**4
> 240000.000000000
X = Binomial(100,.5)
print(u.chebyshevs(X,25)) # P[|X - E[X]| >= 25]
> 0.04
P = Plot() P.plot({'binomial':([(20,.3),(20,.5),(20,.7)],20,1)},'pdf')
<img width="813" alt="Screenshot 2023-04-17 at 11 43 37 PM" src="https://user-images.githubusercontent.com/85849407/232665569-ff264196-53b9-43a5-ad0f-434ee1518e45.png">
#### Sampling
* ##### Sample a random instance of the Normal distribution
```python
X = Normal(-10,10)
print(X.genVar())
> -12.483660083014579
util = Util() util.simAll(k=10000)
<img width="813" alt="Screenshot 2023-04-17 at 10 35 53 PM" src="https://user-images.githubusercontent.com/85849407/232655813-d59862ef-ec0c-4e70-a595-a00b7af2459e.png">
* ##### Sample Poisson(10) 10000 times and compare the percentages of outcomes to the pmf graphically
```python
P = Plot()
P.plotSamples(Poisson(10),10000)
rw = NumberLineRW() rw.graphWalks(100,50)
<img width="611" alt="Screenshot 2023-04-30 at 9 03 46 PM" src="https://user-images.githubusercontent.com/85849407/235386663-228a76f9-7b83-4f28-b1e2-5f0ca91532a1.png">
* Visualize simple bounded 2D random walks
```python
rw = IntegerLatticeRW()
rw.graphWalks2D(100,50)
p
as well:
rw = IntegerLatticeRW(.7)
rw.graphWalks2D(100,50)