Welcome to the Interactive Probability and Statistics Application (IPSA)

This application is used for understanding the probabilistic and statistical concepts used in evaluating evidence in forensic science.

The application uses interactive examples so that you can explore how different values and assumptions can affect probabilistic and statistical conclusions.

On the tab to the left of the application you can find the different examples. Within each tab there are some sub-tabs, which demonstrate different ideas using similar scenarios.

You can use any example in any order that you prefer, but if you are unsure where to begin then start with the top one and work your way down the list of tabs.

If you would like to learn more about the ideas introduced here then you can read about them in our interactive probability and statistics book.

We hope that you enjoy learning using this app.

Development information

This application was developed by Mr Roy Mudie (Application Specialist) and Dr Harry Gray (Harding Fellow) at the Leverhulme Research Centre for Forensic Science (LRCFS). The principal investigator for this project is Professor Niamh Nic Daéid.

Single Coin Toss - Samples

In this example we consider both the expected outcomes of the coin toss as well as actual outcomes of the tosses.

When we assign a probability of a coin toss resulting in a head, we have an expectation for the number of heads that will be acheived for a certain number of tosses. However, this number of heads is not guaranteed to occur when the coin is actually tossed.

When the coin is tossed a number of times and the results are recorded then this is known as a sample.

Use the sliders below to change the number of tosses and the probability of heads for the coin to generate a sample of tosses and view the results in the graphs below.

The outcomes for the sample have been added to a new tree diagram which represents the sample number (also known as the sample frequency) of heads and tails.

Try it

Try the following activities, you can see the answers at the bottom of the page.

  1. Set the number of tosses to around 50 and the probability of heads to be 0.5. Compare the expected number of heads/tails to the sample number of heads/tails. Why are these numbers different?
  2. Now set the number of tosses to 500. Look at the graph which shows the sample proportion of heads/tails with each toss. Can you tell how the sample proportion of heads is calculated?
  3. Look at the graph which shows the sample proportion of heads/tails with each toss again. What happens to the lines on the graph between 1-100 tosses compared to the lines on the graph between 400-500 tosses?
  4. Repeat activity 2 above for a probability of heads of 0.8. Can you tell why you view this behaviour for the lines between tosses 0-100 compared to tosses 400-500?

Number of tosses and probability of heads

Probability Tree

This tree displays the probability for each outcome.

Expected Frequency Tree

This tree displays the expected frequency of each outcome for a certain number of tosses.

Sample Frequency Tree

This tree displays the sample frequency of each outcome for a certain number of tosses.

Coin Tosses

This plot shows the outcomes of each coin toss in the order in which they occurred.

Sample proportion of heads/tails with each coin toss

This plot shows the sample proportion of heads/tails and how it changed as the coin was being tossed.

Total Number of Heads/Tails

This plot shows the total number of heads and tails in the sample.

Distribution of the sample proportion of Heads

Use the buttons below to re-run the sample of coin tosses. This plot displays the sample proportion of heads for each sample together in what is known as a box plot.

The line through the centre of the box shows the median proportion of heads for the samples. This is the value for which half of the samples had a higher sample proportion of heads, and half of the samples had a lower sample proportion of heads.

The size of the box shows the central 50% of sample proportions for the samples - one quarter of the sample values are above the box, and one quarter are below the box.

Any dots outside of the box are known as outliers - values which are extreme compared to the other sample proportions that were observed.

The lines between the boxes and the outliers are known as whiskers and they show the range of values that are not considered to be outliers.

Try it: answers

  1. These numbers are different because the expectations from a theoretical probability model cannot determine precise outcomes from the real-world process that they attempt to model (in this case, coin toss outcomes).
  2. The sample proportion of heads is calculated by dividing the sample number of heads by the total number of tosses.
  3. The lines between 0-100 tosses vary greatly, whilst the lines from 400-500 tosses are more stable.
  4. This behaviour occurs because for smaller sample sizes, the sample proportion of heads can be greatly affected by small random sequences of many heads or many tails (and you can see how many of these sequences occur in the Coin Tosses visualisation graph). Over many samples, the sample proportion of heads is less affected by small sequences of many heads or many tails. As a result, for larger sample sizes the sample proportion of heads is more stable and gets closer to the probability of heads.

