Skip to main content

computes ununiform step-increasing probability problems

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distributions

linearly_varying_binomial_distribution-1.0.3-cp38-cp38-win_amd64.whl (17.5 kB view details)

Uploaded CPython 3.8 Windows x86-64

linearly_varying_binomial_distribution-1.0.3-cp37-cp37m-win_amd64.whl (22.0 kB view details)

Uploaded CPython 3.7m Windows x86-64

File details

Details for the file linearly-varying-binomial-distribution-1.0.3.tar.gz.

File metadata

  • Download URL: linearly-varying-binomial-distribution-1.0.3.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for linearly-varying-binomial-distribution-1.0.3.tar.gz
Algorithm Hash digest
SHA256 acc14667ff34e4a169303204588208c9d9880a675882935b8c10a4fde806dca2
MD5 fa1a6bf59f7690b3fa232c30f0232e16
BLAKE2b-256 be720600b4102db808744f5350e3149334414f077ca7594dac2afad9ea96db80

See more details on using hashes here.

File details

Details for the file linearly_varying_binomial_distribution-1.0.3-cp38-cp38-win_amd64.whl.

File metadata

File hashes

Hashes for linearly_varying_binomial_distribution-1.0.3-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 6a837f7dd725548154e5216ccd743b97a713dc5f48860d62104d83b0c3cae6be
MD5 0225cfe01c4ff014bb017d82d68e0d21
BLAKE2b-256 3d30b14a92c66a5e5c035a7464dfe64a6c98fbde72af22370319108123e05611

See more details on using hashes here.

File details

Details for the file linearly_varying_binomial_distribution-1.0.3-cp37-cp37m-win_amd64.whl.

File metadata

File hashes

Hashes for linearly_varying_binomial_distribution-1.0.3-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 0e7fff1071498543a1eebb6e9d69599d5c99095dadf1895d9c625475093a66a7
MD5 7c5ee5c4345a2c511a311099aa6bd556
BLAKE2b-256 169ef5f379c49ea0dc6559dec07a03144f4c1cc9e286fca474bb22ce6a41f79f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page