Git Product home page Git Product logo

zignor-python's Introduction

zignor-python

Ziggurat normal random number generator ported to Python

Requirement

NumPy installation is required. Python 3 compatible.

Installation

To install, run

python setup.py install

or you can install from PyPI:

pip install zignor

If you are running Windows and don't have MSVC compiler installed, a pre-built distribution on Python 3.5 is given in dist folder.

Usage

It will automatically import NumPy, so you can just use

import zignor
zignor.randn(10)

or

zignor.randn(3, 5)

to generate a matrix of 3 by 5.

More functions

This module includes two implementations. One is an slightly modified implementation of the original Ziggurat method (http://www.jstatsoft.org/article/downloadSuppFile/v005i08/rnorrexp.c). It uses SHR3 as the RNG for uniform distribution. This is the code behind zignor.randn() and zignor.rnor() method, and it is the faster of the two.

We also included a zignor.rexp() for generation exponential distribution.

The other implementation is the VIZIGNOR implementation by Doornik, J.A. It improves the original method and uses MWC8222 RNG to enable the method to pass some more tests. This method can be called by zignor.zignor().

References

  1. G. Marsaglia and W.W. Tsang: The Ziggurat Method for Generating Random Variables. Journal of Statistical Software, vol. 5, no. 8, pp. 1โ€“7, 2000.
  2. Doornik, J.A. (2005), "An Improved Ziggurat Method to Generate Normal Random Samples", mimeo, Nuffield College, University of Oxford.

zignor-python's People

Contributors

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