maths.joint_probability_distribution

Calculate joint probability distribution https://en.wikipedia.org/wiki/Joint_probability_distribution

Attributes

x_vals

Functions

covariance(→ float)

expectation(→ float)

joint_probability_distribution(→ dict)

standard_deviation(→ float)

variance(→ float)

Module Contents

maths.joint_probability_distribution.covariance(x_values: list[int], y_values: list[int], x_probabilities: list[float], y_probabilities: list[float]) float
>>> covariance([1, 2], [-2, 5, 8], [0.7, 0.3], [0.3, 0.5, 0.2])
-2.7755575615628914e-17
maths.joint_probability_distribution.expectation(values: list, probabilities: list) float
>>> from math import isclose
>>> isclose(expectation([1, 2], [0.7, 0.3]), 1.3)
True
maths.joint_probability_distribution.joint_probability_distribution(x_values: list[int], y_values: list[int], x_probabilities: list[float], y_probabilities: list[float]) dict
>>> joint_distribution =  joint_probability_distribution(
...     [1, 2], [-2, 5, 8], [0.7, 0.3], [0.3, 0.5, 0.2]
... )
>>> from math import isclose
>>> isclose(joint_distribution.pop((1, 8)), 0.14)
True
>>> joint_distribution
{(1, -2): 0.21, (1, 5): 0.35, (2, -2): 0.09, (2, 5): 0.15, (2, 8): 0.06}
maths.joint_probability_distribution.standard_deviation(variance: float) float
>>> standard_deviation(0.21)
0.458257569495584
maths.joint_probability_distribution.variance(values: list[int], probabilities: list[float]) float
>>> from math import isclose
>>> isclose(variance([1,2],[0.7,0.3]), 0.21)
True
maths.joint_probability_distribution.x_vals