Difference between revisions of "Grace/C3/Data-Fitting/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
 
{|border=1
 
{|border=1
 
+
||'''Visual Cue'''
|-
+
||'''Narration'''
|| '''Visual Cue'''
+
|| '''Narration'''
+
  
 
|-
 
|-
Line 24: Line 21:
 
|| To record this tutorial, I am using
 
|| To record this tutorial, I am using
 
* '''Ubuntu Linux''' 16.04 OS
 
* '''Ubuntu Linux''' 16.04 OS
* '''Grace''' 5.1.25
+
* '''Grace''' 5.1.25 and
 
* '''Gedit''' 3.18.3
 
* '''Gedit''' 3.18.3
  
Line 40: Line 37:
 
|| * Data fitting is a process to find a mathematical relation between two variables.
 
|| * Data fitting is a process to find a mathematical relation between two variables.
 
* An equation is used to describe the XY dataset pair.
 
* An equation is used to describe the XY dataset pair.
 +
 +
|-
 +
||'''Slide Number 6'''
 +
'''Data fitting'''
 +
||
 
* Using an iterative process, the coefficients are optimized.
 
* Using an iterative process, the coefficients are optimized.
 
* The process returns the best possible coefficients for the equation.
 
* The process returns the best possible coefficients for the equation.
Line 48: Line 50:
  
 
|-
 
|-
|| Hover mouse over file, '''line-data-fit.txt'''.
+
|| Hover mouse over file, '''line-fit.txt'''.
 
|| Notice the file, '''line-fit.txt'''.
 
|| Notice the file, '''line-fit.txt'''.
This file is provided to you in the '''codefiles''' link.  
+
 
 +
This file is provided to you in the '''Code Files''' link.  
 +
 
 
I have downloaded, extracted and saved the file to the '''Desktop''' directory.
 
I have downloaded, extracted and saved the file to the '''Desktop''' directory.
  
 
|-
 
|-
|| Show screenshot of '''Grace read-sets''' dialogue box.
+
|| Show screenshot of '''Grace read-sets''' dialog box.
 
|| Next, open the '''Grace''' program and load this file to plot an '''XY''' graph.
 
|| Next, open the '''Grace''' program and load this file to plot an '''XY''' graph.
  
Line 63: Line 67:
 
|-
 
|-
 
|| Hover mouse over the data.
 
|| Hover mouse over the data.
|| The data points look scattered around a straight line.
+
|| Next I will format the plot.
Next I will format the plot.
+
  
 
|-
 
|-
Line 73: Line 76:
 
|| Move the cursor along the data points.
 
|| Move the cursor along the data points.
 
|| The data points do not lie on a straight line.  
 
|| The data points do not lie on a straight line.  
They are spread around an imaginary line, in the xy plane.
+
 
 +
The data points look scattered around a straight line.
  
 
|-
 
|-
 
|| Cursor on the graph.
 
|| Cursor on the graph.
|| Next, we will fit this data to a straight line.
+
|| We will fit this data to a straight line.
 +
 
 
For a straight line, this is process is called '''linear regression'''.
 
For a straight line, this is process is called '''linear regression'''.
  
 
|-
 
|-
|| '''Slide Number 6'''
+
|| '''Slide Number 7'''
 
'''Equation in two variables'''
 
'''Equation in two variables'''
 
|| A straight line is described by an equation in two variables,
 
|| A straight line is described by an equation in two variables,
The equation has the form,y equals mx+c .
+
 
 +
The equation has the form, y equals mx+c.
 +
 
 
Here, m is the slope of the line and c is the intercept.  
 
Here, m is the slope of the line and c is the intercept.  
  
Line 95: Line 102:
 
|| Choose '''Regression'''.
 
|| Choose '''Regression'''.
 
|| Choose '''Regression''' from the list.
 
|| Choose '''Regression''' from the list.
A '''Regression''' dialogue box opens.
+
 
 +
A '''Regression''' dialog box opens.
  
 
|-
 
|-
Line 101: Line 109:
 
Choose dataset '''(S0)'''.
 
Choose dataset '''(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 and it is shown as ('''S0''').
+
 
 +
Currently only a single set is loaded and it is shown as '''S0'''.
 +
 
 
The next number is the number of points that are present in the dataset.
 
The next number is the number of points that are present in the dataset.
  
Line 107: Line 117:
 
|| Choose '''linear''' for '''Type of fit'''.
 
|| Choose '''linear''' for '''Type of fit'''.
 
|| If many datasets are loaded more sets will be seen, in the '''Apply to set''' box.  
 
|| If many datasets are loaded more sets will be seen, in the '''Apply to set''' box.  
 +
 
Choose '''linear''' for '''Type of fit'''.
 
Choose '''linear''' for '''Type of fit'''.
  
 
|-
 
|-
 
|| for '''Load''', choose '''Fitted values'''.
 
|| for '''Load''', choose '''Fitted values'''.
|| In the '''Load '''drop-down, choose '''Fitted values'''.
+
|| In the '''Load''' drop-down, choose '''Fitted values'''.
  
 
|-
 
|-
 
|| For '''restrictions''' choose '''None'''.
 
|| For '''restrictions''' choose '''None'''.
 
|| For '''restrictions''' choose '''None'''.
 
|| For '''restrictions''' choose '''None'''.
 +
 
If only part of the data set needs to be fitted, enter the required range.
 
If only part of the data set needs to be fitted, enter the required range.
  
 
|-
 
|-
 
|| Hover mouse over '''start load at''' and '''stop load at''' values.
 
|| Hover mouse over '''start load at''' and '''stop load at''' values.
 +
 
Click on '''Accept'''.
 
Click on '''Accept'''.
 
|| We can also specify the '''start load at''' and '''stop load at''' values in the form.  
 
|| We can also specify the '''start load at''' and '''stop load at''' values in the form.  
 +
 
I will leave it as is and will not make changes here.
 
I will leave it as is and will not make changes here.
 +
 
Click on '''Accept''' to run the data fitting.
 
Click on '''Accept''' to run the data fitting.
  
Line 128: Line 143:
 
|| Show the '''Grace console''' window, and output values.
 
|| Show the '''Grace console''' window, and output values.
 
|| The data fitting algorithm runs.
 
|| The data fitting algorithm runs.
 +
 
A '''Grace console''' window appears with mathematical details.
 
A '''Grace console''' window appears with mathematical details.
  
Line 133: Line 149:
 
|| Scroll in the '''Console''' window to show the values.
 
|| Scroll in the '''Console''' window to show the values.
 
|| We can see the equation used for the fitting.
 
|| We can see the equation used for the fitting.
 +
 
The output values of residual, slope, intercept and other parameters are seen.
 
The output values of residual, slope, intercept and other parameters are seen.
  
Line 138: Line 155:
 
|| Show on screen '''S(1)''' dataset showing in panel.
 
|| Show on screen '''S(1)''' dataset showing in panel.
 
|| The fitted line appears on the screen.
 
|| The fitted line appears on the screen.
 +
 
The fitted values are loaded in a different set, '''S1'''.
 
The fitted values are loaded in a different set, '''S1'''.
  
 
|-
 
|-
 
|| Click on '''File''', '''Save'''.
 
|| Click on '''File''', '''Save'''.
|| Click on '''File,''' '''Save''' to save the parameters.
+
|| Click on '''File''', '''Save''' to save the parameters.
  
 
|-
 
|-
Line 153: Line 171:
  
 
|-
 
|-
|| Click on '''accept''' and click to '''close'''.
+
|| Click on '''Apply''' and click to '''close'''.
|| Click on '''Apply''' and then click on '''Close''' to close the text box.
+
|| Click on '''Apply''' and then click on '''Close''' to close the dialog box.
  
 
|-
 
|-
Line 171: Line 189:
 
|-
 
|-
 
|| In select set form, select ('''S1''') data set.  
 
|| In select set form, select ('''S1''') data set.  
|| In the '''select set''' form, select ('''S1''') data set.
+
|| In the '''select set''' form, select '''S1''' data set.
 
This is the fitted data.
 
This is the fitted data.
  
Line 177: Line 195:
 
|| Right-click, select Edit, '''In spreadsheet '''option.
 
|| Right-click, select Edit, '''In spreadsheet '''option.
 
|| Right click to open the context menu.  
 
|| Right click to open the context menu.  
 +
 
Select '''Edit''', and in '''In spreadsheet''' option.  
 
Select '''Edit''', and in '''In spreadsheet''' option.  
 +
 
The '''Grace: Spreadsheet dataset editor''' appears.
 
The '''Grace: Spreadsheet dataset editor''' appears.
  
Line 183: Line 203:
 
|| Hover mouse over x and y columns.
 
|| Hover mouse over x and y columns.
 
|| Notice the x and corresponding fitted y values of the fitted data.
 
|| Notice the x and corresponding fitted y values of the fitted data.
These values are different from the input data .
+
 
 +
These values are different from the input data.
  
 
|-
 
|-
Line 196: Line 217:
 
|| Hover mouse over the two datasets.
 
|| Hover mouse over the two datasets.
 
|| The original data set and the fitted values are the 2 datasets in the graph.
 
|| The original data set and the fitted values are the 2 datasets in the graph.
 +
 
Datasets are labeled as ['''S0'''] for first set and ['''S1'''] for the second set.
 
Datasets are labeled as ['''S0'''] for first set and ['''S1'''] for the second set.
  
Line 201: Line 223:
 
|| Cursor on the graph.  
 
|| Cursor on the graph.  
 
|| We can add more datasets to this graph panel.
 
|| We can add more datasets to this graph panel.
  For this load the data using the '''Data, import, ASCII''' option from the menu.
+
 
 +
For this load the data using the '''Data, import, ASCII''' option from the menu.
  
 
|-
 
|-
|| Click on '''Close''' on the spreadsheet dataset editor and cursor on the interface.
+
|| Cursor on the plot window.
|| Close the Spreadsheet dataset editor.
+
|| Next, we will add legends to the plot.
Next, we will add legends to the plot.
+
  
 
|-
 
|-
Line 255: Line 277:
 
|| Open '''Graph appearance, Legend''' tab.
 
|| Open '''Graph appearance, Legend''' tab.
 
|| Next, open the '''Graph appearance''' window.
 
|| Next, open the '''Graph appearance''' window.
 +
 
In the window, click on the '''Legends''' tab, to format the '''legend''' fonts.
 
In the window, click on the '''Legends''' tab, to format the '''legend''' fonts.
  
Line 260: Line 283:
 
|| Move size slider to 70.
 
|| Move size slider to 70.
 
|| Under the '''text properties''', move the character size slider to 70.
 
|| Under the '''text properties''', move the character size slider to 70.
 +
 
The legends look very large compared to the graph.
 
The legends look very large compared to the graph.
 
|-
 
|-
Line 270: Line 294:
  
 
|-
 
|-
|| Click on the '''legend '''tab.
+
|| Click on the '''legend box'''tab.
 
|| Click on the '''legend box''' tab.
 
|| Click on the '''legend box''' tab.
  
Line 289: Line 313:
 
|-
 
|-
 
|| Click on '''Close'''.
 
|| Click on '''Close'''.
|| Then '''Close''' the dialogue box.
+
|| Then '''Close''' the dialog box.
  
 
|-
 
|-
|| Show screenshot of '''save as''' dialogue box with name filled in as '''regression.agr'''.
+
|| Show screenshot of '''save as''' dialog box with name filled in as '''regression.agr'''.
 
|| Now save the project in the '''Desktop''' directory.
 
|| Now save the project in the '''Desktop''' directory.
 +
 
I will use the file name '''regression dot agr'''.
 
I will use the file name '''regression dot agr'''.
  
 
|-
 
|-
 
|| Press '''Ctrl+Q'''
 
|| Press '''Ctrl+Q'''
|| Press '''Control Q''' or Click on '''File , Exit''' to exit '''Grace'''.
+
|| Press '''Control Q''' or Click on '''File, Exit''' to exit '''Grace'''.
  
 
|-
 
|-
Line 305: Line 330:
  
 
|-
 
|-
|| '''Slide Number 7'''
+
|| '''Slide Number 8'''
 
'''Summary'''
 
'''Summary'''
|| In this tutorial, we,
+
|| In this tutorial we,
* Performed data fitting of a straight line.
+
* Performed data fitting for a straight line.
* Added two datasets to a graph panel.
+
* Added two datasets in the graph panel.
 
* Added legends to the plot and  
 
* Added legends to the plot and  
 
* Formatted the legend properties.
 
* Formatted the legend properties.
  
 
|-
 
|-
|| '''Slide Number 8'''
+
|| '''Slide Number 9'''
 
'''Assignment'''
 
'''Assignment'''
 
|| For assignment activity, please do the following.
 
|| For assignment activity, please do the following.
* Two assignment files are provided in the codefiles link as seen here.
+
* Two assignment files are provided in the Code files link.
parabola1.txt parabola2.txt
+
(parabola1.txt & parabola2.txt)
 
* Plot them in the same graph panel.
 
* Plot them in the same graph panel.
* Perform Quadratic regression on the '''parabola1.txt''' file
+
* Perform quadratic regression on the '''parabola1.txt''' file.
 
+
  
 
|-
 
|-
|| '''Slide Number 9'''
+
|| '''Slide Number 10'''
 
'''Assignment'''
 
'''Assignment'''
 
||  
 
||  
Line 336: Line 360:
  
 
|-
 
|-
|| '''Slide Number 10'''
+
|| '''Slide Number 11'''
 
'''Spoken Tutorial Project'''
 
'''Spoken Tutorial Project'''
 
|| This video summarizes the '''Spoken Tutorial Project'''.
 
|| This video summarizes the '''Spoken Tutorial Project'''.
Line 342: Line 366:
  
 
|-
 
|-
|| '''Slide Number 11'''
+
|| '''Slide Number 12'''
 
'''Spoken Tutorial workshops'''
 
'''Spoken Tutorial workshops'''
 
|| The '''Spoken Tutorial Project''' team:
 
|| The '''Spoken Tutorial Project''' team:
Line 350: Line 374:
  
 
|-
 
|-
|| '''Slide Number 12'''
+
|| '''Slide Number 13'''
 
'''Forum for specific questions:'''
 
'''Forum for specific questions:'''
 
|| Please post your timed queries in this forum.
 
|| Please post your timed queries in this forum.
  
 
|-
 
|-
|| '''Slide Number 13'''
+
|| '''Slide Number 14'''
 
'''Acknowledgement'''
 
'''Acknowledgement'''
 
|| Spoken Tutorial Project is funded by '''NMEICT, MHRD''', Government of India.
 
|| Spoken Tutorial Project is funded by '''NMEICT, MHRD''', Government of India.

Latest revision as of 16:15, 28 October 2020

Visual Cue Narration
Slide Number 1

Title Slide

Welcome to the tutorial on Data fitting in Grace.
Slide Number 2

Learning Objectives

In this tutorial, we will
  • Fit a given set of data points to a linear equation
  • Add two datasets to a graph panel
  • Add legends and format the legend properties
Slide Number 3

System and Software Requirement

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

Pre-requisites https://spoken-tutorial.org

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

Data fitting

* Data fitting is a process to find a mathematical relation between two variables.
  • An equation is used to describe the XY dataset pair.
Slide Number 6

Data fitting

  • Using an iterative process, the coefficients are optimized.
  • The process returns the best possible coefficients for the equation.
Go to Desktop. Go to Desktop.
Hover mouse over file, line-fit.txt. Notice the file, line-fit.txt.

This file is provided to you in the Code Files link.

I have downloaded, extracted and saved the file to the Desktop directory.

Show screenshot of Grace read-sets dialog box. Next, open the Grace program and load this file to plot an XY graph.
Show screenshot of XY data set, and autoscale data. Choose XY data set, and autoscale data.
Hover mouse over the data. Next I will format the plot.
Show screenshot for : change the symbol, size, pattern. choose filled circle adjust size to 35. I have changed the symbols, line style, tick marks and axis labels.
Move the cursor along the data points. The data points do not lie on a straight line.

The data points look scattered around a straight line.

Cursor on the graph. We will fit this data to a straight line.

For a straight line, this is process is called linear regression.

Slide Number 7

Equation in two variables

A straight line is described by an equation in two variables,

The equation has the form, y equals mx+c.

Here, m is the slope of the line and c is the intercept.

Go to Data,Transformations. Go to Data and select Transformations.

Notice the available options.

Choose Regression. Choose Regression from the list.

A Regression dialog box opens.

Hover mouse over S(0).

Choose dataset (S0).

Choose the data set of interest from Apply to set.

Currently only a single set is loaded and it is shown as S0.

The next number is the number of points that are present in the dataset.

Choose linear for Type of fit. If many datasets are loaded more sets will be seen, in the Apply to set box.

Choose linear for Type of fit.

for Load, choose Fitted values. In the Load drop-down, choose Fitted values.
For restrictions choose None. For restrictions choose None.

If only part of the data set needs to be fitted, enter the required range.

Hover mouse over start load at and stop load at values.

Click on Accept.

We can also specify the start load at and stop load at values in the form.

I will leave it as is and will not make changes here.

Click on Accept to run the data fitting.

Show the Grace console window, and output values. The data fitting algorithm runs.

A Grace console window appears with mathematical details.

Scroll in the Console window to show the values. We can see the equation used for the fitting.

The output values of residual, slope, intercept and other parameters are seen.

Show on screen S(1) dataset showing in panel. The fitted line appears on the screen.

The fitted values are loaded in a different set, S1.

Click on File, Save. Click on File, Save to save the parameters.
Show the opened Grace: Save logs. The Grace: Save logs window opens.
Type line-regression.txt in Save to file. In Save to file text box, type the filename as line-regression.txt.
Click on Apply and click to close. Click on Apply and then click on Close to close the dialog box.
Close Grace:Console by File, Close or Esc Close the Grace Console by File, Close or press theEsc key.
Click on Close in Regression window. Click on Close in the Regression window.
Double click on the line in the graph. Double click on the line in the graph.

Grace Set appearance window opens.

In select set form, select (S1) data set. In the select set form, select S1 data set.

This is the fitted data.

Right-click, select Edit, In spreadsheet option. Right click to open the context menu.

Select Edit, and in In spreadsheet option.

The Grace: Spreadsheet dataset editor appears.

Hover mouse over x and y columns. Notice the x and corresponding fitted y values of the fitted data.

These values are different from the input data.

Hover mouse over the fitted line. This line fits the input data best, with a linear equation.
Close the Spreadsheet dataset Editor. Close the Spreadsheet dataset Editor.
Hover mouse over the two datasets. The original data set and the fitted values are the 2 datasets in the graph.

Datasets are labeled as [S0] for first set and [S1] for the second set.

Cursor on the graph. We can add more datasets to this graph panel.

For this load the data using the Data, import, ASCII option from the menu.

Cursor on the plot window. Next, we will add legends to the plot.
Double click on the line to open Set Appearance window. Open the Set Appearance window and choose the dataset S0.
Type Data in String field.

Click on Apply.

Under Legend, in the String field, type Data as the legend label.

Click on Apply.

Choose S1 dataset. Next choose S1 dataset from the Select set data form.
Type Fitted data for the legend string and click on Apply. Here, I will type Fitted data for the legend and click on Apply.
Click on Close to close Set Appearance window. Close the Set Appearance window.
Cursor the the legend. For some users, the legend position may be outside the graph border.
Cursor in the legend box and press Ctrl+L . To reposition the legends, place the cursor in the legend box.

Then press Control and L keys together.

Show the cursor change on the screen. The cursor changes to a pointer.
Left click and drag the legend box to the desired position. Left click and drag the legend box to the desired position.
Press Enter and then press Esc key. Then, press Enter.

Press the Escape key to exit the movement mode.

Open Graph appearance, Legend tab. Next, open the Graph appearance window.

In the window, click on the Legends tab, to format the legend fonts.

Move size slider to 70. Under the text properties, move the character size slider to 70.

The legends look very large compared to the graph.

Click on the font drop-down. I will retain the font type as Times-Roman.
Click on Apply. Click on Apply to apply the changes.
Click on the legend boxtab. Click on the legend box tab.
Hover mouse next to Legend location. We can also specify the position of the legend in the location section.

I will leave it as is.

In pattern drop-down, choose None. In the Frame line section, for Pattern, I will choose None.
Click on Apply. Click on Apply.

This will remove the legend frame box.

Click on Close. Then Close the dialog box.
Show screenshot of save as dialog box with name filled in as regression.agr. Now save the project in the Desktop directory.

I will use the file name regression dot agr.

Press Ctrl+Q Press Control Q or Click on File, Exit to exit Grace.
Let’s summarize.
Slide Number 8

Summary

In this tutorial we,
  • Performed data fitting for a straight line.
  • Added two datasets in the graph panel.
  • Added legends to the plot and
  • Formatted the legend properties.
Slide Number 9

Assignment

For assignment activity, please do the following.
  • Two assignment files are provided in the Code files link.

(parabola1.txt & parabola2.txt)

  • Plot them in the same graph panel.
  • Perform quadratic regression on the parabola1.txt file.
Slide Number 10

Assignment

  • Load the fitted data in the graph.
  • Add legend strings and reposition them inside the graph panel.
  • Format the appearance of the three datasets to distinguish them.
Show the glimpse of assignment. Your completed assignment may look similar to this.
Slide Number 11

Spoken Tutorial Project

This video summarizes 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 NMEICT, MHRD, Government of India.

More information on this mission is available at this link.

This is Rani from IIT Bombay.

Thank you for joining.

Contributors and Content Editors

Madhurig, PoojaMoolya, Ranipv076