Randomized response is a method of calculating aggregate statistics without compromising individual privacy.
- Getting honest responses to sensitive questions
- Privacy-preserving analytics
These methods can be used both as algorithms and in-person survey interviews. As such, you can substitute coin flips with random booleans, and picking cards with randomly choosing an option.
For this method, there are three cards. The cards are shuffled and one of them is picked by the subject. The subject then follows the instruction on the card. The cards are as follows.
- Say “Yes”.
- Say “No”.
- Answer the question truthfully.
Since there is a
2/3 chance that the subject doesn’t even answer the question, they cannot be held responsible for their answer even if it is linked back to them.
def response_cards(rate): choices = [True, False, real_response(rate)] return random.choice(choices)
Because each subject has a chance to answer the question randomly, the result is slightly biased. To be precise, the probability is skewed by the following function.
f(x) = (2/3)x + (1/3)(1 - x)
In order to de-skew the result, we need to use the inverse of the previous function. How do you find the inverse? No idea, ask Wolfram Alpha.
f^-1(x) = 3x - 1
plot_rate(response_cards, "Cards (corrected)", lambda x: 3*x - 1)
// TODO: Fill this section
def response_coin(rate): if flip_coin(): return flip_coin() else: return real_response(rate)
f(x) = (3/4)x - (1/4)(1 - x)
f^-1(x) = 2x - 0.5
plot_rate(response_coin, "Coin", lambda x: x * 2 - 0.5)