Created
August 9, 2015 06:36
-
-
Save uncommoncode/1d133259381cc7211efb to your computer and use it in GitHub Desktop.
Randomized Response
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
def randomized_response(true_response): | |
""" | |
Return a randomized response giving plausible deniability to a query about our true response value. This allows us to run | |
queries across a population while preserving individual privacy. | |
Parameters | |
--- | |
true_response : boolean | |
A boolean value that is our true response value. | |
Returns | |
--- | |
boolean | |
A boolean value that is our randomized response value. | |
""" | |
if random.choice([True, False]): | |
return true_response | |
return random.choice([True, False]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment