Giter Club home page Giter Club logo

qrng's Introduction

QRNG - Quantum Random Number Generator

QRNG is a Python module that leverages quantum computing to generate random numbers. This module uses Qiskit to interface with quantum simulators or quantum computers, providing various functions to generate random integers, floats, ASCII characters, and strings.

Note, due to current limitations of quantum, running this module on a real quantum computer will be slower than a classical computer. However, this module is intended to be used for educational purposes, and to demonstrate the potential of quantum computing. For reference, a single random integer between 0 and 100 takes approximately 36 minutes to generate on a real quantum computer due to queue times.

Features

  • Generate random integers within a specified range.
  • Generate random floating-point numbers with specified precision.
  • Generate random ASCII characters and strings.
  • Batch generation for all types of random values.
  • Option to choose between different quantum backends, including simulators and real quantum hardware.

Installation

Make sure you also have Qiskit installed:

pip install qiskit

Usage

Import the QRNG class from the qrng module and create an instance. You can specify the backend used for quantum computations.

Basic Usage

from qrng import QRNG

# Initialize the QRNG instance
instance = QRNG(backend="qasm_simulator")

# Generate a random integer between 0 and 100
random_number = instance.integer_between(0, 100, do_prints=True, do_plots=True)
print("Random number:", random_number)

Batch Generation

# Generate a batch of 100 random integers between 5 and 100
batch = instance.integer_batch(5, 100, 100)
print("Batch:", batch)

Floating-Point Numbers

# Generate a random float between 0.0 and 1.0 with 4 decimal places
random_float = instance.float_between(0.0, 1.0, 4)
print("Random float:", random_float)

ASCII Characters

# Generate a random ASCII character, including uppercase
random_char = instance.ascii_random(include_uppercase=True)
print("Random character:", random_char)

Strings

# Generate a random string of length 3, including uppercase
random_string = instance.string_random(3, include_uppercase=True)
print("Random string:", random_string)

Documentation

For more information, please refer to the documentation.

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT License

qrng's People

Contributors

thekillertoaster 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.