Difference between revisions of "Grace/C3/Fit-an-Exponential-Decay-Curve/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
 
Line 52: Line 52:
  
 
|-
 
|-
|| Show screenshot of open project dialogue box, loading the project.
+
|| Show screenshot of open project dialog box, loading the project.
 
|| Open the '''regression.arg''' project file from the '''Desktop''' directory.
 
|| Open the '''regression.arg''' project file from the '''Desktop''' directory.
  
Line 63: Line 63:
 
|-
 
|-
 
|| Go to '''Edit, '''Select''' Arrange''' '''graphs '''option.
 
|| Go to '''Edit, '''Select''' Arrange''' '''graphs '''option.
Cursor in '''Arrange graphs''' dialogue box.
+
Cursor in '''Arrange graphs''' dialog box.
 
|| Go to the '''Edit''' menu, select '''Arrange graphs''' option.
 
|| Go to the '''Edit''' menu, select '''Arrange graphs''' option.
  
Line 140: Line 140:
 
|-
 
|-
 
|| Choose '''Regression '''from the sub-menu.
 
|| Choose '''Regression '''from the sub-menu.
Point to the dialogue box.
+
Point to the dialog box.
 
|| Choose '''Regression''' from the sub-menu.
 
|| Choose '''Regression''' from the sub-menu.
  
New '''Regression dialogue box''' opens.
+
New '''Regression dialog box''' opens.
  
 
|-
 
|-
Line 176: Line 176:
 
|| The '''Grace: console''' dialog box opens.
 
|| The '''Grace: console''' dialog box opens.
  
Close the dialogue box and the generated log file.
+
Close the dialog box and the generated log file.
  
 
|-
 
|-
Line 194: Line 194:
 
I will not save the details of the data fitting.  
 
I will not save the details of the data fitting.  
  
I will close the dialogue box.
+
I will close the dialog box.
  
 
Let’s delete the fitted dataset loaded on the graph.
 
Let’s delete the fitted dataset loaded on the graph.
Line 200: Line 200:
 
|-
 
|-
 
|| Go to Edit, Set operations.
 
|| Go to Edit, Set operations.
|| Go to '''Edit''' menu and open the '''Set Operations''' dialogue box.
+
|| Go to '''Edit''' menu and open the '''Set Operations''' dialog box.
  
 
|-
 
|-
Line 214: Line 214:
 
|-
 
|-
 
|| Click on '''OK'''.
 
|| Click on '''OK'''.
|| A '''warning popup''' dialogue box opens to confirm the process.
+
|| A '''warning popup''' dialog box opens to confirm the process.
  
 
Click on '''OK''' to kill the dataset.
 
Click on '''OK''' to kill the dataset.
Line 224: Line 224:
 
|-
 
|-
 
|| Click on '''Close'''.
 
|| Click on '''Close'''.
|| I will click on '''Close''', to close the dialogue box.
+
|| I will click on '''Close''', to close the dialog box.
  
 
You may explore further if desired.
 
You may explore further if desired.
Line 244: Line 244:
 
|-
 
|-
 
|| Click on '''Close'''.
 
|| Click on '''Close'''.
|| Click on '''Close''', to close the dialogue box.
+
|| Click on '''Close''', to close the dialog box.
  
 
I will demonstrate to set up '''non-linear regression''' process.  
 
I will demonstrate to set up '''non-linear regression''' process.  
Line 357: Line 357:
 
|-
 
|-
 
|| Click on '''Close'''.
 
|| Click on '''Close'''.
|| Click on '''Close''', to close the dialogue box.
+
|| Click on '''Close''', to close the dialog box.
  
 
|-
 
|-

Latest revision as of 16:17, 28 October 2020

Visual Cue Narration
Slide Number 1

Title Slide

Welcome to the tutorial on Fit an exponential Decay Curve.
Slide Number 2

Learning Objectives

In this tutorial, we will learn to,
  • Add multiple graph panels to the canvas
  • Remove dataset from the graph panel and
  • Fit a given set of data points with non-linear regression method.
Slide Number 3

System and Software Requirement

To record this tutorial, I am using
  • Ubuntu Linux 16.04 OS
  • Grace 5.1.25
  • Gedit 3.18.3
