Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

What program does linear fit including uncertanities? (excel, graphical analysis ?)

  1. Feb 14, 2007 #1
    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 cant 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
     
  2. jcsd
  3. Feb 14, 2007 #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
     
  4. Feb 22, 2007 #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 (Text):

    [b]STEP 1:[/b]
    Download this file:
    http://t16web.lanl.gov/Kawano/gnuplot/intro/plotexp.dat


    [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.
     
  5. Feb 25, 2007 #4
    GnuPlot is a good choice, but if you are looking for a program with graphical interface try Grace or QtiPlot.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: What program does linear fit including uncertanities? (excel, graphical analysis ?)
  1. Graphics Programs? (Replies: 6)

Loading...