Single Coin Toss - Probabilities

In this example we use a coin toss to introduce the idea of probability. Probability here means a degree of belief in an event occurring.

For a standard double-sided coin, each coin tosses can result in either head or tail. The probability of getting a head means the degree of belief that a coin toss will result in a head.

Probabilities represent this degree of belief as a number between 0 and 1. A probability of 1 reflects a belief that the coin is guaranteed to result in a head. A probability of 0 reflects the belief that the coin will never result in a head, i.e. that it is guaranteed to be tails.

A probability of 0.5, which is the mid-point of 0 and 1, represents the belief that heads and tails are equally likely results of the coin toss. The closer to 1 the probability of heads is, the stronger the belief that the coin will result in a head. The closer the probability of heads is to 0, the stronger the belief that the coin toss will result in a tail.

The slider on the right-hand side of the panel below controls the probability of getting a head for the coin toss in this example.

The slider on the left-hand side of the panel below controls the number of tosses to consider.

Try it

Use the sliders to see how different combinations of tosses and probabilities of heads affect the expected number of heads shown on the tree diagrams. Notice how the probability of heads reflects the proportion of heads that we expect to occur, e.g. for a probability of 0.5 and a total number of tosses of 100, we expect 50 of the 100 tosses to be heads, and the other 50 to be tails.

Try the following activities, you can see the answers at the bottom of the page.

  1. How many head are expected from 350 tosses with a probability of heads of 0.3?
  2. If I expect 90 heads out of 150 tosses, what is my probability of heads for the coin?
  3. Can you tell how the expected number of heads and tails are calculated? Hint: the calculations use the number of tosses and the probability of heads.

Number of tosses and probability of heads

Probability Tree

This tree displays the probability for each outcome.

Expected Frequency Tree

This tree displays the expected frequency of each outcome for a certain number of tosses.

Try it: answers

  1. 105. Move the sliders to the correct positions and read the expected number of heads.
  2. 0.6. Fix the number of tosses to the correct amount and adjust the probability of heads until you see the required number of heads.
  3. The expected number of heads is calculated by multiplying the number of tosses by the probability of heads. The expected number of tails is calculated by multipling the number of tosses by the probability of tails, which is 1 minus the probability of heads.

Double Coin Toss - Samples

In this example we consider the expected outcomes and the sample frequencies from a double coin toss. Please see the 'Double Toss Probabilities' tab if you need a recap of this example.

A 'sample' for the double coin tosses consists of tossing coin 1 followed by coin 2 and then repeating this. For example, a possible outcome for a sample of size 2 could be heads/heads, heads/tails.

As with the single coin toss samples, the double coin toss samples are almost guaranteed to be different from the expectations of a probability model.

Use the sliders below to change the number of double tosses and the probability of heads for the coins to generate a sample of double tosses and view the results in the graphs below.

Number of double coin tosses and probability of heads

Probability Tree

This tree displays the probability for each outcome.

Expected Frequency Tree

This tree displays the expected frequency of each outcome for a certain number of double tosses.

Sample Frequency Tree

This tree displays the sample frequency of each outcome for a certain number of double tosses.

Visualisation of Tosses

This plot shows the outcomes of the coin tosses for each coin and the order in which they occurred.

Tosses of Coin 1

Coin 1 Heads

Coin 1 Tails

Tosses of Coin 2 after coin 1 heads

Tosses of Coin 2 after coin 1 tails

Coin 2 Heads after Coin 1 Heads

Coin 2 Tails after Coin 1 Heads

Coin 2 Heads after Coin 1 Tails

Coin 2 Tails after Coin 1 Tails

