pyhgf.math.binary_surprise#

pyhgf.math.binary_surprise(x: float | Array | ndarray | bool_ | number | bool | int | complex, expected_mean: float | Array | ndarray | bool_ | number | bool | int | complex) Array | ndarray | bool_ | number | bool | int | float | complex[source]#

Surprise at a binary outcome.

The surprise ellicited 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

The outcome.

expected_mean

The mean of the Bernoulli distribution.

Returns:
surprise

The binary 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)`