Comments (9)
Looks interesting. The exponential definitely should make it in.
from ng-numpy-randomstate.
Some quick benchmarks for normal in Python. Generating 1000000
fast-prng: 70ms
randomstate (mt19937): 135ms
randomstate (dsfmt): 35ms
randomstate (xoroshiro): 23ms
The mt19937 in randomstate cannot change due to upstream compatibility. This said, the implementation in randomstate when using a good core PRNG is already 3 times faster than fast-prng.
from ng-numpy-randomstate.
These were testes using the just released 1.11.3.
from ng-numpy-randomstate.
I made a mistake in my previosu benchmarks -- fast PRNG is faster in normals as you say. I differed the numbers of prndoms generated by a factor of 10.
from ng-numpy-randomstate.
fast-prng uses a very fast, inlined core PRNG. This seems to be the source of most of the gains.
Time in ns/observation when producing 10,000,000
Uniform Normal
fast-prng 3.91 6.16
xoroshiro 3.95 8.89
This suggests the Ziggurat implementation is around 100((8.89-3.95)/(6.16-3.91) - 1) = 119% faster, or about double performance.
I suspect all of the apparatus in the abstraction needed to handle lots of different PRNGs is a non-trivial source of the performance difference.
from ng-numpy-randomstate.
I think fast_prng is just using MT19937 (https://bitbucket.org/cdmcfarland/fast_prng/src/b132857f4f040b53516c1b404ade67871c7807d4/shared.h?fileviewer=file-view-default#shared.h-6), so the overhead, if any, comes from the PRNG dispatch?
from ng-numpy-randomstate.
It looks to be using a simd aware MT19937 which is a precursor to dSFMT.
There are a lot of difference that help performance of fast prng such as
having a smaller state and having the only state global to the module. I
don't see any easy way to try and utilize these optimizations while keeping
all of the structure and backward compatibility of a numpy-esque
randomstate.
This said I can try and port over the ziggurat implementation to see how it
goes. I already have 3 or 4 different versions in the code. And the
exponential ziggurat is also a very good idea.
On Fri, Jul 15, 2016, 8:02 PM Antony Lee [email protected] wrote:
I think fast_prng is just using MT19937 (
https://bitbucket.org/cdmcfarland/fast_prng/src/b132857f4f040b53516c1b404ade67871c7807d4/shared.h?fileviewer=file-view-default#shared.h-6),
so the overhead, if any, comes from the PRNG dispatch?—
You are receiving this because you commented.Reply to this email directly, view it on GitHub
#64 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AFU5RdfdHM5yacHqpyrcZdWgEjtXIa7-ks5qV9lFgaJpZM4JNCWx
.
from ng-numpy-randomstate.
On my laptop xoroshiro seems ~26% slower than the inline fast_prng; I guess that's an acceptable cost for the additional functionailities in randomstate.
from ng-numpy-randomstate.
I'm going to close this. I've added ziggurat for Normal and Exponential and implicitly for Gamma (which depends on normal and exponential). The fast_prng is definitely very fast and uses an improved but more complicated sampler to avoid the expensive rejection sampling. This said, the gap is now quite small (say 6.5ns/normal vs 9ns/normal, which are both much faster than NumPy's 70ns/normal). The exponential gain is even larger, with the Ziggurat about 10x faster on Linux.
from ng-numpy-randomstate.
Related Issues (20)
- is this normal? HOT 5
- Python 3.6 wheels HOT 8
- help on RandomState functions show numpy examples HOT 3
- Can not be used on Debian 9 HOT 3
- Can you provide a function to generate random number from multiple streams HOT 3
- Jump is too slow for larger jump steps! HOT 10
- optimized uniform small integers? HOT 4
- Add xoroshiro128+ HOT 1
- Lift "No Compatibility Guarantee" HOT 5
- Improve docstring for dtype
- Upload the latests releases to pypi? HOT 1
- did random_uintegers go away? HOT 11
- Segfault when seeding some prng's with float64 HOT 6
- Jump function for the MT19937 HOT 9
- A bug in MultithreadedRNG HOT 8
- Is there a generic randomstate class I can inherit from? HOT 3
- lognormal doc enhancement? HOT 2
- 1.13 fails to build HOT 13
- `advance` and `randint` HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ng-numpy-randomstate.