arvoelke / nengolib

Nengo library of additional extensions
Other
29 stars 6 forks source link

Quasi Monte Carlo Rd Sampling #153

Closed arvoelke closed 6 years ago

arvoelke commented 6 years ago

Resolves #152. Code is modified from http://extremelearning.com.au/unreasonable-effectiveness-of-quasirandom-sequences/

This is a new method for sampling points from the sphere and ball (encoders and evaluation points). It is still possible to use the old method by passing base=Sobol() to the constructor of all of the distributions, instead of the new default of base=Rd(). The biggest benefit is the new method works for arbitrary dimension, whereas the old method regressed to Nengo's independent distribution for d > 40.

Some plots from the new method (to be in the documentation upon release):

new_documentation

new_documentation2

new_documentation3

Versus the old method (Sobol):

old_documentation1

old_documentation2

old_documentation3

codecov-io commented 6 years ago

Codecov Report

Merging #153 into master will not change coverage. The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master   #153   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files          29     29           
  Lines        1374   1398   +24     
  Branches      157    162    +5     
=====================================
+ Hits         1374   1398   +24
Impacted Files Coverage Δ
nengolib/stats/ntmdists.py 100% <100%> (ø) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update a523f79...293492c. Read the comment docs.

arvoelke commented 6 years ago

@astoeckel Since you were using the Halton sequence, this might be of interest to you. This is a new quasi-random sequence, that's been implemented as a Nengo distribution. You can use it to generate scattered points on the cube, sphere, or ball.

Links to staging documentation (with inline code examples):

carlosgmartin commented 1 year ago

@arvoelke Could @sdementen's suggestions be incorporated? (Avoiding Python for loops, which are slow, as much as possible.)

arvoelke commented 1 year ago

Thanks for the feedback/request. Done in https://github.com/arvoelke/nengolib/pull/191 which has been merged into master. It is unlikely to be released to pypi due to compatibility drift that should be sorted out. It should be possible to install/depend on master directly if this speed-up is needed.

carlosgmartin commented 1 year ago

@arvoelke Thanks! I see a few other places in the code could benefit from vectorization as well, if you're interested. Let me know if you'd like me to open an issue or pull request.

arvoelke commented 1 year ago

I'd be interested in PRs if they are motivated by things that you're running and then you found that your changes helped run them faster/etc (as opposed to just optimizing code for the sake of it).

If you are hungry for speed-ups across the board I would suggest looking into Pyston. The lite version can be installed via pip install pyston_lite_autoload and provides a boost in speed to the entire Python process. I've had good experiences with both lite and full versions.