Slide Number 4

Pre-requisites

To follow this tutorial,
  • Learner must be familiar with the Grace interface.
  • For pre-requisite tutorials, please visit this site.
Slide Number 5

Code Files

  • Two input files used in this tutorial are provided in the code files link.
  • Please download and extract the files.


Show Desktop screenshot with exponential.txt file icon. I have downloaded and saved them on my Desktop.
Open Grace. I have opened the Grace interface.
Click on File, Open. Click on File, Open to open a project.
Show screenshot of open project dialog box, loading the project. Open the regression.arg project file from the Desktop directory.
Point to the straight line graph. A straight line graph is plotted on this plot window.

Let's add another graph panel to the canvas.

Go to Edit, Select Arrange graphs option.

Cursor in Arrange graphs dialog box.

Go to the Edit menu, select Arrange graphs option.

The Arrange graphs window opens.

In Matrix, Cols, increase the number of rows to 2. Under Matrix, in the Cols drop-down increase the number of columns to 2.
Click on Apply, then click Close. Click on Apply and then on click Close.

Notice that one more graph panel is added to the white canvas.

Resize both graph panels to two squares. Notice that the graph panels are now elongated.

I will resize the graph panels to two squares as seen on the screen.

Reposition the legends in G0 graph. I will also reposition the legends in the canvas.
Click on the new Graph to select . To select a graph, click on it.

The selected graph is highlighted with the black squares on the corners.

Select the newly added graph panel. Select the newly added graph panel.
Go to File, Import, ASCII.

Go to Desktop folder and navigate to select the saved file exponential.txt.

Go to Data, Import, ASCII in the menu.

Select the file, exponential.txt from Desktop directory.

Click on Ok to plot the graph.

Click on Cancel to close the window.

Load the data as an XY dataset.

Click on Ok to plot the graph.

Then, click on Cancel to close the window.

Cursor on the graph. From a visual inspection, the data points follow an exponential decay curve.
Double click on the graph line. Double click on the curve to open the set appearance window.
Show screenshot of formatted graph. Add symbols of your choice and choose no line.

This helps to differentiate the fitted data from the starting dataset.

Go to Data, Transformations. Go to Data and select Transformations.
Hover the mouse on the sub-menu. A sub-menu opens with many options for data fitting.
Choose Regression from the sub-menu.

Point to the dialog box.

Choose Regression from the sub-menu.

New Regression dialog box opens.

Show dataset on the screen, Choose G1 (S0). Choose the data set of interest from Apply to set.

Currently only a single set is loaded, shown as (S0).

It is in the graph panel G1 and set is named S0.

Choose Exponential for Type of fit. Choose Exponential for Type of fit.

This drop-down has few choices with sample functions to do data fitting.

For Load, choose Fitted values. In the Load drop-down, choose Fitted values.
For restrictions choose None. For restrictions choose None.
Click on Accept. Click on Accept to run the data fitting.
Point to the dialog box.

Close the dialog box.

The Grace: console dialog box opens.

Close the dialog box and the generated log file.

Cursor on the graph. Notice the fitted data in the graph.
Hover mouse over the curve. Often, the data may follow a complex mathematical equation.

Then, we have to define the equation and do a non-linear regression.

Cursor on the graph. I will demonstrate it.

I will not save the details of the data fitting.

I will close the dialog box.

Let’s delete the fitted dataset loaded on the graph.

Go to Edit, Set operations. Go to Edit menu and open the Set Operations dialog box.
Select Graph G1 in the Source section. In the Source section, select Graph G1 as seen.
Select, G1. S1 set. In the set section, select the set G1 S1.

Right click to open the context menu and choose Kill data.

Click on OK. A warning popup dialog box opens to confirm the process.

Click on OK to kill the dataset.

Hover mouse over the possible set operations. Different types of set operations are possible in this window.
Click on Close. I will click on Close, to close the dialog box.

You may explore further if desired.

Cursor on the graph. Notice that the fitted data is removed from the graph.
Show set appearance window. We can also access the context menu from the set appearance window.
Select a set and right click to show context menu. Select the desired dataset from the Select set form.

Right click to open the context menu and choose Kill data to remove the data.

