Skip to content

Commit

Permalink
Merge 6b910e1 into 433d83b
Browse files Browse the repository at this point in the history
  • Loading branch information
bashtage committed May 12, 2019
2 parents 433d83b + 6b910e1 commit a33af93
Show file tree
Hide file tree
Showing 30 changed files with 337 additions and 335 deletions.
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ are Python 3, with an initial minimum version of 3.5.

## Compatibility Warning

`RandomGenerator` does not support Box-Muller normal variates and so it not
`Generator` does not support Box-Muller normal variates and so it not
100% compatible with NumPy (or randomstate). Box-Muller normals are slow
to generate and all functions which previously relied on Box-Muller
normals now use the faster Ziggurat implementation. If you require backward
Expand All @@ -43,8 +43,8 @@ which can fully reproduce the sequence produced by NumPy.
* Replacement for NumPy's RandomState

```python
from randomgen import RandomGenerator, MT19937
rnd = RandomGenerator(MT19937())
from randomgen import Generator, MT19937
rnd = Generator(MT19937())
x = rnd.standard_normal(100)
y = rnd.random(100)
z = rnd.randn(10,10)
Expand All @@ -57,9 +57,9 @@ which can fully reproduce the sequence produced by NumPy.
exponential and standard gamma using the Ziggurat method

```python
from randomgen import RandomGenerator
from randomgen import Generator
# Default basic PRNG is Xoroshiro128
rnd = RandomGenerator()
rnd = Generator()
w = rnd.standard_normal(10000)
x = rnd.standard_exponential(10000)
y = rnd.standard_gamma(5.5, 10000)
Expand Down Expand Up @@ -237,15 +237,15 @@ Python 2.7.
The separate generators are importable from `randomgen`

```python
from randomgen import RandomGenerator, ThreeFry, PCG64, MT19937
rg = RandomGenerator(ThreeFry())
from randomgen import Generator, ThreeFry, PCG64, MT19937
rg = Generator(ThreeFry())
rg.random(100)

rg = RandomGenerator(PCG64())
rg = Generator(PCG64())
rg.random(100)

# Identical to NumPy
rg = RandomGenerator(MT19937())
rg = Generator(MT19937())
rg.random(100)
```

Expand Down
28 changes: 14 additions & 14 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ Python 3, with an initial minimum version of 3.5.
Compatibility Warning
---------------------

``RandomGenerator`` does not support Box-Muller normal variates and so
it not 100% compatible with NumPy (or randomstate). Box-Muller normals
are slow to generate and all functions which previously relied on
Box-Muller normals now use the faster Ziggurat implementation. If you
require backward compatibility, a legacy generator, ``RandomState``, has
been created which can fully reproduce the sequence produced by NumPy.
``Generator`` does not support Box-Muller normal variates and so it not
100% compatible with NumPy (or randomstate). Box-Muller normals are slow
to generate and all functions which previously relied on Box-Muller
normals now use the faster Ziggurat implementation. If you require
backward compatibility, a legacy generator, ``RandomState``, has been
created which can fully reproduce the sequence produced by NumPy.

Features
--------
Expand All @@ -51,8 +51,8 @@ Features

.. code:: python
from randomgen import RandomGenerator, MT19937
rnd = RandomGenerator(MT19937())
from randomgen import Generator, MT19937
rnd = Generator(MT19937())
x = rnd.standard_normal(100)
y = rnd.random(100)
z = rnd.randn(10,10)
Expand All @@ -65,9 +65,9 @@ Features

.. code:: python
from randomgen import RandomGenerator
from randomgen import Generator
# Default basic PRNG is Xoroshiro128
rnd = RandomGenerator()
rnd = Generator()
w = rnd.standard_normal(10000)
x = rnd.standard_exponential(10000)
y = rnd.standard_gamma(5.5, 10000)
Expand Down Expand Up @@ -263,15 +263,15 @@ The separate generators are importable from ``randomgen``

