# Beta¶

Beta distribution for binary data.

A Beta distribution is very similar to a Bernoulli distribution in that it counts occurrences of boolean events. The differences lies in what is being measured. A Binomial distribution models the probability of an event occurring, whereas a Beta distribution models the probability distribution itself. In other words, it's a probability distribution over probability distributions.

## Parameters¶

• alpha

Typeint

Default1

Initial alpha parameter.

• beta

Typeint

Default1

Initial beta parameter.

• seed

Typeint | None

DefaultNone

Random number generator seed for reproducibility.

## Attributes¶

• mode

The most likely value in the distribution.

• n_samples

The number of observed samples.

## Examples¶

from river import proba

successes = 81
failures = 219
beta = proba.Beta(successes, failures)

beta(.21), beta(.35)

(0.867..., 0.165...)


for success in range(100):
beta = beta.update(True)
for failure in range(200):
beta = beta.update(False)

beta(.21), beta(.35)

(2.525...e-05, 0.841...)


## Methods¶

call

Probability mass/density function.

Parameters

• p'float'

cdf

Cumulative density function, i.e. P(X <= x).

Parameters

• x'float'

revert

Reverts the parameters of the distribution for a given observation.

Parameters

• x'float'

sample

Sample a random value from the distribution.

update

Updates the parameters of the distribution given a new observation.

Parameters

• x'float'