{ "cells": [ { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Coin 1 came up heads 4884 times.\n", "Coin 2 came up heads 2010 times.\n" ] } ], "source": [ "from numpy import random\n", "\n", "rng = random.default_rng() \n", "\n", "ph1 = 0.50\n", "ph2 = 0.20\n", "\n", "nh1 = 0\n", "nh2 = 0\n", "for t in range(10000):\n", " if rng.random() < ph1:\n", " nh1 += 1\n", " if rng.random() < ph2:\n", " nh2 += 1\n", "\n", "print('Coin 1 came up heads',nh1,'times.')\n", "print('Coin 2 came up heads',nh2,'times.')" ] } ], "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.6" } }, "nbformat": 4, "nbformat_minor": 4 }