bayesplain.teach.NaturalFrequencies

class bayesplain.teach.NaturalFrequencies(table, n, base_rate, sensitivity, specificity, case_label='cases', condition_label='the condition', flag_label='flagged')[source]

A 2x2 grid of whole counts, and what it implies.

Variables:
table

[[true positive, false negative], [false positive, true negative]] as integers.

n

Total number of imagined cases.

base_rate

The prevalence that was assumed.

sensitivity

The detection rate that was assumed.

specificity

The correct-clearance rate that was assumed.

case_label='cases'

What one row of the imagined data is.

condition_label='the condition'

The thing being detected.

flag_label='flagged'

What the detector does when it fires.

Methods

bayes_rule_check()

Compute the same answer from the formula, for comparison.

summary()

Print the grid and read the answer off it.

base_rate[source]
bayes_rule_check()[source]

Compute the same answer from the formula, for comparison.

Returns:

P(condition | flag) by Bayes’ rule. Agrees with posterior_given_flag up to the rounding needed to keep the grid in whole numbers, which is the point: the counting and the formula are the same operation.

Return type:

float

case_label = 'cases'[source]
condition_label = 'the condition'[source]
property false_negatives[source]

Cases that have the condition and were missed.

property false_positives[source]

Cases that do not have the condition but were flagged anyway.

flag_label = 'flagged'[source]
property flagged[source]

Total number of cases the detector flagged.

n[source]
property posterior_given_flag[source]

Share of flagged cases that actually have the condition.

This is the number the exercise is about, and it is obtained by dividing one count by another – no formula required.

property posterior_given_no_flag[source]

Share of un-flagged cases that have the condition anyway.

sensitivity[source]
specificity[source]
summary()[source]

Print the grid and read the answer off it.

Returns:

Printable text with no probability in the table itself.

Return type:

_Report

table[source]
property true_negatives[source]

Cases that do not have the condition and were correctly cleared.

property true_positives[source]

Cases that have the condition and were flagged.

property with_condition[source]

Total number of cases that actually have the condition.