Randomized response

Differential privacy
Reading time: about 2 minutes

Randomized response is a method of calculating aggregate statistics without compromising individual privacy.

Use cases

  1. Getting honest responses to sensitive questions
  2. Privacy-preserving analytics

Methods

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.

Card method

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.

  1. Say “Yes”.
  2. Say “No”.
  3. 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.

In [2]:
def response_cards(rate):
    choices = [True, False, real_response(rate)]
    
    return random.choice(choices)

Skew

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 [3]:
plot_rate(response_cards, "Cards")
Out:
<Figure size 720x480 with 1 Axes>

De-skewing

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
In [4]:
plot_rate(response_cards, "Cards (corrected)", lambda x: 3*x - 1)
Out:
<Figure size 720x480 with 1 Axes>

Coin method

// TODO: Fill this section
In [5]:
def response_coin(rate):
    if flip_coin():
        return flip_coin()
    else:
        return real_response(rate)
In [6]:
plot_rate(response_coin, "Coin")
Out:
<Figure size 720x480 with 1 Axes>

Skew

f(x) = (3/4)x - (1/4)(1 - x)

De-skewing

f^-1(x) = 2x - 0.5
In [7]:
plot_rate(response_coin, "Coin", lambda x: x * 2 - 0.5)
Out:
<Figure size 720x480 with 1 Axes>

References and useful links

The following pages link here

Citation

If you find this work useful, please cite it as:
@article{yaltirakliwikirandomizedresponse,
  title   = "Randomized response",
  author  = "Yaltirakli, Gokberk",
  journal = "gkbrk.com",
  year    = "2024",
  url     = "https://www.gkbrk.com/wiki/randomized-response/"
}
Not using BibTeX? Click here for more citation styles.
IEEE Citation
Gokberk Yaltirakli, "Randomized response", October, 2024. [Online]. Available: https://www.gkbrk.com/wiki/randomized-response/. [Accessed Oct. 10, 2024].
APA Style
Yaltirakli, G. (2024, October 10). Randomized response. https://www.gkbrk.com/wiki/randomized-response/
Bluebook Style
Gokberk Yaltirakli, Randomized response, GKBRK.COM (Oct. 10, 2024), https://www.gkbrk.com/wiki/randomized-response/

Comments

© 2024 Gokberk Yaltirakli