According to my idea, this should be modified on the basis of the program defined by the regional source, but it seemed as if my idea was very immature. disk.flair (3.0 KB) disk.inp (2.3 KB) source.f (9.8 KB)

I would like to ask the expert how I can get a distribution similar to the official tutorial:
y=exp( -A * x)

Maybe the problem is simple, but it’s really troubling!
Thanks in advance！
fengfeng

as this is not a FLUKA, but a mathematical question, you can find many places, where sampling from probability distributions is explained, like this one.

Unfortunately I can’t verify if your implementation is correct or not based on a picture. Furthermore, you need to be careful, how the shift from z = 0 to z = zmin is implemented as it can influence what section of the exponential you are sampling from.

I forgot to upload my source file,It seems to be working well for now. You check it out. I found that with the decrease of the coefficient A, the result of the calculation seemed to differ more from the numerical integral.This is a very strange result for me. source.f (9.8 KB)

I hope that the teacher will analyze why the difference between the counting result and the numerical integral will become larger and larger as the coefficient A decreases.At the same time, first make sure that it does achieve exponential distribution sampling.

I did not specify which results are you comparing to what numerical integral, so I can’t comment on their differences.

The formula

-0.25D0 * LOG (FLRNDM( ZCOORD ))

will already give you a random number between 0 and +infinity. So the multiplication (ZMAX - ZMIN) will only alter the term of -(1/A) giving you a different distribution that you are expecting.

It is a pleasure to have implemented the program with the help of my teachers.I think I got the best affirmation.The first one is not a fluka problem, I will solve it myself, delaying your time.This post can be closed.

Thanks to Mr. David, I can learn something new!
Fengfeng