Skip to content

Instantly share code, notes, and snippets.

@jrhea
Last active February 26, 2020 20:27
Show Gist options
  • Save jrhea/4ed292d721003b4725ac892e4fd5c945 to your computer and use it in GitHub Desktop.
Save jrhea/4ed292d721003b4725ac892e4fd5c945 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 51,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Adversary Power\tProb of Majority\n",
"0.33\t\t1.11e-16\n",
"0.38\t\t2.44e-15\n",
"0.39\t\t4.02e-13\n",
"0.4\t\t4.06e-11\n",
"0.43\t\t2.89e-06\n",
"0.45\t\t5.97e-04\n",
"0.47\t\t2.54e-02\n",
"0.49\t\t2.51e-01\n",
"0.5\t\t4.88e-01\n"
]
}
],
"source": [
"import scipy\n",
"\n",
"p = [0.33,0.38,0.39,0.40,0.43,0.45,0.47,0.49,0.50]\n",
"n = 1024\n",
"x = 512\n",
"result = []\n",
"print(\"Adversary Power\\tProb of Majority\")\n",
"for i in range(9):\n",
" result='{:0.2e}'.format(1-scipy.stats.binom.cdf(x, n, p[i]))\n",
" print(str(p[i])+\"\\t\\t\"+str(result))\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment