Skip to content

Tutorial 4_ces_inference.ipynb with bias doesn't quite work yet #245

@SphericalCowww

Description

@SphericalCowww

Describe the bug
With the bias enabled as a fit parameter for ces inference, the likelihood gives nan.

To Reproduce
Load the following configuration file with:

parameter_definition:
  livetime:
    nominal_value: 5000
    ptype: livetime
    fittable: false
    description: Livetime in day

  fiducial_mass:
    nominal_value: 4
    ptype: needs_reinit
    fittable: false
    description: Fiducial mass in ton

  test_flat_rate_multiplier:
    nominal_value: 300
    ptype: rate
    fittable: true
    fit_limits:
      - 0
      - null
    parameter_interval_bounds:
      - 0
      - 50
    fit_guess: 300

  test_gaussian_rate_multiplier:
    nominal_value: 100
    ptype: rate
    fittable: true
    fit_limits:
      - 0
      - null
    parameter_interval_bounds:
      - 0
      - 50
    fit_guess: 100

  smearing_a:
    nominal_value: 50
    ptype: shape
    uncertainty: 0.05
    relative_uncertainty: true
    fittable: false
    blueice_anchors:
      - 50
    fit_limits:
      - 20
      - 80
    description: smearing shaping parameter

  smearing_b:
    nominal_value: 18
    ptype: shape
    uncertainty: 0.05
    relative_uncertainty: true
    fittable: false
    blueice_anchors:
      - 18
    fit_limits:
      - 6
      - 30
    description: smearing shaping parameter

  A:
    nominal_value: 0.18
    ptype: shape
    uncertainty: 0.05
    relative_uncertainty: true
    fittable: true
    blueice_anchors:
      - 0.06
      - 0.12
      - 0.18
      - 0.24
      - 0.30
    fit_limits:
      - 0.06
      - 0.30
    description: bais shaping parameter

  k:
    nominal_value: 0.01707
    ptype: shape
    uncertainty: 0.05
    relative_uncertainty: true
    fittable: false
    blueice_anchors:
      - 0.01707
    fit_limits:
      - 0.01
      - 0.03
    description: bias shaping parameter

  B:
    nominal_value: 0.0
    ptype: shape
    uncertainty: 0.01
    relative_uncertainty: true
    fittable: false
    blueice_anchors:
      - 0.0
    fit_limits:
      - -0.01
      - 0.01
    description: bias shaping parameter

  efficiency_constant:
    nominal_value: 1.0
    ptype: shape
    uncertainty: 0.01
    relative_uncertainty: false
    fittable: false
    blueice_anchors:
      - 1.0

likelihood_config:
  template_folder: null 
  likelihood_terms:
    - name: science_run_0
      default_source_class: alea.ces_source.CESTemplateSource
      likelihood_type: blueice.likelihood.UnbinnedLogLikelihood
      analysis_space:
        - ces: np.arange(0, 500, 1)
      minimal_energy_resolution: 0.1
      apply_efficiency: true
      efficiency_model: constant
      efficiency_parameters:
        - efficiency_constant
      apply_smearing: true
      smearing_model: gaussian
      smearing_parameters:
        - smearing_a
        - smearing_b
      apply_bias: true
      bias_model: arctan
      bias_parameters:
        - A
        - k
        - B
      livetime_parameter: livetime
      fiducial_mass_parameter: fiducial_mass
      slice_args: {}
      sources:
      - name: test_gaussian
        class: alea.ces_source.CESMonoenergySource
        peak_energy: 120
        parameters:
          - test_gaussian_rate_multiplier
          - smearing_a
          - smearing_b
          - A
          - k
          - B
          - efficiency_constant
      - name: test_flat
        class: alea.ces_source.CESFlatSource
        parameters:
          - test_flat_rate_multiplier
          - efficiency_constant

Then at the block, the ll_vals_c will give none:

confidence_level = 0.9
funcGrainSize = 10
xRange = [95, 120]
gs_rates = np.linspace(*xRange, funcGrainSize)

ll_vals_c = []
for gs_iter, gs_rate in tqdm(enumerate(gs_rates)):
    _, ll_val_c = dataFit_models.fit(test_gaussian_rate_multiplier=gs_rate)
    ll_vals_c.append(ll_val_c)
print(key, ll_vals_c)

Expected behavior
The fit of bias parameters should be similar to that to the fit of the smearing parameters.

Screenshots
If applicable, add screenshots to help explain your problem.

Image

Additional context
The code is not exactly 4_ces_inference.ipynb, and didn't produce a minimal code yet. However, hopefully, with the information above, it's enough to reproduce the bug.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions