-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Ziggurat as a method for standard_normal
#3278
Comments
standard_normal
to use Ziggurat algorithmstandard_normal
to use Ziggurat algorithm
standard_normal
to use Ziggurat algorithmstandard_normal
to use Ziggurat algorithm?
hmm it seems like box-muller's wikipedia page argues for it's use:
So it's not immediately obvious which would be better for our use case. It is worth noting that box-muller can't produce values more than 9.419 standard deviations from the mean |
I think we're going to have to add the stuff need for ziggurat for exponential anyway, so we could always add a we also be implementing the inverse cdf method / inverse transform sampling method for |
standard_normal
to use Ziggurat algorithm?standard_normal
This PR (closes Bears-R-Us#3278) adds `ziggurat` method for calculating standard normal based on numpys implemenation. I also realized that even though the zig method for both `standard_normal` and `standard_exponential` can't handle multi dimensional arrays yet, their other methods can. I created two versions of each proc with `where array_nd > 1` and `where array_nd == 1`, so now we can generate multi-dim exponentially and normally arrays if we use the compatible method. I added parameterization for the methods in the tests
This PR (closes Bears-R-Us#3278) adds `ziggurat` method for calculating standard normal based on numpys implemenation. I also realized that even though the zig method for both `standard_normal` and `standard_exponential` can't handle multi dimensional arrays yet, their other methods can. I created two versions of each proc with `where array_nd > 1` and `where array_nd == 1`, so now we can generate multi-dim exponentially and normally arrays if we use the compatible method. I added parameterization for the methods in the tests
This PR (closes Bears-R-Us#3278) adds `ziggurat` method for calculating standard normal based on numpys implemenation. I also realized that even though the zig method for both `standard_normal` and `standard_exponential` can't handle multi dimensional arrays yet, their other methods can. I created two versions of each proc with `where array_nd > 1` and `where array_nd == 1`, so now we can generate multi-dim exponentially and normally arrays if we use the compatible method. I added parameterization for the methods in the tests
Right now our implementation of
standard_normal
does a box-muller transform, but numpy uses the Ziggurat algorithm. Ziggurat algorithm's wikipedia page says:considering it's used by numpy and we're likely to need to generate large quantities of numbers, I think it would be worthwhile. It's also used in numpy's implementation of other distributions such as
exponential
which will be added in #3183Numpy's c based implementation can be found here
This will require saving off some constants . The nature of chpl means we'll want these constants on each locale or else we'll kill performance by going back and forth to the lookup tables on locale 0. This has caused us issues previously (see #2354)
The text was updated successfully, but these errors were encountered: