LSSTDESC / stream_sim

Simple stellar stream simulation tools.
MIT License
1 stars 1 forks source link

inverse_transform_sample #1

Closed kadrlica closed 1 year ago

kadrlica commented 1 year ago

@psferguson I thought I could construct a trivial stream that is uniform between -9 < phi1 < 9 with something like this:

phi1,phi2,nstars,width
-9.0,0.0,1.5,0.1
+0.0,0.0,1.5,0.1
+9.0,0.0,1.5,0.1

However, the CDF for this stream is array([0.33333333, 0.66666667, 1. ]), which means that the interpolator function is undefined for x_new < 0.333... It seems that this was causing trouble before and was dealt with here: https://github.com/LSSTDESC/stream_sim/blob/b988c0f497da99831557f2ba52148ba55228c721/example_generate_pal5.py#L18-L21

but I think a more robust example is the inverse sampler in ugali, which explicitly inserts a 0 at the beginning of the cdf: https://github.com/DarkEnergySurvey/ugali/blob/82abffcc92bddf830d89f85cb3966870f7d9f720/ugali/analysis/imf.py#L80-L83

I'll test this out on my version and see how it goes...

kadrlica commented 1 year ago

This should be superseded by #3.