[FFmpeg-devel] [PATCH] lavu/lfg: switch to Ziggurat algorithm for normal random number generation

Ganesh Ajjanagadde gajjanag at gmail.com
Sat Mar 12 15:00:33 CET 2016


On Fri, Mar 11, 2016 at 8:56 AM, Michael Niedermayer
<michael at niedermayer.cc> wrote:
> On Thu, Mar 10, 2016 at 11:16:08PM -0500, Ganesh Ajjanagadde wrote:
[...]
>> +static inline double ziggurat(AVLFG *lfg)
>> +{
>> +    while (1) {
>
>> +        uint64_t r = (av_lfg_get(lfg) << 31) + av_lfg_get(lfg);
>
> this looks like undefined behavior


>
> also the numbers that come out of this look different

Sorry about this; the julia code had a 64 bit random number generator
that I emulated incorrectly. I also forgot that they use 1 based
indexing in one spot. Fixed and posted v2, this in fact fixes the
other issue as well.

Benches are updated, there is a slight variation.

Wrote a sample mean and stddev computation as a sanity check for the
future; I will add a proper normality test some time.

[...]
>
>
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Democracy is the form of government in which you can choose your dictator
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>


More information about the ffmpeg-devel mailing list