Gnuplot/C2/Error-bars-and-data-fitting/English
Title of script: Error bars and Data fitting
Author: Rani Parvathy
Keywords: gnuplot, video tutorial, spoken tutorial, data fitting, regression, error bars
Visual Cue | Narration |
---|---|
Slide Number 1
Title Slide
Data fitting and error bars
|
Welcome to the tutorial on
Data fitting and error bars
|
Slide Number 2
Learning Objectives
|
In this tutorial, we will learn,
|
Slide Number 3
System and Software Requirement
|
Debian Linux
Gedit 3.22.0
and
Have Gnuplot 5.2.5 installed
|
Slide Number 4
Samson Microphone
|
To record audio, I am using Samson USB portable microphone was used.
The model number SAGOMIC
I bought it from amazon website, for about rupees four thousand
It may be available in other websites.
|
Slide Number 5
Pre-requisites
|
To follow this tutorial, learner’s must be familiar with,
Basic computer and internet skills
Concept of graphing
and
College level Mathematics skills
|
Slide Number 6
Pre-requisites
|
Please locate this tutorial on our web page, spoken hyphen tutorial dot org
Prerequisite spoken tutorials, if any, will be mentioned in this page
|
Go to Desktop. | First, we will first learn to incorporate error bars in a graph.
First, Go to Desktop.
I have a, x y yerror type data, in a text file.
|
Double click to open the file. | It is saved in Desktop directory for me.
Double click on the file icon to open it in a text editor.
The file opens in gedit for me.
This file is provided to you with the tutorial.
|
The first column is x data.
| |
Close gedit | Close gedit by clicking on the x-sign. |
Press ctrl alt t
cd ~/Desktop
|
Press ctrl alt t keys together to open a terminal.
|
ctrl+alt+T
>gnuplot
|
Open gnuplot.
|
Show qt on screen. | Set terminal as necessary.
For me it is already in qt.
|
Ctrl-l | I will clear screen with command control l.
This takes terminal prompt to top of the screen for clarity in video. |
First, let's plot the data to see the trend and for visual inspection. | |
plot 'error-bar.txt' using 1:2:3 with yerrorbars | Enter the plot command as seen on the screen. |
If error limits are on the x data, we can use, x error bars term for plotting.
| |
The colon 3 with y error bars in the plot command adds the error to the plot. | |
Hover mouse over decay curve. | Next, let's fit this graph to an equation. |
This data likely represent an exponential decay. | |
The points may be off the ideal curve due to measurement errors. | |
We will fit the given data points to an exponential decay function. | |
Let's see a few steps involved in fitting data points to an equation. | |
Slide Number 7
Steps in data fitting
Initial guess values for constants
Display the fitted data
|
First, define a function to represent the data
|
f(x) = a * exp(-k*x) | First, let's define the function.
Type f of x is equal to a times e to the power minus k x
Use the syntax as seen on the screen
|
Go to graphical window. | Let's make an educated initial guess for the initial guess values of a and k
Go to graphical window.
|
From the graph, I will place the initial value of a at one lakh fitfty thousand | |
For an exponential decay, I will place the initial guess of k around 0.5 | |
Close the graphical window and go to gnuplot terminal prompt. | |
a=150000
k=0.5
|
Enter commands to set the values of a and k
Enter a equal to fifteen hundred thousand
Enter k equal to zero point five
|
fit f(x) “error-bar.txt” using 1:2:3 via a,k | To fit the data use command as seen on the screen.
Fit space f of x space in double quotes error hyphen bar dot txt.
Then Space using space 1 colon 2 colon 3 via a comma k
|
If column 3 is not mentioned, the y axis uncertainties is not considered for data fitting. | |
The software does the fitting and gives output values. | |
Let's scroll up the screen. | |
I see an error , warning message on top | |
Notice a table with chi square and new values of a and k after each iteration. | |
Program reports, the fitting process converged after a few iterations.
It is 8 iteractions.
| |
Many fitting parameters are reported in the output.
Program reports, final sum of square of residuals.
| |
Notice, relative change in values after the last iteration.
The number is very small
| |
Degrees of freedom is 9 | |
The root mean square or RMS is around 0.17 | |
Updated values of a and k and their error in estimation is also shown. | |
The correlation matrix of variables is at the end of the output. | |
Now we have a function that fits the given data points. | |
Let's plot the data points and function together. | |
Then, we can see, how well the equation fit the given points.
I will clear the screen with command control l for clarity in video again.
| |
plot f(x) lw 2 title 'fitted data', "error-bar-fitting.txt" using 1:2:3 with yerrorbars pt 7 ps 1.5 notitle | Then, enter the plot command as seen on the screen.
|
I will modify to change legend as fitted data for f of x.
It is represented by a line with width 2.
| |
I have specified no legend title for the starting data set.
Data points are represented only by symbols with error bar and have no line.
I have specified a filled circle symbol and 1.5 for point size
| |
set xrange [0.95:5.05] | Please pause video as necessary to practice.
|
replot | Replot to see the results. |
Slide Number 8
Summary
|
Now let’s summarize.
|
Slide Number 9
Assignment
|
For assignment activity, please do the following.
For data file assignment.txt, plot x and y error bars in graph.
The file is provided to you along with the tutorial.
Fit the data to a double exponential decay curve.
|
Slide Number 10
Spoken Tutorial Project
|
This video summarises the Spoken Tutorial Project
If you do not have good bandwidth, you may download and watch it.
|
Slide Number 11
Spoken Tutorial workshops
|
We conduct workshops using spoken tutorials and give certificates.
|
Slide Number 12
Forum for specific questions:
|
Post your timed queries in the forum. |
Slide Number 13
Acknowledgement
|
Spoken Tutorial Project is funded by NMEICT, MHRD, Government of India.
|
Thank you for joining. | |
plot f(x) lw 2, "error-bar-fitting.txt" using 1:2:3 with yerrorbars pt 7 ps 1.5 |