.. code:: python
from randomgen import RandomGenerator, ThreeFry, PCG64, MT19937
rg = RandomGenerator(ThreeFry())
from randomgen import Generator, ThreeFry, PCG64, MT19937
rg = Generator(ThreeFry())
rg.random(100)
rg = RandomGenerator(PCG64())
rg = Generator(PCG64())
rg.random(100)
# Identical to NumPy
rg = RandomGenerator(MT19937())
rg = Generator(MT19937())
rg.random(100)
.. _license-1:
Expand Down
4 changes: 2 additions & 2 deletions benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
rg = numpy.random.RandomState()
rg.random_sample()
else:
from randomgen import RandomGenerator, {brng}
rg = RandomGenerator({brng}())
from randomgen import Generator, {brng}
rg = Generator({brng}())
rg.random()
'''

Expand Down
2 changes: 1 addition & 1 deletion doc/source/brng/index.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Basic Random Number Generators
------------------------------

The random values produced by :class:`~randomgen.generator.RandomGenerator`
The random values produced by :class:`~randomgen.generator.Generator`
are produced by a basic RNG. These basic RNGs do not directly provide
random numbers and only contains methods used for seeding, getting or
setting the state, jumping or advancing the state, and for accessing
Expand Down
20 changes: 10 additions & 10 deletions doc/source/change-log.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,26 @@ v1.16.5
:func:`~randomgen.mtrand.RandomState.exponential`, and
:func:`~randomgen.mtrand.RandomState.logistic` that could result in ``nan``
values in rare circumstances (about 1 in :math:`10^{53}` draws).
- Added keyword ``closed`` to :func:`~randomgen.generator.RandomGenerator.randint`
- Added keyword ``closed`` to :func:`~randomgen.generator.Generator.randint`
which changes sampling from the half-open interval ``[low, high)`` to the closed
interval ``[low, high]``.
- Fixed a bug in :func:`~randomgen.mtrand.RandomState.random_integers` that
could lead to valid values being treated as invalid.

v1.16.4
=======
- Add a fast path for broadcasting :func:`~randomgen.generator.RandomGenerator.randint`
- Add a fast path for broadcasting :func:`~randomgen.generator.Generator.randint`
when using ``uint64`` or ``int64``.
- Refactor PCG64 so that it does not rely on Cython conditional compilation.
- Add :func:`~randomgen.generator.RandomGenerator.brng` to access the basic RNG.
- Allow multidimensional arrays in :func:`~randomgen.generator.RandomGenerator.choice`.
- Speed-up :func:`~randomgen.generator.RandomGenerator.choice` when not replacing.
- Add :func:`~randomgen.generator.Generator.brng` to access the basic RNG.
- Allow multidimensional arrays in :func:`~randomgen.generator.Generator.choice`.
- Speed-up :func:`~randomgen.generator.Generator.choice` when not replacing.
The gains can be very large (1000x or more) when the input array is large but
the sample size is small.
- Add parameter checks in :func:`~randomgen.generator.RandomGenerator.multinomial`.
- Fix an edge-case bug in :func:`~randomgen.generator.RandomGenerator.zipf`.
- Allow 0 for sample in :func:`~randomgen.generator.RandomGenerator.hypergeometric`.
- Add broadcasting to :func:`~randomgen.generator.RandomGenerator.multinomial` (see
- Add parameter checks in :func:`~randomgen.generator.Generator.multinomial`.
- Fix an edge-case bug in :func:`~randomgen.generator.Generator.zipf`.
- Allow 0 for sample in :func:`~randomgen.generator.Generator.hypergeometric`.
- Add broadcasting to :func:`~randomgen.generator.Generator.multinomial` (see
`NumPy issue 9710 <https://github.com/numpy/numpy/pull/9710>`_)

v1.16.3
Expand All @@ -48,7 +48,7 @@ v1.16.2

- ``random_raw``, which have been moved to the individual basic RNGs
- ``random_uintegers``, which can be replaced with
:func:`~randomgen.generator.RandomGenerator.randint`.
:func:`~randomgen.generator.Generator.randint`.

- Added :class:`~randomgen.mtrand.RandomState` as a clone of NumPy's
RandomState.
Expand Down
6 changes: 3 additions & 3 deletions doc/source/extending.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Extending
---------
The basic RNGs have been designed to be extendable using standard tools for
high-performance Python -- numba and Cython.
The :class:`randomgen.generator.RandomGenerator` object can also be used with
The :class:`randomgen.generator.Generator` object can also be used with
user-provided basic RNGs as long as these export a small set of required
functions.

Expand Down Expand Up @@ -135,7 +135,7 @@ examples folder.

New Basic RNGs
==============
:class:`~randomgen.generator.RandomGenerator` can be used with other
:class:`~randomgen.generator.Generator` can be used with other
user-provided basic RNGs. The simplest way to write a new basic RNG is to
examine the pyx file of one of the existing basic RNGs. The key structure
that must be provided is the ``capsule`` which contains a ``PyCapsule`` to a
Expand All @@ -156,7 +156,7 @@ used by the basic RNG. The next three are function pointers which return the
next 64- and 32-bit unsigned integers, the next random double and the next
raw value. This final function is used for testing and so can be set to
the next 64-bit unsigned integer function if not needed. Functions inside
:class:`~randomgen.generator.RandomGenerator` use this structure as in
:class:`~randomgen.generator.Generator` use this structure as in

.. code-block:: c
Expand Down
103 changes: 51 additions & 52 deletions doc/source/generator.rst
Original file line number Diff line number Diff line change
@@ -1,89 +1,88 @@
Random Generator
----------------
The :class:`~randomgen.generator.RandomGenerator` provides access to
The :class:`~randomgen.generator.Generator` provides access to
a wide range of distributions, and served as a replacement for
:class:`~numpy.random.RandomState`. The main difference between
the two is that :class:`~randomgen.generator.RandomGenerator` relies
the two is that :class:`~randomgen.generator.Generator` relies
on an additional basic RNG to manage state and generate the random
bits which are then transformed into random values from useful
distributions. The default basic RNG used by
:class:`~randomgen.generator.RandomGenerator` is
:class:`~randomgen.generator.Generator` is
:class:`~randomgen.xoroshiro128.Xoroshiro128`. The basic RNG can be
changed by passing an instantized basic RNG to
:class:`~randomgen.generator.RandomGenerator`.
:class:`~randomgen.generator.Generator`.

.. currentmodule:: randomgen.generator

.. autoclass::
RandomGenerator
Generator

Seed and State Manipulation
===========================
.. autosummary::
:toctree: generated/

~RandomGenerator.seed
~RandomGenerator.state
~Generator.seed
~Generator.state

Simple random data
==================
.. autosummary::
:toctree: generated/

~RandomGenerator.rand
~RandomGenerator.randn
~RandomGenerator.integers
~RandomGenerator.random_integers
~RandomGenerator.random
~RandomGenerator.choice
~RandomGenerator.bytes
~Generator.rand
~Generator.randn
~Generator.integers
~Generator.random
~Generator.choice
~Generator.bytes

Permutations
============
.. autosummary::
:toctree: generated/

~RandomGenerator.shuffle
~RandomGenerator.permutation
~Generator.shuffle
~Generator.permutation

Distributions
=============
.. autosummary::
:toctree: generated/

~RandomGenerator.beta
~RandomGenerator.binomial
~RandomGenerator.chisquare
~RandomGenerator.complex_normal
~RandomGenerator.dirichlet
~RandomGenerator.exponential
~RandomGenerator.f
~RandomGenerator.gamma
~RandomGenerator.geometric
~RandomGenerator.gumbel
~RandomGenerator.hypergeometric
~RandomGenerator.laplace
~RandomGenerator.logistic
~RandomGenerator.lognormal
~RandomGenerator.logseries
~RandomGenerator.multinomial
~RandomGenerator.multivariate_normal
~RandomGenerator.negative_binomial
~RandomGenerator.noncentral_chisquare
~RandomGenerator.noncentral_f
~RandomGenerator.normal
~RandomGenerator.pareto
~RandomGenerator.poisson
~RandomGenerator.power
~RandomGenerator.rayleigh
~RandomGenerator.standard_cauchy
~RandomGenerator.standard_exponential
~RandomGenerator.standard_gamma
~RandomGenerator.standard_normal
~RandomGenerator.standard_t
~RandomGenerator.triangular
~RandomGenerator.uniform
~RandomGenerator.vonmises
~RandomGenerator.wald
~RandomGenerator.weibull
~RandomGenerator.zipf
~Generator.beta
~Generator.binomial
~Generator.chisquare
~Generator.complex_normal
~Generator.dirichlet
~Generator.exponential
~Generator.f
~Generator.gamma
~Generator.geometric
~Generator.gumbel
~Generator.hypergeometric
~Generator.laplace
~Generator.logistic
~Generator.lognormal
~Generator.logseries
~Generator.multinomial
~Generator.multivariate_normal
~Generator.negative_binomial
~Generator.noncentral_chisquare
~Generator.noncentral_f
~Generator.normal
~Generator.pareto
~Generator.poisson
~Generator.power
~Generator.rayleigh
~Generator.standard_cauchy
~Generator.standard_exponential
~Generator.standard_gamma
~Generator.standard_normal
~Generator.standard_t
~Generator.triangular
~Generator.uniform
~Generator.vonmises
~Generator.wald
~Generator.weibull
~Generator.zipf

0 comments on commit a33af93

Please sign in to comment.