Finding a Program to Calculate Slope with Y-Intercept of 0 and Uncertainty

In summary, the conversation discusses the need for a program that can calculate the slope of a linear fit line and its uncertainty, with a y-intercept of 0, for a data set with uncertainties on both x and y variables. The individual has tried using Excel and Graphical Analysis, but is looking for other programs that may be better suited for this task. They also inquire about calculating uncertainties for a multivariable function. One suggestion is to try Gnuplot, which can also fit a function to the data and create graphics in various file formats. Another suggestion is Grace, which has a graphical interface.
  • #1
dreamspy
41
2
Hi


I have some data which concists of some points (x,y) and I'm looking for a program that can calculate for me the slope of the linear fit line (trendline) including uncertanity on the slope. Also the y-interception has to bo at 0.

My data set includes incertanities on both x and y variables.

I have tried this in excel. I can get the slope for the line that has y-intercept = 0, and I can add in the graph my uncertanities, but I can't find out how to calculate the uncertanity of the slope.

I tried another program called graphical analysis. That program can easily give me the slope and the uncertanity of the slope. But I can't seem to find out how to force y-intercept to 0 (force the line through the point (0,0) )


So my questions in general are:

Is there another program that is better suited for this?
How can I calculate uncertanity for the trendline in Excel?
How can I force the trendline (linear fit line) to go through the point (0,0) in Graphical Analysis.

An answer to just one of these questions would be sufficent :)



best regards
frímann kjerúlf
student of University of Iceland
 
Computer science news on Phys.org
  • #2
Just seconds after I sent this post I figured out how to do this in Graphical Analysis :) Just use the "General Equation" Y = AN (not Y = AN + b) .

Although I am still interestd in knowing if there are some better programs for making charts, and calculating uncertanities? F.x. calculating uncertanities of a multivariable function, it can get quite cumbersome using paper and pencil.

regards
Frímann
 
  • #3
Try gnuplot:
http://www.gnuplot.info/

For the Windows version download the file from
http://gnuplot.sourceforge.net/development/binaries/
(The version from 10-Feb-2007)
The Windows version of gnuplot is called wgnuplot.

To start wgnuplot, unzip the downloaded file and go to the folder
gnuplot\bin
There, click on
wgnuplot.exe

First of all the font in the terminal is too small, so change it with a rightclick on the terminal
background and click "Choose Font". Choose the font you like.

Then work through this excellent tutorial:
http://t16web.lanl.gov/Kawano/gnuplot/intro/index-e.html

Other tutorials can be found here:
http://gnuplot.sourceforge.net/help.html
and there are lots more on google

-------------------------------

Here's an example on how to plot data and fit a function to it:

Code:
[b]STEP 1:[/b]
Download this file: 
[PLAIN]http://t16web.lanl.gov/Kawano/gnuplot/intro/plotexp.dat[/PLAIN] [b]STEP 2:[/b]
Open the plotexp.dat file with a texteditor and replace the data 
by the following:
0	0.1
1	1.03
2	2
3	3.03
4	4
5	5.03
6	6
7	7.03
8	8
9	9.03
10	10
Save the plotexp.dat file.
(Note: The first column contains the x-values and the
second one the y-values.)[b]STEP 3:[/b]
Now put the plotexp.dat file into the folder
gnuplot\bin\[b]STEP 4:[/b]
Start wgnuplot and type the following in the wgnuplot terminal:
gnuplot> plot "plotexp.dat" 

This creates a plot of the datapoints.

You can label the x- and y-axis and put a title. Type in the terminal:
gnuplot> set xlabel "name of x-axis"
gnuplot> set ylabel "name of y-axis"
gnuplot> set title "this is the title"
gnuplot> plot "plotexp.dat" 

(Note: Instead of typing 
gnuplot> plot "plotexp.dat"
you can also type
gnuplot> replot)[b]STEP 5:[/b]
Fitting a function to the datapoints:

Suppose you wanted to do a linear fit, then your function is
f(x) = a*x+b

Thus, type in the terminal:
gnuplot> f(x)=a*x+b   

