Forensic statistics in Python
(832) 422-8646
Contact
I recently had a project in which I had to reverse engineer a data analysis. There was some ambiguity regarding which of several possibilities someone chose for several of the variables, something analogous to the following example.
Suppose you have three numbers with uncertain values with a known, or at least purported, sum. The first number could be 31, 41, or 59; the second could be either 26 or 53; the last could be 58, 97, 93, or 23.
The following code enumerates all 3 × 2 × 4 = 24 possibilities and prints their sums.
from itertools import product
# Example input<br>possibilities = [(31, 41, 59), (26, 53), (58, 97, 93, 23)]
for combo in product(*possibilities):<br>total = sum(combo)<br>print(f"Combination {combo} sums to: {total}")
In this example all the sums are unique, though of course that might not happen in practice. If, for example, you know the sum is 187, you know the three numbers were 41, 53, and 93. If the reported sum is 200, you know some assumption has been violated because none of the possible choices add up to 200.
More forensics posts
Make up your own rules of probability
Identifiable to man or machine?
Metadata in photos
Changing one character in a PDF
Bits of information in age or birthday
Leave a Reply<br>Your email address will not be published. Required fields are marked *<br>Comment *<br>Name *
Email *
Website
Search for:
John D. Cook, PhD
My colleagues and I have decades of consulting experience helping companies solve complex problems involving data privacy, applied math, and statistics.
Let’s talk. We look forward to exploring the opportunity to help your company too.