Sample proportion of outcomes with each double toss

This plot shows the sample proportion of each outcome and how it changed as the coins were being tossed.

Double Coin Toss - Probabilities

In this example we use a double coin toss to introduce joint probabilities.

In the previous example using a single coin toss, we introduced probability as a degree of belief on a scale from 0 to 1 and saw how it could be applied to calculate the expected number of heads. In this example, we will toss two coins and see how probabilities can be used to calculate expected outcomes of both tosses.

Suppose that we now have two double sided coins, coin 1 and coin 2, each of which has the same probability of resulting in heads. First we toss coin 1 and view the result and then we toss coin 2. The possible outcomes of coin 1/coin 2 are heads/heads, heads/tails, tails/heads, heads/heads. The probabilities for these outcomes are called joint probabilities.

Joint probabilities describe the probability of multiple events occurring together. In this example the joint probabilities of interest are the outcome of coin 1 and coin 2.

The right-hand slider in the panel below controls the probability of heads, which is the same for both coins. The slider on the left represents the number of times we toss both coins, e.g. 200 tosses means that we toss coin 1 and coin 2 and repeat this 200 times.

Try it

Try the following activities, you can see the answers at the bottom of the page.

  1. Fix the slider at 400 tosses with probability of heads of 0.5. What is the probability of a double tails? This is the joint probability of two tails.
  2. Change the probability of heads to 0.2. What is the joint probability of double tails now?
  3. How is joint probability of a double tails calculated?
  4. Are the joint probabilities for double heads and heads/tails calculated in the same way? Do you know what statistical property this shows?

Number of double coin tosses and probability of heads

Probability Tree

This tree displays the probability for each outcome.

Expected Frequency Tree

This tree displays the expected frequency of each outcome for a certain number of double tosses.

Try it: answers

  1. 0.25. This can be seen by reading the value for Tails/Tails from the probability tree.
  2. 0.64. This can be seen by reading the value for Tails/Tails from the probability tree.
  3. It is calculated by multiplying the probability of tails by itself. You can check this using a calculator.
  4. Yes, they are calculated in the same way - by multiplying the probbailities of each outcome together. This property is known as statistical independence.

Disease Testing Example

In this example we will explore something called the base rate and how that can affect the results of a disease test. The base rate describes the background occurrence of something within a population.

For diseases, the base rate describes the proportion of the population who have the disease.

When we test people for the disease, we do not know whether they have the disease or not and we are using the test to try to help us determine that.

However, every test makes mistakes, and so the result of the test is not guaranteed to be correct.

Two important features of a diagnostic test are the sensitivity and specificity, and these are explained in the information box below.

Change the base rate of the disease using the slider below and see how that affects the number of mistakes the test makes for a population of 10,000 people.

Try it

In the box below you can control the base rate of the disease. You can see the effects of the changes in the tree diagram below.

Try the following activities, you can see the answers at the bottom of the page.

  1. What is the number of incorrect positive test results when the base rate is 0.05? These are also known as false positives.
  2. Increase the base rate from 0.05 to 0.95. How does the number of false positives change?
  3. What does the above result mean for testing everybody for a rare disease?

Disease and Test Information


Test sensitivity: 0.95

The sensitivity of the disease test is the probability that it returns a positive test result when the tested person has the disease.

A test sensitivity of 0.95 means that out of 100 diseased individuals, 95 correctly test positive.

Test specificity: 0.95

The specificity of the disease test is the probability that it returns a negative test result when the tested person is disease-free.

A test specificity of 0.95 means that out of 100 disease-free individuals, 95 correctly test negative.

Disease and test results

This tree shows the test results for a population of people for the base rate and test details given in the box opposite.

Try it: answers

  1. 475. This can be read from the expected frequency tree as the number of people of test positive despite not having the disease.
  2. The number of false positives decreases from 475 to 25 as the base rate increases from 0.05 to 0.95.
  3. This means that there will be a large number of false positives.

