Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

A synchronized Tausworthe RNG for Python and R

Project Description

A synchronized Tausworthe RNG usable in R and Python.


This program was created because it was desired to have the same random numbers in both R and Python programs. Although both languages implement a Mersenne-Twister RNG, the implementations are so different that it is not possible to get the same random numbers with the same seed.

SyncRNG is a Tausworthe RNG implemented in syncrng.c, and linked to both R and Python. Since both use the same underlying C code, the random numbers will be the same in both languages, provided the same seed is used.


First install the packages as stated under Installation. Then, in Python you can do:

from SyncRNG import SyncRNG

s = SyncRNG(seed=123456)
for i in range(10):

Similarly, after installing the R library you can do in R:


s <- SyncRNG(seed=123456)
for (i in 1:10) {
   cat(s$randi(), '\n')

You’ll notice that the random numbers are indeed the same.


Installing the R package can be done through CRAN:


The Python package can be installed using pip:

pip install syncrng


In both R and Python the following methods are available for the SyncRNG class:

  1. randi(): generate a random integer on the interval [0, 2^32).
  2. rand(): generate a random floating point number on the interval [0.0, 1.0)
  3. randbelow(n): generate a random integer below a given integer n.
  4. shuffle(x): generate a permutation of a given list of numbers x.


The random numbers are uniformly distributed on [0, 2^32 - 1].

Release History

Release History

This version
History Node


History Node


History Node


Download Files

Download Files

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

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
SyncRNG-1.2.1.tar.gz (5.0 kB) Copy SHA256 Checksum SHA256 Source Oct 16, 2016

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting