Skip to content

Commit

Permalink
Moved the chi2 calculation to Signal.py
Browse files Browse the repository at this point in the history
  • Loading branch information
lmauviard committed Dec 6, 2024
1 parent d5c10aa commit d95c171
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion xpsi/PostProcessing/_residual.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ def add_pulses( self ):
double_pulse_model = _np.concatenate( (pulse_model , pulse_model) )

# Compute the chi squared
chi2 = _np.sum( (pulse_data - pulse_model)**2 / pulse_model )
chi2 = self._signal.chi2

# Plot pulse
self._ax_pulse.errorbar(x=doubles_phases,
Expand Down
19 changes: 19 additions & 0 deletions xpsi/Signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -733,6 +733,25 @@ def synthesise(self, phase_shifts, directory, **kwargs):
"""
raise NotImplementedError('Cannot synthesise data.')

@property
def chi2( self ):
""" Return the chi2 value for the current likelihood value or a given parameter vector if required.
:param list p:
Parameter vector, optional.
"""

# Get the pulse of data and model
pulse_data = self.data.counts.sum( axis = 0 )
pulse_model = self.expected_counts.sum( axis = 0 )

# Compute the chi squared
chi2 = _np.sum( (pulse_data - pulse_model)**2 / pulse_model )

return chi2



def construct_energy_array(num_energies, signals, max_energy=None):
Expand Down

0 comments on commit d95c171

Please sign in to comment.