\(\renewcommand\AA{\unicode{x212B}}\)
Exercise 5¶
The aim of this exercise is to implement a simple linear fitting function defined as:
The function should have 2 parameters:
- A0: intercept with the y-axis.
- A1: gradient of the function.
Define a class called PyLinearFunction
- Add an - initfunction that declares the two parameters.
- Add a - function1Dfunction that returns the y values for the given x values as a numpy array.
- Add the appropriate line to register it with Mantid. 
To test:
- Execute your code in the script window to register the function with Mantid. 
- Load file GEM38370_Focussed_Legacy.nxs. 
- Plot spectrum number 5. 
- Activate the fitting tool. 
- Right click on the plot and select “Add Other Function…”. 
- Select - PyLinearFunction.
- Change - StartXto 0.1 and- EndXto 2.0
- Click Fit! 
Once finished check your answer with the provided Exercise 5 Solutions