pyhgf.math.binary_surprise#
- pyhgf.math.binary_surprise(x, expected_mean, clipping=True)[source]#
Surprise at a binary outcome.
The surprise elicited by a binary observation \(x\) under the expected probability \(\hat{\mu}\) is given by:
\[\begin{split}\begin{cases} -\log(\hat{\mu}),& \text{if } x=1\\ -\log(1 - \hat{\mu}), & \text{if } x=0\\ \end{cases}\end{split}\]- Parameters:
x (Array | ndarray | bool | number | bool | int | float | complex) – The outcome.
expected_mean (Array | ndarray | bool | number | bool | int | float | complex) – The mean of the Bernoulli distribution.
clipping (bool) – If True (default), the expected mean is clipped in a reasonable range to avoid numerical instabilities.
- Returns:
The binary surprise.
- Return type:
surprise
Examples
>>> from pyhgf.binary import binary_surprise >>> binary_surprise(x=1.0, expected_mean=0.7) `Array(0.35667497, dtype=float32, weak_type=True)`