Giter VIP home page Giter VIP logo

randomness-extractors's Introduction

Randomness Extractors

Build Status

Extract (hopefully) almost uniform random bit from source(s) of biased and correlated bits.

Install

npm install --save randomness-extractors

Extractors

Von Neumann's Extractor

Reference: J. Von Neumann, “Various techniques used in connection with random digits,” Applied Math Series, Notes by G. E. Forsythe, in National Bureau of Standards, Vol. 12, pp. 36-38, 1951.

var Extractors = require('randomness-extractors');

var source = [0, 0, 1, 0, 1, 1, 0, 1];
Extractors.vonNeumannsExtractor([source]); // '10'

Inner Product Extractor

Reference: https://people.eecs.berkeley.edu/~vazirani/pubs/2com.pdf

You could do inner product of the two sources in GF(2) to extract a random bit. Optionally, you could also perform the inner product in GF(2^n), 1 <= n <= 13, to obtain n random bits.

var Extractors = require('randomness-extractors');
Extractors.innerProductExtractor([[0, 0, 0, 1, 1], [1, 1, 1, 1, 0]]) // '0';

var source1 = [0, 0, 1, 0, 1, 1, 0, 0];
var source2 = [1, 0, 1, 1, 0, 1, 1, 0];

var n = 3; // inner-product of GF(2^3)
Extractors.innerProductExtractor([source1, source2], n) // '001'

Browser usage

You can get the extractors by including the dist/out.js.

...

<script src="node_modules/randomness-extractors/dist/out.js"></script>
<script>
Extractors.innerProductExtractor([0, 0, 0, 1, 1], [1, 1, 1, 1, 0]) // '0';
</script>

...

Or you could use browsify/webpack to require the package.

Test

npm test

randomness-extractors's People

Contributors

ycmjason avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.