Git Product home page Git Product logo

pi_calculation's Introduction

Calculating π

The code in this repository estimates the value of π by a Monte Carlo process described below.

We will use it as an example to measure, and later improve, the performance of Python code.

How to run

You can run the code with python calc_pi.py.

There are some options you can customise. See the help message (python calc_pi.py --help) or look at the code to see what those are.

How it works

In this approach, π is approximated in 3 steps:

  • sampling n random points inside a square with side length 1,
  • counting the number of those points that fall inside a circle,
  • and multiplying that by 4/n

(Why this works is not particularly important for our purposes, but you may find it interesting to figure it out for yourself)

pi_calculation's People

Contributors

ageorgou avatar

Watchers

Alessandro Felder 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.