DolevArtzi / probably-probability

Probability playground to work with and simulate RVs
1 stars 0 forks source link

probably-probability Screenshot 2023-04-17 at 11 57 03 PM

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.

Supported Distributions

Discrete

Continuous

Supported Functionalities

Examples

Basics of Working with Distributions

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)
Screenshot 2023-04-22 at 3 48 35 AM

Random Walks

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)
Screenshot 2023-05-15 at 9 43 31 PM

rw = IntegerLatticeRW(.7)
rw.graphWalks2D(100,50)
Screenshot 2023-05-15 at 9 50 36 PM