Difference between revisions of "Grace/C3/Fit-an-Exponential-Decay-Curve/English"
Line 34: | Line 34: | ||
|| Show '''Desktop''' screenshot with '''exponential.txt''' file icon. | || Show '''Desktop''' screenshot with '''exponential.txt''' file icon. | ||
|| Two input files used in this tutorial are provided in the '''Code files''' link. | || Two input files used in this tutorial are provided in the '''Code files''' link. | ||
+ | |||
I have downloaded and saved them on my '''Desktop'''. | I have downloaded and saved them on my '''Desktop'''. | ||
Line 41: | Line 42: | ||
|- | |- | ||
− | || Click on '''File, Open'''. | + | || Click on '''File''', '''Open'''. |
− | || Click on '''File, Open''' to open a project. | + | || Click on '''File''', '''Open''' to open a project. |
|- | |- | ||
Line 51: | Line 52: | ||
|| Point to the straight line graph. | || Point to the straight line graph. | ||
|| A straight line graph is plotted on this plot window. | || A straight line graph is plotted on this plot window. | ||
+ | |||
Let's add another graph panel to the canvas. | Let's add another graph panel to the canvas. | ||
Line 57: | Line 59: | ||
Cursor in '''Arrange graphs''' dialogue box. | Cursor in '''Arrange graphs''' dialogue box. | ||
|| Go to the '''Edit''' menu, select '''Arrange graphs''' option. | || Go to the '''Edit''' menu, select '''Arrange graphs''' option. | ||
+ | |||
The '''Arrange graphs''' window opens. | The '''Arrange graphs''' window opens. | ||
Line 66: | Line 69: | ||
|| Click on '''Apply''', then click Close. | || Click on '''Apply''', then click Close. | ||
|| Click on '''Apply''' and then on click '''Close'''. | || Click on '''Apply''' and then on click '''Close'''. | ||
+ | |||
Notice that one more graph panel is added to the white canvas. | Notice that one more graph panel is added to the white canvas. | ||
Line 71: | Line 75: | ||
|| Resize both graph panels to two squares. | || Resize both graph panels to two squares. | ||
|| Notice that the graph panels are now elongated. | || Notice that the graph panels are now elongated. | ||
+ | |||
I will resize the graph panels to two squares as seen on the screen. | I will resize the graph panels to two squares as seen on the screen. | ||
Line 80: | Line 85: | ||
|| Click on the new Graph to select . | || Click on the new Graph to select . | ||
|| To select a graph, click on it. | || To select a graph, click on it. | ||
+ | |||
The selected graph is highlighted with the black squares on the corners. | The selected graph is highlighted with the black squares on the corners. | ||
Line 88: | Line 94: | ||
|- | |- | ||
|| Go to '''File, Import, ASCII'''. | || Go to '''File, Import, ASCII'''. | ||
+ | |||
Go to '''Desktop''' folder and navigate to select the saved file '''exponential.txt'''. | Go to '''Desktop''' folder and navigate to select the saved file '''exponential.txt'''. | ||
|| Go to '''Data, Import, ASCII''' in the menu. | || Go to '''Data, Import, ASCII''' in the menu. | ||
+ | |||
Select the file,''' exponential.txt''' from '''Desktop''' directory. | Select the file,''' exponential.txt''' from '''Desktop''' directory. | ||
|- | |- | ||
|| Click on '''Ok''' to plot the graph. | || Click on '''Ok''' to plot the graph. | ||
+ | |||
Click on '''Cancel '''to close the window. | Click on '''Cancel '''to close the window. | ||
|| Load the data as an '''XY''' dataset. | || Load the data as an '''XY''' dataset. | ||
Click on '''Ok''' to plot the graph. | Click on '''Ok''' to plot the graph. | ||
+ | |||
Then, click on '''Cancel''' to close the window. | Then, click on '''Cancel''' to close the window. | ||
Line 110: | Line 120: | ||
|| Show screenshot of formatted graph. | || Show screenshot of formatted graph. | ||
|| Add '''symbols''' of your choice and choose no line. | || Add '''symbols''' of your choice and choose no line. | ||
+ | |||
This helps to differentiate the fitted data from the starting dataset. | This helps to differentiate the fitted data from the starting dataset. | ||
Line 124: | Line 135: | ||
Point to the dialogue box. | Point to the dialogue box. | ||
|| Choose '''Regression '''from the sub-menu. | || Choose '''Regression '''from the sub-menu. | ||
+ | |||
New '''Regression''' '''dialogue box''' opens. | New '''Regression''' '''dialogue box''' opens. | ||
Line 129: | Line 141: | ||
|| Show dataset on the screen, Choose '''G1 (S0)'''. | || Show dataset on the screen, Choose '''G1 (S0)'''. | ||
|| Choose the data set of interest from '''Apply to set'''. | || Choose the data set of interest from '''Apply to set'''. | ||
+ | |||
Currently only a single set is loaded, shown as '''(S0)'''. | Currently only a single set is loaded, shown as '''(S0)'''. | ||
Line 136: | Line 149: | ||
|| Choose '''Exponential''' for '''Type of fit'''. | || Choose '''Exponential''' for '''Type of fit'''. | ||
|| Choose '''Exponential''' for '''Type of fit'''. | || Choose '''Exponential''' for '''Type of fit'''. | ||
+ | |||
This drop-down has few choices with simple functions to do data fitting. | This drop-down has few choices with simple functions to do data fitting. | ||
Line 154: | Line 168: | ||
Close the dialog box. | Close the dialog box. | ||
|| The '''Grace: console''' dialog box opens. | || The '''Grace: console''' dialog box opens. | ||
+ | |||
Close the dialogue box and the generated log file. | Close the dialogue box and the generated log file. | ||
Line 163: | Line 178: | ||
|| Hover mouse over the curve. | || Hover mouse over the curve. | ||
|| Often, the data may follow a complex Mathematical equation. | || Often, the data may follow a complex Mathematical equation. | ||
− | Then, we have to define the equation | + | |
+ | Then, we have to define the equation and do a non-linear regression. | ||
|- | |- | ||
Line 169: | Line 185: | ||
|| I will demonstrate it. | || I will demonstrate it. | ||
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 dialogue box. | ||
+ | |||
Let’s delete the fitted dataset loaded on the graph. | Let’s delete the fitted dataset loaded on the graph. | ||
Line 183: | Line 201: | ||
|| Select, G1. S1 set. | || Select, G1. S1 set. | ||
|| In the '''set''' section, select the set '''G1 S1'''. | || In the '''set''' section, select the set '''G1 S1'''. | ||
+ | |||
Right click to open the '''context menu''' and choose '''Kill data'''. | Right click to open the '''context menu''' and choose '''Kill data'''. | ||
Line 188: | Line 207: | ||
|| Click on '''OK'''. | || Click on '''OK'''. | ||
|| A '''warning popup''' dialogue box opens to confirm the process. | || A '''warning popup''' dialogue box opens to confirm the process. | ||
+ | |||
Click on '''OK''' to kill the dataset. | Click on '''OK''' to kill the dataset. | ||
Line 197: | Line 217: | ||
|| Click on '''Close'''. | || Click on '''Close'''. | ||
|| I will click on '''Close''', to close the dialogue box. | || I will click on '''Close''', to close the dialogue box. | ||
+ | |||
You may explore further if desired. | You may explore further if desired. | ||
Line 210: | Line 231: | ||
|| Select a set and right click to show '''context menu'''. | || Select a set and right click to show '''context menu'''. | ||
|| Select the desired dataset from the '''Select set''' form. | || Select the desired dataset from the '''Select set''' form. | ||
− | Right click to open the '''context menu''' and choose '''Kill data''' to remove | + | |
− | the data. | + | Right click to open the '''context menu''' and choose '''Kill data''' to remove the data. |
|- | |- | ||
|| Click on '''Close'''. | || Click on '''Close'''. | ||
|| Click on '''Close''', to close the dialogue box. | || Click on '''Close''', to close the dialogue box. | ||
− | I will demonstrate to set up '''non-linear regression''' | + | |
+ | I will demonstrate to set up '''non-linear regression'''. | ||
+ | . | ||
|- | |- | ||
Line 235: | Line 258: | ||
|- | |- | ||
− | || Go to '''Data ,Transformations, Non-linear curve fitting'''. | + | || Go to '''Data''' , '''Transformations''', '''Non-linear curve fitting'''. |
− | || Go to '''Data,Transformations''' and select '''Non-linear curve fitting'''. | + | || Go to '''Data''', '''Transformations''' and select '''Non-linear curve fitting'''. |
|- | |- | ||
Line 246: | Line 269: | ||
Point to the five parameters in the form. | Point to the five parameters in the form. | ||
|| Select '''2''' for '''Parameters'''. | || Select '''2''' for '''Parameters'''. | ||
+ | |||
Two parameters '''A0''' to '''A1''' appear in the form below. | Two parameters '''A0''' to '''A1''' appear in the form below. | ||
Line 251: | Line 275: | ||
|| Type, '''y= A0 * exp(A1*x)''' | || Type, '''y= A0 * exp(A1*x)''' | ||
|| I will use an exponential decay curve as seen on the interface. | || I will use an exponential decay curve as seen on the interface. | ||
+ | |||
Let’s type the equation as seen. | Let’s type the equation as seen. | ||
Line 256: | Line 281: | ||
|| Set '''Iterations''' to 20 using the black, up triangle button. | || Set '''Iterations''' to 20 using the black, up triangle button. | ||
|| There is also an option to input starting values and define bounds. | || 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. | Set '''Iterations''' to 20 using the black, up triangle button as seen on the screen. | ||
Line 265: | Line 291: | ||
|| Cursor on the graph. | || Cursor on the graph. | ||
|| We can make an educated guess for starting values of '''A0''' and '''A1''' from 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. | From the graph, '''A0''' could be around point four to point 5. | ||
+ | |||
Value of '''A1''' is around -0.25. | Value of '''A1''' is around -0.25. | ||
Line 271: | Line 299: | ||
|| Input 0.4 for A0 and -0.2 for A1. | || Input 0.4 for A0 and -0.2 for A1. | ||
|| Set the initial guess values of the coefficients slightly away. | || Set the initial guess values of the coefficients slightly away. | ||
+ | |||
Then, the iterative process in the regression algorithm can be observed. | Then, the iterative process in the regression algorithm can be observed. | ||
+ | |||
Input 0.4 for '''A0''' and -0.2 for '''A1''' as initial guess. | Input 0.4 for '''A0''' and -0.2 for '''A1''' as initial guess. | ||
Line 285: | Line 315: | ||
|| Click '''Apply''' and to run iterations. | || Click '''Apply''' and to run iterations. | ||
|| Click on '''Apply''' and to run the iterations. | || Click on '''Apply''' and to run the iterations. | ||
+ | |||
The algorithm runs. | The algorithm runs. | ||
Line 290: | Line 321: | ||
|| Hover mouse over the '''parameters'''. | || Hover mouse over the '''parameters'''. | ||
|| In this window, fitting parameter '''Chi-square''' is seen. | || In this window, fitting parameter '''Chi-square''' is seen. | ||
+ | |||
'''Correlation coefficient, RMS, relative error''' and '''Theil coefficient''' are also seen. | '''Correlation coefficient, RMS, relative error''' and '''Theil coefficient''' are also seen. | ||
Line 295: | Line 327: | ||
|| Cursor on '''chi square'''. | || Cursor on '''chi square'''. | ||
|| Examine the '''chi-square''' values obtained. | || Examine the '''chi-square''' values obtained. | ||
+ | |||
Low '''chi-square''' means, the resulting function is a good fit for the data. | Low '''chi-square''' means, the resulting function is a good fit for the data. | ||
Line 300: | Line 333: | ||
|| Cursor on the output values of '''residual''', '''RMS'''. | || Cursor on the output values of '''residual''', '''RMS'''. | ||
|| '''Residual''' is the difference between the observed and the fitted values. | || '''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. | The '''sum of squares''' of residuals is minimized in the least square fitting method. | ||
Line 305: | Line 339: | ||
|| Click on '''File, Save'''. | || Click on '''File, Save'''. | ||
|| You may note down the values or save the results. | || You may note down the values or save the results. | ||
+ | |||
Click on '''File, Save''' option to save the results. | Click on '''File, Save''' option to save the results. | ||
Line 310: | Line 345: | ||
|| In the form, type ''''fitted-values.txt'''' and click on '''Apply'''. | || In the form, type ''''fitted-values.txt'''' and click on '''Apply'''. | ||
|| A '''Grace:save logs''' form appear prompting to give a file name. | || A '''Grace:save logs''' form appear prompting to give a file name. | ||
+ | |||
In the form , type ''''fitted-values.txt'''' and click on '''Apply'''. | In the form , type ''''fitted-values.txt'''' and click on '''Apply'''. | ||
Line 323: | Line 359: | ||
|| Cursor on graph. | || Cursor on graph. | ||
|| A curve generated from data fitting, is automatically loaded on the graph. | || A curve generated from data fitting, is automatically loaded on the graph. | ||
+ | |||
The fitted curve traverse between the given data points. | The fitted curve traverse between the given data points. | ||
Revision as of 15:26, 31 December 2019
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,
|
Slide Number 3
System and Software Requirement |
To record this tutorial, I am using
|
Slide Number 4
Pre-requisites |
To follow this tutorial,
|
Show Desktop screenshot with exponential.txt file icon. | Two input files used in this tutorial are provided in the Code files link.
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 dialogue 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 dialogue 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 dialogue box. |
Choose Regression from the sub-menu.
New Regression dialogue 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 is 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 simple 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 dialogue 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 dialogue 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 dialogue 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 dialogue 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 dialogue 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 dialogue box.
I will demonstrate to set up non-linear regression. . |
Slide Number 5
Steps for Data Fitting |
|
Slide Number 6
Steps for Data Fitting |
|
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 to 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 dialogue 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 7
Summary |
Now, let’s summarize.
In this tutorial, we
|
Slide Number 8
Assignment 1 y= a0.x2 + a1.x + a2 |
For assignment, please do the following.
|
Slide Number 9
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 10
Spoken Tutorial Project |
This video summarises the Spoken Tutorial Project.
Please download and watch it. |
Slide Number 11
Spoken Tutorial workshops |
The Spoken Tutorial Project team:
For more details, please write to us. |
Slide Number 12
Forum for specific questions: |
Please post your timed queries in this forum. |
Slide Number 13
Acknowledgement |
Spoken Tutorial Project is funded by MHRD, Government of India.
|
This is Rani, from IIT Bombay.
Thank you for joining. |