Skip to main content

A module that returns True or False output based on given probability

Project description

What is PyProbs?

PyProbs is a module that has useful functionality that returns True or False based on the given probability.

Version Python License

Installation

You can install it from PyPI by running the following command

pip install pyprobs

Or you can manually execute the setup.py from source

python setup.py install

Examples

Simple Usage:

>>> from PyProbs import Probability as pr
>>> # You can pass float (i.e. 0.5, 0.157), int (i.e. 1, 0) or str (i.e. '50%', '3/11')
>>> pr.Prob(50/100)
False
>>> pr.Prob(50/100, num=5)
[False, False, False, True, False]

Suggested and More Advanced Usage:

>>> from PyProbs import Probability as pr
>>> p = pr()
>>> p.iProb('3/7', 0.25, num=2)
[[True, True], [False, False]]

>>> p.history
{'3/7': [True, True], 0.25: [False, False]}
>>> p.count_values('all')
{True: 2, False: 2}

>>> p.set_constant(1/1000, mutable=True)  # If you set the mutable parameter to False, you won't be able to change the constant again.

>>> # You can get the constant and mutable value:
>>> p.get()
{'constant': 0.001, 'mutable': True}
>>> # Also you can use it like "p.get(how='constant')" or "p.get(how='mutable')", this only returns the desired value.

>>> p._constant # You can more easily get the constant value.
0.001

Functions of The Probability Class

  • Prob
  • iProb
  • set_constant
  • get
  • clear
  • count_values

Note: All of them require creating an instance except the Prob function.

Requirements

  • Python v3.x

Documentation

https://pyprobs.readthedocs.io/

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

pyprobs-0.3.tar.gz (6.3 kB view hashes)

Uploaded source

Built Distribution

pyprobs-0.3-py3-none-any.whl (6.8 kB view hashes)

Uploaded py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page