comp.lang.ada
 help / color / mirror / Atom feed
From: gautier_niouzes@hotmail.com
Subject: Re: Simple hash or pseudo-random function
Date: Mon, 16 Jul 2018 14:14:09 -0700 (PDT)
Date: 2018-07-16T14:14:09-07:00	[thread overview]
Message-ID: <979df026-05c7-447b-b5eb-010d85d61813@googlegroups.com> (raw)
In-Reply-To: <piijvs$u7k$1@dont-email.me>

Le lundi 16 juillet 2018 19:17:49 UTC+2, Jeffrey R. Carter a écrit :

> Not sure what you mean by "an integer in a range of minimum length 365". You 
> could simply use a RNG to generate 64-bit values and xor them with your values 
> if you want a 64-bit result. By setting the initial seed, the sequence would be 
> repeatable. Ada.Numerics.Discrete_Random would probably serve. If it's too slow, 
> the PragmAda Reusable Components includes KISS, a very fast, pretty good RNG. It 
> produces 32-bit values, so you'd probably need to call it twice.

The 64-bit value is the *input* and the output is a function of that input only.
e.g.
10562032 gives always 211
31375393 gives always 31
85232830 gives always 172
NB: the input codes can appear in a different order, so a pseudo-random *sequence* cannot be used.

I've tested different RNG's by initializing them with the input code and using only the first pseudo-random value using that seed. The good news is that they seem uniformly distributed even with successive seed values, but they are not random enough when seeds are similar. I'll check Marius' solution, or a hash function like CRC.


  reply	other threads:[~2018-07-16 21:14 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-16  8:20 Simple hash or pseudo-random function gautier_niouzes
2018-07-16 13:34 ` Shark8
2018-07-17  4:44   ` robin.vowels
2018-07-16 14:52 ` Marius Amado-Alves
2018-07-16 20:59   ` gautier_niouzes
2018-07-16 17:17 ` Jeffrey R. Carter
2018-07-16 21:14   ` gautier_niouzes [this message]
2018-07-17  6:09     ` Jeffrey R. Carter
2018-07-18 13:38       ` gautier_niouzes
2018-08-01  9:08         ` gautier_niouzes
2018-07-17  0:40 ` Dan'l Miller
2018-07-17  6:44 ` Paul Rubin
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox