Skip to content

Instantly share code, notes, and snippets.

@tomkooij
Created March 15, 2015 18:44
Show Gist options
  • Save tomkooij/a5a5ea58e2adf60f25bb to your computer and use it in GitHub Desktop.
Save tomkooij/a5a5ea58e2adf60f25bb to your computer and use it in GitHub Desktop.
Monte carlo Pi ipython notebook
Display the source blob
Display the rendered blob
Raw
{
"metadata": {
"name": "",
"signature": "sha256:a2ef372cc633ecf9022ddee3e566a0d7e6dcf1d9cd635f35cd7d1a7378ffcde6"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
"cell_type": "code",
"collapsed": false,
"input": [
"import numpy as np\n",
"\n",
"x,y = np.random.rand(2, 1e6)\n",
"\n",
"print \"Happy %1.2f day!\" % (4.*np.average((x**2 + y**2) < 1.))"
],
"language": "python",
"metadata": {},
"outputs": []
},
{
"cell_type": "code",
"collapsed": false,
"input": [],
"language": "python",
"metadata": {},
"outputs": []
}
],
"metadata": {}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment