HPL_rand(3)

πŸ“¦ version 2.2, in fedora 43, fedora 44

🌸 HPL_rand β€” random number generator πŸ’…

okay bestie, welcome to the HPL_rand(3) page, a whole HPL Library Functions moment, and it's literally just the little chaos gremlin that spits out your random numbers ✨


✨ SYNOPSIS ✨

#include "hpl.h"

double HPL_rand();

πŸ¦‹ DESCRIPTION πŸ¦‹

so HPL_rand generates the next number in the random sequence. that's it, that's the job πŸ’– and it's highkey picky about it too β€” this function ensures that the number lands in the interval (-0.5, 0.5]. not gonna lie, that interval is giving "almost symmetric but not quite" and we respect it.

the static array irand is where the info lives β€” it holds the 2 integers you need to cook up the next number in the sequence X(n). here's the actual formula, no cap:

X(n) = (2^32 * irand[1] + irand[0]) / d - 0.5

where the constant d is the largest 64 bit positive integer. yes ma'am, the largest one. iconic behavior fr fr.

then irand gets updated so you can generate the next number X(n+1) in the random sequence, like this:

X(n+1) = a * X(n) + c

and the constants a and c? those should have been preliminarily stored in the arrays ias and ics as 2 pairs of integers πŸŽ€ so like, they gotta be sitting there already, this function is not doing that for you, bestie.

and the initialization of ias, ics and irand? that's a whole separate serve β€” it's performed by the function HPL_setran. so go say hi to her first πŸ’œ

ngl if you skipped the setup step, you're on your own, this page is very clear that HPL_setran is the one who preps everything πŸ™ˆ

πŸ‘‘ SEE ALSO πŸ‘‘

  • HPL_ladd (3)
  • HPL_lmul (3)
  • HPL_setran (3)
  • HPL_xjumpm (3)
  • HPL_jumpit (3)

and that's the whole page, bestie 🫢 this was HPL 2.2, dated February 24, 2016, from the HPL Library Functions collection. slay, stay random, bye πŸ’–βœ¨πŸŒˆ

πŸ“¦ where this page comes from