Calculation of the ChiSquare (χ2)

Get the ChiSquare

1.1 Introduction

The purpose of the ChiSquare plugin is to calculate the ChiSquare and the reduced ChiSquare for two sets of data.

1.2 Plugin Properties

Table 1.1 lists available plugin property names, along with their data type and purpose.


Parameter Name Data Type

Purpose




   
ExperimentalData TelluriumData

Data representing Experimental data.

ModelData TelluriumData

Data representing Model data.

NrOfModelParametersint

Number of model parameters used to create the model data.

ChiSquare double

The calculated ChiSquare.

ReducedChiSquare double

The calculated reduced ChiSquare.





Table 1.1: Plugin Properties

1.3 Plugin Events

This plugin does not use any plugin events.

1.4 The execute() function

The execute() function will attempt to calculate the ChiSquare, and the reduced ChiSquare, using data supplied by the user.

1.5 Python examples

1.5.1 Usage of the ChiSquare plugin

The python script below shows how to use the plugin.

 
1from teplugins import * 
2 
3try: 
4    modelPlugin     = Plugin("tel_test_model") 
5    noisePlugin     = Plugin("tel_add_noise") 
6    chiSquarePlugin = Plugin("tel_chisquare") 
7 
8    #Generate internal test data 
9    modelPlugin.execute() 
10    modelData = modelPlugin.TestData 
11    expData = modelPlugin.TestDataWithNoise 
12 
13    chiSquarePlugin.ExperimentalData = expData 
14    chiSquarePlugin.ModelData = modelData 
15    chiSquarePlugin.NrOfModelParameters = 1 
16 
17    chiSquarePlugin.execute() 
18 
19    chi = chiSquarePlugin.ChiSquare 
20    reduced_chi = chiSquarePlugin.ReducedChiSquare 
21 
22    print ChiSquare is:  + chi 
23    print Reduced ChiSquare is:  + reduced_chi 
24 
25except Exception as e: 
26    print Problem:  + e
Listing 1.1: ChiSquare plugin example.