How would I use a random number generator to give random numbers from a top hat distribution in Fortran? I've seen lots of information about how to make a Gaussian random number generator, but not one with a top hat distribution.
$\begingroup$
$\endgroup$
4
-
$\begingroup$ What's a "top hat distribution"? $\endgroup$– Wolfgang BangerthCommented Jun 3, 2020 at 19:29
-
$\begingroup$ If you have a Gaussian random number generator, you can sample it, then if the sampled number is inside (mean-variance,mean+variance) then you return 1, otherwise, you return 0. $\endgroup$– Abdullah Ali SivasCommented Jun 3, 2020 at 20:32
-
$\begingroup$ Unless, of course, you are talking about uniform distribution over an arbitrary interval. That is just shifting and scaling. $\endgroup$– Abdullah Ali SivasCommented Jun 3, 2020 at 22:19
-
$\begingroup$ For a given random distribution characterized by some PDF one can find a transformation resulting in a different PDF. So from the standard random generators producing normal and uniform distributions one can derive a transformation producing anything else, including the "hat" function. $\endgroup$– Maxim UmanskyCommented Jun 4, 2020 at 4:05
Add a comment
|