pyhgf.math.binary_surprise#

pyhgf.math.binary_surprise(x, expected_mean)[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 (float | Array | ndarray | bool | number | bool | int | complex) – The outcome.

  • expected_mean (float | Array | ndarray | bool | number | bool | int | complex) – The mean of the Bernoulli distribution.

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