Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolve poisson and gamma distributions between _commonspeckle and skbeam #54

Open
1 of 2 tasks
ambarb opened this issue Feb 5, 2021 · 2 comments
Open
1 of 2 tasks
Labels
_commonspeckle part of V2, but strictly related to a common repo (speckle + maybe scattering) question skbeam conflict V2 required to move towards share XPCS/speckle analysis for CHX/CSX

Comments

@ambarb
Copy link
Collaborator

ambarb commented Feb 5, 2021

Neet to address differences in two distribution functions.

  • gamma distribution
  • poisson distribution

Gamma Distribution

_commonspeckle

(lines 472-474 are completely different)

# gamma_dist = (stats.gamma(M, 0., K/M)).pdf(bin_values)
x = bin_values
coeff = np.exp(M * np.log(M) + (M - 1) * np.log(x) - gammaln(M) - M * np.log(K))
gamma_dist = coeff * np.exp(-M * x / K)
return gamma_dist

skbeam

https://github.com/scikit-beam/scikit-beam/blob/655d55f6396524f012bd5d1e2dc3b3fa9d6d6512/skbeam/core/fitting/lineshapes.py#L414-L415

Poisson Distribution

_commonspeckle

(make sure K is a float)

P(K) = \frac{<K>^K}{K!}\exp(-<K>)
"""
# poisson_dist = stats.poisson.pmf(K, bin_values)
K = float(K)
poisson_dist = np.exp(-K) * np.power(K, bin_values) / gamma(bin_values + 1)
return poisson_dist

skbeam

https://github.com/scikit-beam/scikit-beam/blob/655d55f6396524f012bd5d1e2dc3b3fa9d6d6512/skbeam/core/fitting/lineshapes.py#L489-L493

@ambarb ambarb added V2 required to move towards share XPCS/speckle analysis for CHX/CSX _commonspeckle part of V2, but strictly related to a common repo (speckle + maybe scattering) labels Feb 5, 2021
@ambarb
Copy link
Collaborator Author

ambarb commented Feb 5, 2021

@danielballan @afluerasu would the ultimate plan be to import these distributions INTO skbeam or to import FROM skbeam?

@ambarb
Copy link
Collaborator Author

ambarb commented Mar 31, 2021

For gamma distribution @yugangzhang told us that the original scipy function is wrong and he had to correct it manually. @xmchenGH checked that the latest scipy function performs as expected. It sounds like we can convert back to the original skbeam code for the gamma distribution. For this we will simply import.

Thanks @xmchenGH for your help on this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
_commonspeckle part of V2, but strictly related to a common repo (speckle + maybe scattering) question skbeam conflict V2 required to move towards share XPCS/speckle analysis for CHX/CSX
Projects
None yet
Development

No branches or pull requests

4 participants