Giter VIP home page Giter VIP logo

quantum-dice's Introduction

A Quantum Dice: Let's Gamble!

Billions of dollars are at stake! Play now a quantum mechanically enhanced dice to enrich yourself: Roll this brand new kind of a quantum dice - which has been built using Rigetti's Forest API - and beat the odds!

Installation

To install the dependencies run:

pipenv install

To enable the virtual environment run:

pipenv shell

Run: QVM Server

Requires a 64-bit Linux environment:

$ ./bin/forest-sdk-2.0.2/qvm --server
[2018-11-26 12:24:19] Starting server on port 5000.

with the following run-time dependencies:

$ ldd ./bin/forest-sdk-2.0.2/qvm
linux-vdso.so.1 (0x00007ffc05919000)
libdl.so.2=> /usr/lib/libdl.so.2 (0x00007f8aaaea9000)
libpthread.so.0 => /usr/lib/libpthread.so.0 (0x00007f8aaae88000)
libz.so.1 => /usr/lib/libz.so.1 (0x00007f8aaac71000)
libm.so.6 => /usr/lib/libm.so.6 (0x00007f8aaaaec000)
libc.so.6 => /usr/lib/libc.so.6 (0x00007f8aaa928000)
/lib64/ld-linux-x86-64.so.2 => /usr/lib64/ld-linux-x86-64.so.2(0x00007f8aaaed8000)

Run: qdice.py

Simulates 1024 throws of a 8-sided quantum dice, which has been implemented using 3 Hadamard gates: Sampling those gates results in 3 classical bits, which are then togheter interpreted as the binary representation of a single number in the range [1..9].

$ python ./qdice.py --trials=1024 --hadamards=3
#0001:[ 0 1 0 ] => 3;
#0002:[ 1 0 1 ] => 6;
#0003:[ 0 0 0 ] => 1;
#0004:[ 0 0 0 ] => 1;
...
#1021:[ 0 1 1 ] => 4;
#1022:[ 1 1 0 ] => 7;
#1023:[ 0 1 1 ] => 4;
#1024:[ 0 1 0 ] => 3;

The result of the 1024 throws is averaged for each bit and the corresponding number, providing a simple statistics, where the expected distribution is uniform:

μ{⟨H(i)⟩}=[ 0.48 0.52 0.41 ], μ{∑H(i)*2^i}=4.46;
σ{⟨H(i)⟩}=[ 0.50 0.50 0.50 ], σ{∑H(i)*2^i}=4.50.

Run: qcolor.py

Transforms the results of the random throws of a quantum dice into an RGB colored image, where the square root of the number of trials defines the height and width of the square image; hence trials should be a square number. The simulate flag controls whether a regular pseudo-random generator should be used to produce the throws.

$ python ./qcolor.py --trials=65536 [--simulate]

Quantum Image

Copyright

© 2018 Hasan Karahan, https://github.com/hsk81.

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.