Giter VIP home page Giter VIP logo

coinflip's Introduction

coinflip

This program computes the expected waiting time for all bitstrings of the specified length.

You can adjust SEQ_LEN to accomodate for different lenghts. The theoretical upper bound is determined by your machine's word size. Unless you have 2^64 words of RAM to spare, the actual upper bound may be much lower.

You can increase NUM_ROUNDS to improve precision.

Here's the output for SEQ_LEN = 3 and NUM_ROUNDS = 10000000:

  seq   average waiting time
  --------------------------
  000   14.00
  001   8.00
  010   10.00
  011   8.00
  100   8.00
  101   10.00
  110   8.00
  111   14.00

This means that e.g. when tossing a fair coin, head-tail-tail (011) is most likely to occur after 8 tosses, while head-tail-head (010) is most likely to occur after 10 tosses.

See http://goo.gl/dL7SZg for a theoretical discussion of these results.

coinflip's People

Contributors

vzxwco avatar

Stargazers

 avatar

Watchers

 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.