Skip to main content

"Random" numbers based in pi's decimals

Project description

PiRan: Random numbers based on Pi

1. Disclaimer and license

Disclaimer

I use the word "random" for the data generated by this library. Thought, all of this is mathematically false. So do not use this for any serious purpose.

License

GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007

Copyright (C) 2007 Free Software Foundation, Inc. https://fsf.org/

This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA, or see https://www.gnu.org/licenses/.

2. Project overview

  • Author: Firefnix
  • Coded in Python 3.8
  • Licensed under LGPL-3-or-later
  • Source code: here

3. Usage examples

To build the digits calculator and compute:

from piran import build, compute
build() # pi.c -> pi.so
compute(10000) # Ten thousand digits!

Note that this is only needed once. Ten thousand digits are usually computed in less than a second. Now we can really use the library:

from piran import Random
r = Random() # Creates a cursor file
for i in range(10):
    print("unsigned int:", r.uint(10), "\nsigned int:", r.sint(-10, 10))

r.close() # Deletes the cursor file

4. Explanations

I'm actually not very good at math. But we all know that:

Pi is an irrationnal number. Thus, its decimals never repeat themselves.

So I worked on the (mathematically false) assumption that if pi's decimals never repeat themselves, then these decimals can be considered "random".

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

piran-0.1b8.tar.gz (8.6 kB view details)

Uploaded Source

File details

Details for the file piran-0.1b8.tar.gz.

File metadata

  • Download URL: piran-0.1b8.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.2

File hashes

Hashes for piran-0.1b8.tar.gz
Algorithm Hash digest
SHA256 88ab354697fc350e2dfacaa769080cc5394c1b251a3f653d0538d06697a534cf
MD5 6d98dce7c7fc5f2bdd2dd7f396a13990
BLAKE2b-256 a4c997edd89f5b4f4e04fd14a56fd22b8dd660bb6c2b5f532f3044237ffa8bdc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page