Doping Test Example with Probabilities

In this example we will explore the effectiveness of tests and how that affects drugs testing results.

There are athletes who are doping in order to improve their performance. A test has been developed to try to detect whether an athlete is doping or not. The test can return positive or negative for doping, but there is always uncertainty about its results.

The sensitivity of a test is the probability that it returns a positive test result when the athlete is truly doping. This a conditional probability, since it is conditional on the athlete doping.

The specificity of a test is the probability that the test returns a negative result when the athlete is truly not doping. This is a probability that is conditioned on the athlete not doping.

Change the sensitivity and specificity of the test using the slider below and see how that affects the number of mistakes the test makes for a population of 10,000 athletes.

Try it

Below you can control the sensitivity and specificity of the doping test. You can see the effects of the changes in the tree diagram below.

Try the following activities, you can see the answers at the bottom of the page.

  1. What is the number of incorrect negative test results when the sensitivity is 0.99? These are also known as false negatives.
  2. Decrease the sensitivity from 0.99 gradually. How does the number of false negatives change? Which side of the tree diagram is affected?
  3. Set the specificity to 0.99 and decrease it gradually. How does the number of false positives change? Which side of the tree diagram is affected?
  4. Use the above results to decide whether a high sensitivity alone is enough to control the number of false results the test makes.

Doping Test Properties

In this box you can control the sensitivity and specificity of the test. You can see the effects of the changes that you make in the text description and tree diagram below.

One way to understand the effects of the sensitivity or specificity is to change only one of the sliders at a time and see how that affects the results. For example, which side of the tree diagram does the sensitivity value affect? What does this mean for the number of true positive test results?

A test sensitivity of 0.95 means that out of 100 doping athletes, 95 test positive.
A test specificity of 0.95 means that out of 100 non-doping athletes, 95 test negative.

Text description of results

Doping status and test results

Try it: answers

  1. 2. This can be seen by setting the sensitivity to the correct number and seeing the number of negative test results returned to athletes who are doping.
  2. The number of false negatives increases as the sensitivity decreases. This affects the left-hand side of the tree, which shows the doping athletes.
  3. The number of false positives increases as the specificity decreases. This affects the right-hand side of the tree, which shows the non-doping athletes.
  4. High sensitivity alone is not enough to control the number of false results, since it does not affect the number of false positives. Both a high sensitivity and a high specificity are required. The base rate also has an effect and this is shown in the Disease Test example.

Doping Testing Example with Likelihood Ratio

This example continues on from the previous doping test example. Athletes are doping and a test is used to try to detect them.

In this example we will see how the base rate of doping and the sensitivity and specificity of the test affect the key components of Bayes' rule: the prior odds, the likelihood ratio, and the posterior odds.

Bayes' rule is a rule of probability that determines how to update beliefs based upon learning new information. In this example, the belief is about whether an athlete is doping or not and the new information which updates that belief is the result of the doping test.

The belief before learning the test result can be expressed as prior odds: the relative size of the probability that the athlete is doping compared to not doping.

The belief after learning the test result can be expressed as posterior odds: the relative size of the probability that the athlete is doping compared to not doping conditional on the result of the test.

The update factor which converts the prior odds to the posterior odds is controlled by the effectiveness of the test and is known as the likelihood ratio (LR). The LR compares the probabilities of obtaining the observed test result conditioned on the athlete doping versus the same probability conditioned on them not doping.

Since the effectiveness of the test is determined by its sensitivity and specificity, this means that these test properties have an effect on both the LR and the posterior odds.

Change the sensitivity and specificity of the test using the slider below and see how that affects the components of Bayes' rule in this population of 10,000 athletes. There is a text description to help explain the mathematical calculations.

Try it

Below you can control the sensitivity and specificity of the doping test. You can see the effects of the changes in the calculations below.

