4D round q-Gaussian generator #136
Conversation
|
Need to add tests and test in GPU context. Would also appreciate some feedback on the numerical stability of |
szymonlopaciuk
left a comment
There was a problem hiding this comment.
I'm sorry it took so long to answer. I have a couple of comments that may be helpful regarding your numerical stability question. Otherwise the PR is very nice and clean!
| if abs(q - 1) < 1e-2: | ||
| term2 = -1 / (1 - q) | ||
| else: | ||
| term2 = gamma(q / (q - 1)) / gamma(1 / (q - 1)) |
There was a problem hiding this comment.
I think you might not need the branch, since
So the first one is not an approximation.
| else: | ||
| term2 = gamma(q / (q - 1)) / gamma(1 / (q - 1)) | ||
|
|
||
| term3 = (1 + beta * (q - 1) * F) ** (1 / (1 - q) - 3 / 2) |
There was a problem hiding this comment.
If I understand right, the stability problem is that for large beta and
| np.ndarray: CDF of g(F). | ||
| """ | ||
| delta_F = np.diff(F, prepend=0) | ||
| cdf = np.cumsum(g_F * delta_F) # todo: rewrite with scipy.integrate.quad(g_F, -np.inf, np.inf) |
Description
Adds 4D q-gaussian generator to create normalised coordinates in 4D.
Beam is round and q is the same in x and y.
Example in xpart/examples/particles_generation/008_generate_q_gaussian.py
Checklist
Mandatory:
Optional: