logs archiveBotHelp.net / Freenode / #ada / 2015 / August / 14 / 3
charlie5
no implementations in other langs ?
(Action) will have to hit sack soon
Visaoni
really simple one in C, "reference" on in C++
I think I recall seeing a C-style one done for Haskell or something
charlie5
c++ uses templates ?
Visaoni
oh god so many templates
charlie5
lol
Visaoni
uses more template magick than I know
charlie5
heh, ok ... so not a good candidate for a port :)
Visaoni
it gets worse too, when you consider the "reference" implementation has 4 kinds of generators that offer different options (some you can alter the value that is added, other's you can't. of those you can't, some use memory location of generator to provide unique value, couple of differnt default values)
originally I picked this damned project because it sounded simple but kind of interesting, potentially useful, and like a modern place I could slap "Ada was here"
charlie5
fun'n'games, eh
Visaoni
but yeah
I've got a thing that works. have had one for ages. it just requires an obscene amount of work to set up
charlie5
i've used the standard ada random number generator pkg but only for sims and games ... nothing with stringent random requirements
i guess you've checked it out already
Visaoni
yup
mersenne twister on the inside, and has some silly restrictions (like the type-in-package-instantiation, and lacking a bounded_random)
nothing wrong with it, other than that silliness
unless you have a reason to care about space and really care about speed
charlie5
yeah, the standard ada/gnat implementations arent always 'optimal', i spose
Visaoni
there's really nothing wrong with using the mersenne twister as your standard
charlie5
(Action) has run out of irish coffee
Visaoni
although I might argue there is something wrong with the spec :)
charlie5
heh, i don;t think i've read the ada LRM sections on random numbers
would be nice to sit down ansd read the thing thru properly one fine sunny day
Visaoni
it's really just the way you're forced to pick a range and have that range forever and ever that's silly
potentially harmful, even, considering for each new range you have to start over and reseed
although at that point maybe you just go into the source code and copy/paste the Random implementation to avoid all that :P
charlie5
(Action) just chekced his 'random' math code
discretes get mapped from 0..1 random real range as mentioned b4 ... pretty ordinary
mm, naptime methinks
Visaoni
yep, so you basically did the later then (or else your distributions are skewed :P)
just for comparison, everything else aside, just the state bits are 624 32-bit values in the standard implementation
charlie5
624 ?!
Visaoni
aye
egilhh
"standard implementation"? The standard does not specify how things are implemented
Visaoni
well, the one used in GNAT
I was going to say you're kind of forced into it by the mersenne twister, although it seems there's a smaller version of it
Natacha
it depends on which Mersenne prime you pick
Visaoni
and after a quick glance it seems the standard doesn't require the Mersenne twister either
and yes, I should have said "forced into something big"
but it seems that isn't true either :)
charlie5
one last chirrup before i rest mine eary head ... would caching be helpful performance wise (for small discrete ranges) .. ie precalculate a set of randoms in the range, then offer them up as/when requested
err, weary
:)
sort of a side issue, i guess
Visaoni
erm... could be? probably depends a lot on how the user code is
charlie5
well, probly would only be of benefit in certain cases, if any
Visaoni
probably not I'd guess, unless you went really extreme and packed the cached results
charlie5
i tried similar with caching trig results for a 2d physics lib ... helped quite a bit (well, lots :) ) ... been a little loopy on caching ever since
Visaoni
you'd need something to reliably kick the generator out of the cache, but not kick the.. cache... out of the cache
even then
but yeah
I don't need more things to do in this project :P
I have quite enough already, thank you very much
charlie5
ah, i'm afraid i don't mean cpu cache ... that's a bit beyond me atm ... i just meant storing precalculated values in an array and looking them up ... there is a loss of accuracy of course but the precision is configurable
heh, yes, i shouldn't have mentioned it
just crossed my mind on way to the hammock
n8
Visaoni
aye, I know what you meant :)
(Action) goes to bed
darkestkhan
charlie5: for small discrete types permutations are best
pnoffke
#last
!last
sparre
(Action) has been wondering if keeping the generator state in a generic package isn't the most practical.
Natacha
the state is the coldest of all cold monsters
« prev 1 2 3 next »