Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cleoold/linearly_varying_binomial_distribution_calcs_python
a "binomial" distribution with linearly increasing chance.
https://github.com/cleoold/linearly_varying_binomial_distribution_calcs_python
probability python-c-extension statistics
Last synced: about 2 months ago
JSON representation
a "binomial" distribution with linearly increasing chance.
- Host: GitHub
- URL: https://github.com/cleoold/linearly_varying_binomial_distribution_calcs_python
- Owner: cleoold
- License: mit
- Created: 2020-02-29T06:49:42.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-05-10T19:27:08.000Z (over 4 years ago)
- Last Synced: 2024-11-18T09:12:29.052Z (about 2 months ago)
- Topics: probability, python-c-extension, statistics
- Language: Python
- Homepage: https://pypi.org/project/linearly-varying-binomial-distribution/
- Size: 23.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# linearly varying_binomial distribution calculations
```
pip install linearly-varying-binomial-distribution
```This is a wrapper module for the previous repo: [C PROGRAM](https://github.com/cleoold/linearly_varying_binomial_distribution_calcs)
### Description of the math
Imagine the cardpool of a ptw game looks like:
One can flip a card. there is a probability (here say 0.02) to have a prize at the beginning.
* If one does not have the prize for 50 attempts in a row, the constant (here say 0.02) will be added to the existing probability (so that the chance of having the prize is increasing) until one finally has the prize, at which point the chance will reset to the original one.For example, one tried 52 times and there have been no successes. At this point their chance for success for the 53rd time will be 0.08. If the 53-rd try is a success, then the chance for the 54-th try will be reset to 0.02, otherwise the chance becomes 0.10. Also the maximum number of tries allowed here is calculated 99, where the chance is 1.
If he tries 60 times, we can calculate the chance of getting the prize with the following code:
```py
from lvbdist import LVBdistribution
x = LVBdistribution(
0.02, # the starting probability
0.02, # the constant to add
50 # numbr of failures before triggering the addition
)
x.have_success_within_n_attempts(60) # 0.911490```
How about the probability they just get the prize at the 60th turn
```py
x.have_first_success_at_n(60) # 0.024964
```We can calculate the average number of attempts they need to make to have the prize:
```py
x.have_first_success_at_n_E() # 34.59455
```We can also calculate the average successes in 60 attempts:
```py
x.have_m_successes_within_n_attempts_E(60) # 1.443428
```Function names are self-descriptive. Note that functions ending with `_E` are expectated values. There always exist a function without the `_E` suffix.
Refer to [the lazily generated doc](https://cleoold.github.io/linearly_varying_binomial_distribution_calcs_Python/doc/) for all functions.
### Building
Requirements: setuptools, and any modern C compiler shall work
Clone the repository:
```bash
git clone --recurse-submodules https://github.com/cleoold/linearly_varying_binomial_distribution_calcs_Python
```You can install the package by running
```bash
make install
```#### Developing
(Optional) set up a virtual env
```bash
python3 -m venv . # pyvenv .
source bin/activate
```build the package in-place in the `lvbdist` folder by running
```bash
make debugging
```
And then build the distributable:
```bash
bin/pip3 install wheel
make release
```