Try the following activities, you can see the answers at the bottom of the page.

  1. Read through the calculations and descriptions below for the prior odds. In this example, is doping rare or common?
  2. Set both the sensitivity and specificity of the doping test to 0.9 and read through the calculations and description of the LR. What is the value of the LR? What does this value mean?
  3. Keep the same sensitivity and specificity above and read through the calculations and description for the posterior odds. What is the value? What does this mean for a randomly selected athlete who tests positive?
  4. What do the above two steps highlight about the interpretation of the LR?
  5. See if you can find values for the sensitivity and specificity which result in posterior odds that are greater than 1. Why is this important?

Doping Test Properties

In this box you can control the sensitivity and specificity of the test. You can see the effects of the changes that you make in the text description and calculations below.

A test sensitivity of 0.95 means that out of 100 doping athletes, 95 test positive.
A test specificity of 0.95 means that out of 100 non-doping athletes, 95 test negative.

Prior Odds

The box opposite contains the calculations for the prior odds in this doping example. The probability that any randomly selected athlete is doping is determined by the base rate, 0.02. Since athletes are either doping or not doping and cannot be doing both then these probabilities are exhaustive and mutually exclusive and so must sum to 1. This makes the probability that a randomly selected athlete is not doping equal to 0.98.

The prior odds compares the size of these two probabilities, giving odds of roughly 0.02. This can be interpreted as any randomly selected athlete is 0.02 times as likely to be doping as not doping. In other words, they are far less likely to be doping and much more likely to not be doping when randomly selected.

Prior Odds Calculation

Likelihood Ratio

Likelihood Ratio Calculation

Posterior Odds

Posterior Odds Calculation

Try it: answers

  1. The base rate is 0.02, implying prior odds of 0.0204. This means that a randomly selected athlete is 0.0204 times as probable to be doping compared to not doping. This means that doping is rare.
  2. The LR is 9. This means that a positive test is 9 times as probable when an athlete is doping compared to when they are not doping.
  3. The posterior odds are 0.1837. This means that a randomly selected athlete who tests positive is 0.1837 times as likely to be doping compared to not be doping. Since this number is less than 1, the athlete is more likely to not be doping.
  4. In the steps above, an LR above 1 still resulted in posterior odds less than 1 (due to doping being rare). This shows that LRs needs to be carefully considered and not mistakenly confused with posterior odds.
  5. Posterior odds greater than 1 are important because this is the value at which an athlete who tests positive is more likely to be doping than not doping.

Likelihood Ratio (LR) in forensic science

In this example we demonstrate how the LR is calculated based upon its underlying conditional probabilities.

In forensic science, the LR is a quantitative tool to determine the value of a piece of evidence in discriminating between the prosecution's and defence's version of events.

The LR applied to forensic science depends upon three key elements:

  • \(E\): evidence,
  • \(H_p\): prosecution hypothesis for the evidence,
  • \(H_d\): defence hypothesis for the evidence.

The LR compares the magnitude of the probability of \(E\) conditioned on \(H_p\) with the probability of \(E\) conditioned on \(H_d\).

If the probability of \(E\) conditioned on \(H_p\) is two times as large as the probability of \(E\) conditioned on \(H_d\), say 0.5 compared to 0.25, then the LR is 2.

If the probability of \(E\) conditioned on \(H_p\) is only one quarter the size of the probability of \(E\) conditioned on \(H_d\), say 0.1 compared to 0.4, then the LR is 0.25.

The LR determines how much more likely the recovered evidence was assuming the prosecution hypothesis to be true compared to when the defence hypothesis is true.

Fix each of the conditional probabilities in the calculator below to see the resulting LR.

Values for these terms can also be greater than 1, and this is because the conditional probabilities are technically 'likelihoods'. The technical details of this are beyond the scope of this application, the key point is that the LR is the ratio of two non-negative values.

LR calculator

Enter values for the conditional probabilities below. You may try values greater than 1 to test more general likelihoods. You can also see the mathematical expression for computing the LR.