To fit this function to the data, type in the terminal:
gnuplot> fit f(x) "plotexp.dat" via a,b Gnuplot determines:

Final set of parameters                         Asymptotic Standard Error
=======================            ==========================

a               = 0.995455                     +/- 0.002571     (0.2583%)
b               = 0.0454545                    +/- 0.01521      (33.47%)   

The values for a and b are:
a   = (0.995455  +/- 0.002571)    
b   = (0.0454545 +/- 0.01521)       

(Note: You can use other functions for f(x), for example
gnuplot > f(x) = a+b*x+c*x**3
The fit-command then becomes:
gnuplot> fit f(x) "plotexp.dat" via a,b,c
Note that x**3 means x^3.)[b]STEP 6:[/b]
To plot the data and display the fitted line together,
type in the terminal:

gnuplot> plot "plotexp.dat", f(x) [b]STEP 7:[/b]
- You can also save the graphics and create an output as eps or postscript:

EPS (with color):
gnuplot> set term postscript eps enhanced color
gnuplot> set output "color.eps"
gnuplot> replot
(Note: You can also use another name for the output, e.g. type:
gnuplot> set output "myData.eps")

EPS (only mono)
gnuplot> set term postscript eps enhanced monochrome
gnuplot> set output "mono.eps"
gnuplot> replot

POSTSCRIPT:
gnuplot> set term postscript 
gnuplot> set output "data.ps"
gnuplot> replot
(To view ps files, you need a program called Ghostview and Ghostscript, 
[url]http://www.cs.wisc.edu/~ghost/gsview/index.htm[/url])

You will then find the eps or ps file in the gnuplut\bin folder.

Finished!

NOTE:
- By pressing up and down key (on your keyboard) in the terminal, you can choose former commands you typed
- I had to download the "plotexp.dat" and edit it because
saving the datapoints in a txt file (test.txt) and opening the txt file
with gnuplot didn't work. For some reason only the .dat file is recognized
by wgnuplot.
- Unfortunately I don't know how to create a jpeg file with wgnuplot.
 
Last edited by a moderator:
  • #4
GnuPlot is a good choice, but if you are looking for a program with graphical interface try http://plasma-gate.weizmann.ac.il/Grace/" .
 
Last edited by a moderator:

1. What is the purpose of finding a program to calculate slope with a y-intercept of 0 and uncertainty?

The purpose of finding a program to calculate slope with a y-intercept of 0 and uncertainty is to accurately measure the relationship between two variables and determine the uncertainty or margin of error in the calculated slope. This can be useful in various scientific fields such as physics, chemistry, and biology.

2. How does the program calculate slope with a y-intercept of 0 and uncertainty?

The program uses mathematical equations and algorithms to analyze the data and calculate the slope and y-intercept. It takes into account the uncertainty or error in the data points to provide a more accurate result.

3. What are the inputs required for the program to calculate slope with a y-intercept of 0 and uncertainty?

The inputs required for the program include the x and y values of the data points, as well as the uncertainty or error associated with each data point. These inputs can be obtained through experiments or other measurements.

4. Can the program calculate slope with a y-intercept of 0 and uncertainty for non-linear relationships?

No, the program is designed to calculate the slope and y-intercept for linear relationships only. Non-linear relationships require different equations and methods for determination of slope and intercept.

5. How can the program help in scientific research?

The program can help in scientific research by providing accurate measurements of the relationship between two variables and taking into account the uncertainty or margin of error. This can aid in making more informed and reliable conclusions based on the data analysis.

Similar threads

  • STEM Educators and Teaching
Replies
11
Views
2K
  • Set Theory, Logic, Probability, Statistics
Replies
5
Views
1K
  • Other Physics Topics
Replies
6
Views
2K
  • Set Theory, Logic, Probability, Statistics
Replies
11
Views
753
  • Programming and Computer Science
Replies
11
Views
2K
  • STEM Educators and Teaching
Replies
5
Views
652
Replies
4
Views
1K
Replies
4
Views
1K
Replies
10
Views
2K
  • Set Theory, Logic, Probability, Statistics
Replies
30
Views
2K
Back
Top