Strange behaviour observed in output of gaussian random generator

Dear FLUKA experts,

I had a strange experience while using Gaussian random number generator in FLUKA. For some other purpose, I need a Gaussian distribution and often I prefer to use in built feature of FLUKA for this. I only added few lines for that and used a write statement to get a print of 1000 points with Gaussian distribution. I created a new basic fluka input for that. The variables used for Gaussian sampling had nothing to do with other variables present in default source.f.

What I observed is that the output depends on the way XFLK(NPFLKA) … are defined, in one case I wrote fixed value (5.0D0, arbitrary) [see the source1.f] and in other case, I wrote XBEAM… [see the source2.f].

I hoped, the output of Gaussian random number wont depend on that. Am I missing something here ?

Here are the distributions when I used these two source.f. [first fig. for source1.f]

second fig. for source2.f]

Other relevant files for your convenience:

test.inp (1.1 KB) source_1.f (9.1 KB) source_2.f (9.1 KB) test.flair (1004 Bytes)

Dear Riya,

you need to keep in mind, that the same random number generator is used during the particle transport as well to sample the interactions. So if you change the simulation settings (in your case the beam position), the random numbers will diverge.

However, this doesn’t mean you wont get random numbers according to a Gaussian distribution in both cases.

If you are only want to generate random numbers unrelated to FLUKA, you could have a look at Python: How to Generate Random Numbers in Python

Cheers,
David

1 Like

Hello @horvathd ,

Thank you for the explanation. Is there any function available to generate gaussian random number directly in python? I know we can also generate gaussian random number using Box Muller method etc, for that a sampling method has to be written. Since FLUKA already has that function, I was using that. One thing, I am unable to understand is, in my source file, I have not used Gaussian random number at any place during particle transport. Can you please tell me where exactly it is using this function ?

Also, I know in both cases I am getting gaussian random number. But while dividing in bins, in 2nd case ( where I have written XBEAM), in some bin, the value is zero, which is not required for my purpose.

Regards,
Riya

Dear Riya,

for a Python example please look at the linked tutorial and search for the Random Gaussian Values section. (How to Generate Random Numbers in Python)

FLUKA also uses the Box-Muller transform to generate random numbers from a Gaussian distribution. So any random number used during the transport will use the same underlying pseudo random number generator.

In your case, when you leave the beam coordinates default (XBEAM, etc.), then the simulated particle beam will interact with the COPPER target you have in your input file. To simulate the interaction random numbers are used.

The zero bin you are observing is simply due to statistics, you need to generate more random numbers to smooth out the curve.

Cheers,
David

1 Like

Thank you @horvathd for the help.

Regards,
Riya