Skip to main content

linearly varying_binomial distribution calculations

pip install linearly-varying-binomial-distribution

This is a wrapper module for the previous repo: C PROGRAM

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:

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

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:

x.have_first_success_at_n_E() # 34.59455

We can also calculate the average successes in 60 attempts:

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 for all functions.

Building

Requirements: setuptools, and any modern C compiler shall work

Clone the repository:

git clone --recurse-submodules https://github.com/cleoold/linearly_varying_binomial_distribution_calcs_Python

You can install the package by running

make install

Developing

(Optional) set up a virtual env

python3 -m venv . # pyvenv .
source bin/activate

build the package in-place in the lvbdist folder by running

make debugging

And then build the distributable:

bin/pip3 install wheel
make release

Metadata

Release files for linearly-varying-binomial-distribution 1.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for linearly-varying-binomial-distribution 1.0.3
File Size Uploaded
linearly-varying-binomial-distribution-1.0.3.tar.gz 8.3 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for linearly-varying-binomial-distribution 1.0.3
File Interpreter ABI Platform
linearly_varying_binomial_distribution-1.0.3-cp38-cp38-win_amd64.whl CPython 3.8 CPython 3.8 Windows x86-64 Details
linearly_varying_binomial_distribution-1.0.3-cp37-cp37m-win_amd64.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-64 Details

Total release size: 47.9 kB

Release files / linearly-varying-binomial-distribution-1.0.3.tar.gz

Download URL linearly-varying-binomial-distribution-1.0.3.tar.gz
Size 8.3 kB
Tags Source
SHA-256 checksum
How to use checksums
acc14667ff34e4a169303204588208c9d9880a675882935b8c10a4fde806dca2
BLAKE2b-256 checksum
How to use checksums
be720600b4102db808744f5350e3149334414f077ca7594dac2afad9ea96db80
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.9

Release files / linearly_varying_binomial_distribution-1.0.3-cp38-cp38-win_amd64.whl

Download URL linearly_varying_binomial_distribution-1.0.3-cp38-cp38-win_amd64.whl
Size 17.5 kB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
6a837f7dd725548154e5216ccd743b97a713dc5f48860d62104d83b0c3cae6be
BLAKE2b-256 checksum
How to use checksums
3d30b14a92c66a5e5c035a7464dfe64a6c98fbde72af22370319108123e05611
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.9

Release files / linearly_varying_binomial_distribution-1.0.3-cp37-cp37m-win_amd64.whl

Download URL linearly_varying_binomial_distribution-1.0.3-cp37-cp37m-win_amd64.whl
Size 22.0 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
0e7fff1071498543a1eebb6e9d69599d5c99095dadf1895d9c625475093a66a7
BLAKE2b-256 checksum
How to use checksums
169ef5f379c49ea0dc6559dec07a03144f4c1cc9e286fca474bb22ce6a41f79f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.6.9

Release history Release notifications | RSS feed

This release

1.0.3 This release

3 release files

1.0.2

4 release files

1.0.1

3 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page