Skip to content

Overview

CI pypi Downloads versions license

Caution: under development

Hall is currently under development and is prone to interface changes. The documentation is currently incomplete, but will be coming soon.

Hall is a lightweight library with pythonic syntax. Some features include:

  • Clean, pythonic syntax that closely resembles mathematical notation in probability theory.
  • Symbolic algebra and bayesian statistics with random variables.
  • Calculations are numerically precise, with arbitrairy precision.
  • Lightweight; it only requires mpmath.
  • Fully type-annotated and mypy friendly
  • Thoroughly tested.

Example

>>> from hall import P, E, Std, Normal, sample
>>> IQ = ~Normal() * 100 + 15
>>> E[IQ]
100.0
>>> Std[IQ]
15.0
>>> P(IQ >= 130)
0.0227501319481792
>>> print("IQ test outcome:", sample(IQ))
IQ test outcome: 116.309834872963

So the chance of having an IQ (normally distributed with μ=100 and σ=15) of at least 130 is approximately 2.3%.

What's going on here:

  • IQ is a random variable with the normal distribution, scaled to have a mean of 100 and standard deviation of 15, i.e., \( \mathrm{IQ} \sim \mathcal N(100, 15^2) \).
  • We verify this using the operators for the expectancy \( \operatorname E[\cdot] \), and standard deviation \( \operatorname{Std}[\cdot] \).
  • Next, we obtain the probability of someone having an IQ of at least 130, \( \operatorname P (\mathrm{IQ} \ge 130) \).
  • Finally, we draw a sample from the random variable with the hall.sample function.

Rationale

Coming soon