Repository navigation
Add Random instance for Natural #44
Description
Activity
- Excellent idea. . I’ve got a 1.2/2.0 branch in preparation. But one must then ask: what distribution! There is no finite interval to select uniformly for naturals or integers. We could have it just be the same range as a 64bit word or 128 bit word would be ... but that seems unsatisfactory.…On Tue, Oct 17, 2017 at 5:34 PM Neil Mitchell ***@***.***> wrote: With GHC 8.2 there is Natural in the base library, so it would be good if Random provided a suitable instance. — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#44>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAAQwoFodc2e39B1D6IIpKft1uj67yKLks5stR1ogaJpZM4P82t8> .
If you don't do what you do for
Integerit would be massively confusing. And forIntegeryou usemaxBound :: Int- which seems at least consistent.@ndmitchell using
maxBound :: Intsounds extremely wrong. I would expect something with more of a Gaussian-style shape with a fairly large standard deviation forInteger, and probably half of that forNatural.@treeowl perhaps, all I'm saying is they should be consistent. I would like the random Integer to never overflow all my memory though, so it needs a limit of some kind.
Ah, I suppose it does, for such practical reasons. But
maxBound :: Intseems way too small. If the standard deviation is something likemaxInt ^ nfor some smalln(to pick something pretty arbitrary), then you could cut off at some sensible multiple of that without losing much. What I really don't know is whether there is a good principled choice of distribution.- My current plan is to have the default natural interval be word 64. Defaults are well, defaults. And for infinite structures there’s no good answer for computations that finish in finite time. Hence markov chains and approximations algorithms The main bottle neck at the moment is figuring out how to make some needed systematic changes while making sure the breakages are all tolerable and happen just once.…On Mon, Feb 18, 2019 at 2:14 AM David Feuer ***@***.***> wrote: Ah, I suppose it does, for such practical reasons. But maxBound :: Int seems way too small. If the standard deviation is something like maxInt ^ n for some small n (to pick something pretty arbitrary), then you could cut off at some sensible multiple of that without losing much. What I really don't know is whether there *is* a good principled choice of distribution. — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#44 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AAAQwsKkKLzdpqsErvf_zs3v5p_AOfr7ks5vOlLPgaJpZM4P82t8> .
- More color : The current random instance / type class only supports / makes sense for uniform distributions on finite width intervals that have a finite number of points contained in those intervals. Anything else can’t Be an instance. On Mon, Feb 18, 2019 at 12:28 PM Carter Schonwald < [email protected]> wrote:…My current plan is to have the default natural interval be word 64. Defaults are well, defaults. And for infinite structures there’s no good answer for computations that finish in finite time. Hence markov chains and approximations algorithms The main bottle neck at the moment is figuring out how to make some needed systematic changes while making sure the breakages are all tolerable and happen just once. On Mon, Feb 18, 2019 at 2:14 AM David Feuer ***@***.***> wrote: > Ah, I suppose it does, for such practical reasons. But maxBound :: Int > seems way too small. If the standard deviation is something like maxInt > ^ n for some small n (to pick something pretty arbitrary), then you > could cut off at some sensible multiple of that without losing much. What I > really don't know is whether there *is* a good principled choice of > distribution. > > — > You are receiving this because you commented. > > > Reply to this email directly, view it on GitHub > <#44 (comment)>, or mute > the thread > <https://github.com/notifications/unsubscribe-auth/AAAQwsKkKLzdpqsErvf_zs3v5p_AOfr7ks5vOlLPgaJpZM4P82t8> > . >
- added 6 commits that reference this issue
on Jun 15, 2020 There is a new
instance UniformRange Natural. I don't know if addinginstance Random Naturalis a good idea. The broken instance forIntegeris already there, so we'll keep it for backwards compatibility, but adding new broken instances doesn't feel right. In any caseNaturalcan now be generated withuniformRanduniformRM
With GHC 8.2 there is Natural in the base library, so it would be good if Random provided a suitable instance.