Skip to content

Commit

Permalink
added a test on the skewness of the Skewed and Cauchy
Browse files Browse the repository at this point in the history
  • Loading branch information
clara-escanuela committed Apr 15, 2023
1 parent a33651b commit c4f0c76
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion ctapipe/image/tests/test_toy.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def test_intensity(seed, monkeypatch, prod5_lst):


def test_skewed(prod5_lst):
from ctapipe.image.toymodel import SkewedGaussian
from ctapipe.image.toymodel import SkewedCauchy, SkewedGaussian

# test if the parameters we calculated for the skew normal
# distribution produce the correct moments
Expand All @@ -84,6 +84,18 @@ def test_skewed(prod5_lst):
assert np.isclose(var, length.to_value(u.m) ** 2)
assert np.isclose(skew, skewness)

model = SkewedCauchy(
x=x, y=y, width=width, length=length, psi=psi, skewness=skewness
)
model.generate_image(geom, intensity=intensity, nsb_level_pe=5, rng=rng)

a, loc, scale = model._moments_to_parameters()
mean, var, skew = skewnorm(a=a, loc=loc, scale=scale).stats(moments="mvs")

assert np.isclose(mean, 0)
assert np.isclose(var, length.to_value(u.m) ** 2)
assert np.isclose(skew, skewness)


def test_compare(prod5_lst):
from ctapipe.image.toymodel import Gaussian, SkewedGaussian
Expand Down

0 comments on commit c4f0c76

Please sign in to comment.