You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't quite know if this is the proper place for this, but is there a way to make certain guarantees that unsafe code external to the crate can depend upon? I use this code a lot for code that is supposed to be relatively high performance, but it's relatively difficult to extract information from the struct safely and efficiently so that I can manipulate it with unsafe code.
As a simple example, is there a way to add some kind of InfallibleDistribution trait which is basically the Distribution trait but for distributions that have the relevant statistics always defined regardless of their parameters? Currently, I'm using unwrap_unchecked() on the std_dev() output of the Normal distribution, but that's not technically guaranteed by the API to always be sound, even though the standard deviation of any Normal distribution is obviously always defined.
@alimf17 would the solution proposed in #295 work well for you? Or did you want to construct distributions unchecked and have all their evaluations be unchecked as well? At the moment, we've relied on using NAN to signal unconditionally bad input
inverse_cdf(x) = NAN implies x is not a probability, i.e. outside [0,1] or NAN
pdf(x) = NAN implies x is not in the sample space or is NAN
and I'd prefer keeping the checks around. #303 happens to be an interesting case of something like this, where returning NAN wouldn't clearly indicate where input was first identified as bad, but the error occurs because of underflow - a use case for [signaling] NAN.
I don't quite know if this is the proper place for this, but is there a way to make certain guarantees that unsafe code external to the crate can depend upon? I use this code a lot for code that is supposed to be relatively high performance, but it's relatively difficult to extract information from the struct safely and efficiently so that I can manipulate it with unsafe code.
As a simple example, is there a way to add some kind of InfallibleDistribution trait which is basically the Distribution trait but for distributions that have the relevant statistics always defined regardless of their parameters? Currently, I'm using
unwrap_unchecked()
on thestd_dev()
output of the Normal distribution, but that's not technically guaranteed by the API to always be sound, even though the standard deviation of any Normal distribution is obviously always defined.Originally posted by @alimf17 in #206 (comment)
Feel free to change the title on this issue
The text was updated successfully, but these errors were encountered: