Clone this repo:
  1. 64e4627 Update OWNERS file by Sadaf Ebrahimi · 11 days ago main master
  2. 0a1cff3 Writing METADATA file for rappor am: 9d7cfa8217 am: 6ceb25daa2 am: 0d07658cd9 by Sadaf Ebrahimi · 1 year, 5 months ago android14-dev android14-qpr1-release android14-qpr1-s2-release android14-qpr2-s1-release aml_hef_341114030 aml_hef_341311010 aml_rkp_341012000 aml_rkp_341015010 aml_rkp_341114000 aml_rkp_341311000 android-14.0.0_r16 android-14.0.0_r17 android-14.0.0_r18 android-14.0.0_r19 android-14.0.0_r20 android-14.0.0_r21 android-14.0.0_r22 android-14.0.0_r23 android-14.0.0_r24 android-14.0.0_r25 android-14.0.0_r26 android-14.0.0_r27 android-14.0.0_r29
  3. 0d07658 Writing METADATA file for rappor am: 9d7cfa8217 am: 6ceb25daa2 by Sadaf Ebrahimi · 1 year, 5 months ago android-u-beta-1-gpl
  4. 6ceb25d Writing METADATA file for rappor am: 9d7cfa8217 by Sadaf Ebrahimi · 1 year, 5 months ago main-16k-with-phones
  5. 9d7cfa8 Writing METADATA file for rappor by Sadaf Ebrahimi · 1 year, 6 months ago


RAPPOR is a novel privacy technology that allows inferring statistics about populations while preserving the privacy of individual users.

This repository contains simulation and analysis code in Python and R.

For a detailed description of the algorithms, see the paper and links below.

Feel free to send feedback to

Running the Demo

Although the Python and R libraries should be portable to any platform, our end-to-end demo has only been tested on Linux.

If you don't have a Linux box handy, you can view the generated output.

To setup your enviroment there are some packages and R dependencies. There is a setup script to install them: $ ./ Then to build the native components run: $ ./ This compiles and tests the fastrand C extension module for Python, which speeds up the simulation.

Finally to run the demo run: $ ./

The demo strings together the Python and R code. It:

  1. Generates simulated input data with different distributions
  2. Runs it through the RAPPOR privacy-preserving reporting mechanisms
  3. Analyzes and plots the aggregated reports against the true input

The output is written to _tmp/regtest/results.html, and can be opened with a browser.


R analysis (analysis/R):

Demo dependencies (

These are necessary if you want to test changes to the code.

Python client (client/python):

  • None. You should be able to just import the file.


  • R: tested on R 3.0.
  • Python: tested on Python 2.7.
  • OS: the shell script tests have been tested on Linux, but may work on Mac/Cygwin. The R and Python code should work on any OS.


To run tests:

$ ./

This currently runs Python unit tests, lints Python source files, and runs R unit tests.

API is a tiny standalone Python file, and you can easily copy it into a Python program.

NOTE: Its interface is subject to change. We are in the demo stage now, but if there's demand, we will document and publish the interface.

The R interface is also subject to change.

The fastrand C module is optional. It‘s likely only useful for simulation of thousands of clients. It doesn’t use cryptographically strong randomness, and thus should not be used in production.

Directory Structure

  R/                 # R code for analysis
  cpp/               # Fast reimplementations of certain analysis
                     #   algorithms
apps/                # Web apps to help you use RAPPOR (using Shiny)
bin/                 # Command line tools for analysis.
client/              # Client libraries
  python/            # Python client library
  cpp/               # C++ client library
doc/                 # Documentation
tests/               # Tools for regression tests
  compare_dist.R     # Test helper for single variable analysis
  gen_true_values.R  # Generate test input    # Generate an HTML report for the regtest      # RAPPOR client simulation    # Specification of test cases
  ...             # Build scripts (docs, C extension, etc.)              # Quick demonstration              # Generate docs form the markdown in doc/
gh-pages/            # Where generated docs go. (A subtree of the branch gh-pages)
pipeline/            # Analysis pipeline code.           # End-to-end regression tests, including client
                     #  libraries and analysis             # Install dependencies (for Linux)              # Test runner




  • Google Blog Post about RAPPOR
  • RAPPOR implementation in Chrome
    • This is a production quality C++ implementation, but it‘s somewhat tied to Chrome, and doesn’t support all privacy parameters (e.g. only a few values of p and q). On the other hand, the code in this repo is not yet production quality, but supports experimentation with different parameters and data sets. Of course, anyone is free to implement RAPPOR independently as well.
  • Mailing list: