Tutorial

These instructions assume that you have already successfully completed parts 1 through 5 of the JAS tutorial.

Part 10: Fitting Functions to Data

Tutorial parts 1 through 5 showed you some of the valuable functions of JAS while performing a local job for data analysis. This portion of the tutorial will build on that knowledge by showing you how to fit functions to your JAS histograms. Please note that whether your job is a local/remote event generation job, or a local/remote data analysis job, the process for fitting functions to your plots are the same.

Selecting Functions

Java Analysis Studio comes with a number of default functions that can be displayed on most plots containing histograms (functions cannot be added to a string-binned histogram).  Most of the default  functions are fittable. Java Analysis Studio keeps a function registry where it holds all of the functions that can be added to a plot.  The first time you use Java Analysis Studio, the default functions will be registered.  If you wish define your own functions or add/ remove  functions from the list, see the help documentation provided for these topics.  Your modifications to the function registry will be saved and loaded next time the application starts if you have selected the 'Save registries' box in the 'Defaults' tab of the 'Options' dialog.  By default, this option is selected.

To use functions in data analysis,

  • Select the plot you want to add a function to by clicking the mouse on that plot. A blue frame indicates the selected plot.
  • You can add a function to the plot in three ways.
    • The first way is to select the 'Add Function' submenu from the popup menu (when opened from a histogram plot).  You will see a list of the functions in the function registry.  Select one and it will be added.
    • The second way is to access the same 'Add Function' submenu, which is also located in the 'Functions' submenu of the 'Histogram' menu.
    • The third way is to open the 'Properties' dialog from either the popup menu (when opened from a histogram plot) or the 'Histogram' menu.  Select the 'Functions' tab, and click on the 'Add' button.
  • Some functions have advanced options.  These are options specific to a certain function, such as a spline function's smoothness or a polynomial function's order.   The 'Advanced Options...' button on the 'Functions' tab of the 'Properties' dialog is active when one such function is selected.  Click it to open a dialog box that allows you to set special options for the selected function.  Another way to open the advanced options dialog is to select the function from the 'Advanced Options' submenu of the popup menu (when opened from a histogram plot).  See the documentation on advanced options for more information on defining a function that allows the user advanced options.

Top

Fitting Functions

Java Analysis Studio comes with a least-squares fitter.  Like functions, fitters are stored in a registry and you can add and remove fitters from the registry. The fitter registry will be saved and loaded next time the application starts if the 'Save registries' box in the 'Defaults' tab of the 'Options' dialog is selected, which it is by default.  To define your own fitter, see the help documentation. See also the section on the default fitter.

There are three ways to fit a curve to data. You can fit to histograms, but not to scatter plots.

  • The first way is to select the 'Fit' submenu from the popup menu (when activated on a histogram plot). The 'Fit' submenu will only be active if there is at least one fittable function that is not fit already and one data set on the selected plot.  If there are multiple data sets, you will first be asked to select which one you want the curve to be fit to.  You will then be asked which curve you want to be fit to that data set.   To look at the parameters of the fit after fitting a curve in this way, you will have to select the 'Functions' tab on the 'Properties' dialog and select the function you have just fit. The parameters are displayed on a table there.
  • The second way is to access the same 'Fit' submenu from the 'Functions' submenu of the 'Histogram' menu.  When a fitter that was executed in these two ways is finished, the chi squared value for the fit will be displayed in the lower left corner of the application frame.  To look at the parameters of the fit after fitting a curve in this way, you will have to select the 'Functions' tab on the 'Properties' dialog and select the function you have just fit.  The parameters are displayed on a table there.
  • The third way to fit a curve to data is to select the 'Functions' tab on the 'Properties' dialog, and select the 'Fit' check box.  The check box will only be enabled if a fittable function has been selected.  The new fit parameters visible are on the same pane.

The fitter should stay linked to the data as you have set it and should re-fit the curve each time the data change.  If the function has handles and you move one of them manually, the fit will be cleared and will no longer update with the data.


Top

Return to Tutorial Part 1: Creating a New Job

Return to Tutorial Part 6: Further Explorations into JAS