Last active
June 22, 2021 20:52
-
-
Save Quantalabs/03c70fb5fb9b5d0e87e05aaa1ba587cd to your computer and use it in GitHub Desktop.
Simple differential privacy algorithm
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
var flip = function (dataArray) { | |
var a = dataArray; | |
for(var i = 0; i < a.length; i++) { | |
var b = Math.random(0,1); | |
var c = Math.round(b); | |
if(c === 0) { | |
a[i] = true; | |
} | |
if(c === 1) { | |
var b1 = Math.random(0,1); | |
var c1 = Math.round(b1); | |
if(c1 === 0) { | |
a[i] = true; | |
} | |
if(c1 === 1) { | |
a[i] = false; | |
} | |
} | |
} | |
dataArray = a; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment