Perform Parameter Estimation Using Liklihood Free Inference (LFI)

Perform Parameter Estimation Using Liklihood Free Inference (LFI)#

NMMA is adding machine learning functionality to its currently offered analysis methods. In this initial incorporation, a neural network approach will perform parameter estimation on light curves from BNS events. We will address the limitations first, and then provide an example run.

Limitations#

  1. Requires use of the Ka2017 model

  2. Requires use of 3 filters, optimally performs best when given ztfg,ztfr,ztfi

  3. Requires a time step dT of 0.25

Functionality#

  1. Returns a posterior when a light curve is given

  2. Returns a posterior when an injection file is given

Example#

Set up the environment#

In addition to installing the standard requirements.txt file, you must also run pip install -r ml_requirments.txt to fulfill the necessary package requirements.

Generate a simulation set#

First, we will create an injection file that describes our light curves. Running the following command line will generate a json file (injection.json). For Ka2017, this will include the parameters: luminosity_distance, timeshift, log10_mej, log10_vej, log10_Xlan, and geocent_time.

nmma_create_injection --prior-file ./priors/Ka2017 --eos-file ./example_files/eos/ALF2.dat --binary-type BNS --filename ./output/injection --n-injection 10 --original-parameters --extension json

We can generate light curves using this injection file with the following command. Here, we can define the start and ending time of the light curve, its filters, and we can add ztf-like noise.

lightcurve-generation --model Ka2017 --outdir outdir --outfile-type json --label test --tmin -2 --tmax 20 --dt 0.25 --filters ztfg,ztfr,ztfi --injection ./outdir/injection.json --injection-detection-limit 22.0,22.0,22.0 --ztf-uncertainties

There are two options when running the analysis. One can run it using the injection file directly, which will cause the analysis to generate a light curve on the fly. Or, the command will accept a pre-generated light curve. To run using LFI, the –sampler argument must be neuralnet. In the first example, we call the injection file and pass the first injection to the analysis. In the second, we take the first light curve generated by the injection file. Both of these commands will output a posterior plot to the provided outdir.

lightcurve-analysis --sampler neuralnet --model Ka2017 --outdir inferences --label with_inj --prior priors/Ka2017.prior --injection outdir/injection.json --injection-num 0 --dt 0.25

lightcurve-analysis --sampler neuralnet --model Ka2017 --outdir inferences --label with_data --data outdir/test_0.json --prior priors/Ka2017.prior