Statistics & probability

Bernoulli KL divergence calculator

Measure the average log-loss penalty of using a reference model for a binary event.

Your numbers

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

Measure the average log-loss penalty of using a reference model for a binary event.

THE FORMULAD(p∥q)=p ln(p/q)+(1−p)ln((1−p)/(1−q))

A worked example

A fair coin measured against q=0.25 gives about 0.144 nats.

Good to know

Changing which model is the reference can change the answer.

Read the result

Measure the average log-loss penalty of using a reference model for a binary event.

The primary result is labeled “Divergence (nats)”. Keep the input definitions in view when comparing this result with another method.

Try a related calculation

Changing which model is the reference can change the answer.

For a related exercise, try the statistics calculator.

A few questions, answered

How can I check the default inputs by hand?

A fair coin measured against q=0.25 gives about 0.144 nats.

Which rule does this calculator apply?

D(p∥q)=p ln(p/q)+(1−p)ln((1−p)/(1−q))

Find your calculator

Start typing to explore the library.