summaryrefslogtreecommitdiff
path: root/doc/source/reference/random/performance.py
diff options
context:
space:
mode:
authorKevin Sheppard <kevin.k.sheppard@gmail.com>2019-05-24 10:41:58 +0100
committermattip <matti.picus@gmail.com>2019-05-27 22:58:35 +0300
commit58c0e72854c3f79d3d165d74f2dc721815a38b57 (patch)
tree3a8fff1f2c1a073248c81e53ba8d3a0367c00907 /doc/source/reference/random/performance.py
parent3db5a7736cf26db59817eb8939b042ae18c482fa (diff)
downloadnumpy-58c0e72854c3f79d3d165d74f2dc721815a38b57.tar.gz
Revert "MAINT: Implement API changes for randomgen-derived code"
This reverts commit 17e0070df93f4262908f884dca4b08cb7d0bba7f.
Diffstat (limited to 'doc/source/reference/random/performance.py')
-rw-r--r--doc/source/reference/random/performance.py38
1 files changed, 21 insertions, 17 deletions
diff --git a/doc/source/reference/random/performance.py b/doc/source/reference/random/performance.py
index bbf17b1d0..54165226e 100644
--- a/doc/source/reference/random/performance.py
+++ b/doc/source/reference/random/performance.py
@@ -1,23 +1,25 @@
from collections import OrderedDict
from timeit import repeat
-import numpy as np
import pandas as pd
-from numpy.random import MT19937, DSFMT, ThreeFry, Philox, Xoshiro256, \
- Xoshiro512
+import numpy as np
+from numpy.random import MT19937, DSFMT, ThreeFry, PCG64, Philox, \
+ Xoshiro256, Xoshiro512
-PRNGS = [DSFMT, MT19937, Philox, ThreeFry, Xoshiro256, Xoshiro512]
+PRNGS = [DSFMT, MT19937, PCG64, Philox, ThreeFry, Xoshiro256, Xoshiro512]
-funcs = {'32-bit Unsigned Ints': 'integers(0, 2**32,size=1000000, dtype="uint32")',
- '64-bit Unsigned Ints': 'integers(0, 2**64,size=1000000, dtype="uint64")',
- 'Uniforms': 'random(size=1000000)',
- 'Normals': 'standard_normal(size=1000000)',
- 'Exponentials': 'standard_exponential(size=1000000)',
- 'Gammas': 'standard_gamma(3.0,size=1000000)',
- 'Binomials': 'binomial(9, .1, size=1000000)',
- 'Laplaces': 'laplace(size=1000000)',
- 'Poissons': 'poisson(3.0, size=1000000)', }
+funcs = OrderedDict()
+integers = 'integers(0, 2**{bits},size=1000000, dtype="uint{bits}")'
+funcs['32-bit Unsigned Ints'] = integers.format(bits=32)
+funcs['64-bit Unsigned Ints'] = integers.format(bits=64)
+funcs['Uniforms'] = 'random(size=1000000)'
+funcs['Normals'] = 'standard_normal(size=1000000)'
+funcs['Exponentials'] = 'standard_exponential(size=1000000)'
+funcs['Gammas'] = 'standard_gamma(3.0,size=1000000)'
+funcs['Binomials'] = 'binomial(9, .1, size=1000000)'
+funcs['Laplaces'] = 'laplace(size=1000000)'
+funcs['Poissons'] = 'poisson(3.0, size=1000000)'
setup = """
from numpy.random import {prng}, Generator
@@ -40,7 +42,7 @@ for prng in PRNGS:
npfuncs = OrderedDict()
npfuncs.update(funcs)
npfuncs['32-bit Unsigned Ints'] = 'randint(2**32,dtype="uint32",size=1000000)'
-npfuncs['64-bit Unsigned Ints'] = 'tomaxint(size=1000000)'
+npfuncs['64-bit Unsigned Ints'] = 'randint(2**64,dtype="uint64",size=1000000)'
setup = """
from numpy.random import RandomState
rg = RandomState()
@@ -51,7 +53,7 @@ for key in npfuncs:
setup.format(prng=prng().__class__.__name__),
number=1, repeat=3)
col[key] = 1000 * min(t)
-table['NumPy'] = pd.Series(col)
+table['RandomState'] = pd.Series(col)
table = pd.DataFrame(table)
table = table.reindex(table.mean(1).sort_values().index)
@@ -59,10 +61,12 @@ order = np.log(table).mean().sort_values().index
table = table.T
table = table.reindex(order)
table = table.T
+table = table.reindex([k for k in funcs], axis=0)
print(table.to_csv(float_format='%0.1f'))
-rel = table.loc[:, ['NumPy']].values @ np.ones((1, table.shape[1])) / table
-rel.pop(rel.columns[0])
+rel = table.loc[:, ['RandomState']].values @ np.ones(
+ (1, table.shape[1])) / table
+rel.pop('RandomState')
rel = rel.T
rel['Overall'] = np.exp(np.log(rel).mean(1))
rel *= 100