Click on Close. Click on Close, to close the dialog box.

I will demonstrate to set up non-linear regression process. .

Slide Number 6

Steps for Data Fitting

  • For data fitting, select an equation to fit the data.
  • Make an initial guess for the value of the coefficients.
  • Run the data fitting algorithm.
Slide Number 7

Steps for Data Fitting

  • Convergence is usually obtained with few iterations.
  • Examine the output parameters for goodness of the fit.
  • Plot the function and the data together for visual representation.
Go to Data , Transformations, Non-linear curve fitting. Go to Data, Transformations and select Non-linear curve fitting.
Point to In the Main tab. Under the Main tab, we will enter the desired equation.
Select 2 for Parameters.

Point to the five parameters in the form.

Select 2 for Parameters.

Two parameters A0 and A1 appear in the form below.

Type, y= A0 * exp(A1*x) I will use an exponential decay curve as seen on the interface.

Let’s type the equation as seen.

Set Iterations to 20 using the black, up triangle button. There is also an option to input starting values and define bounds.

Set Iterations to 20 using the black, up triangle button as seen on the screen.

Cursor on A0, A1. Set A0 and A1 initial guess.
Cursor on the graph. We can make an educated guess for starting values of A0 and A1 from the graph.

From the graph, A0 could be around point four to point 5.

Value of A1 is around -0.25.

Input 0.4 for A0 and -0.2 for A1. Set the initial guess values of the coefficients slightly away.

Then, the iterative process in the regression algorithm can be observed.

Input 0.4 for A0 and -0.2 for A1 as initial guess.

Hover mouse on apply bounds check box. You may apply bounds check box if necessary by clicking on the bounds buttons.
In the Set section, select the set, G1 S0. In the Set section, select the set, G1 S0.
Click Apply and to run iterations. Click on Apply and to run the iterations.

The algorithm runs.

Hover mouse over the parameters. In this window, fitting parameter Chi-square is seen.

Correlation coefficient, RMS, relative error and Theil coefficient are also seen.

Cursor on chi square. Examine the chi-square values obtained.

Low chi-square means, the resulting function is a good fit for the data.

Cursor on the output values of residual, RMS. Residual is the difference between the observed and the fitted values.

The sum of squares of residuals is minimized in the least square fitting method.

Click on File, Save. You may note down the values or save the results.

Click on File, Save option to save the results.

In the form, type 'fitted-values.txt' and click on Apply. A Grace:save logs form appear prompting to give a file name.

In the form, type 'fitted-values.txt' and click on Apply.

Click on Close. Click on Close, to close the dialog box.
Click on File, close to close Grace:console window, Use File, close to close the Grace:console window.
Cursor on graph. A curve generated from data fitting, is automatically loaded on the graph.

The fitted curve traverse between the given data points.

Click on Close to close the non-linear curve fitting window. Click on close to close the non-linear curve fitting window.
Click on File, save. Click on File, save to save the project.
Click on File, Exit. From top menu, choose File, exit to exit Grace.
Slide Number 8

Summary

Now, let’s summarize.

In this tutorial, we

  • Added multiple graph panels in the canvas
  • Learned to delete data sets from a graph panel
  • Performed non-linear regression on an exponential decay curve.
Slide Number 9

Assignment 1 y= a0.x2 + a1.x + a2

For assignment, please do the following.
  • Fit the data given in the file assignment1.txt to a parabola.
  • Use an equation of the type, as seen here.
Slide Number 10

Assignment 2

* Fit the given data in the file assignment2.txt, to atan(x).
Glimpse of assignment. Your complete assignment look similar to this.
Slide Number 11

Spoken Tutorial Project

This video summarises the Spoken Tutorial Project.

Please download and watch it.

Slide Number 12

Spoken Tutorial workshops

The Spoken Tutorial Project team:
  • conducts workshops and
  • gives certificates.

For more details, please write to us.

Slide Number 13

Forum for specific questions:

Please post your timed queries in this forum.
Slide Number 14

Acknowledgement

Spoken Tutorial Project is funded by MHRD, Government of India.


This is Rani, from IIT Bombay.

Thank you for joining.

Contributors and Content Editors

Madhurig, PoojaMoolya, Ranipv076, Snehalathak