Best fit line

regarding a graph made from spreadsheet data...
how do i make a best fit line to a set of points?
also, is there a way to find the slope and intercept of this line?
Thank you!

Hello
The named functions are not available in AppleWorks.
One way to mimic them is to use AppleScripts .
Here is an old one which calculate the slope.
--{SCRIPT}
tell application "AppleWorks 6"
activate
tell front document
set laSelection to get object specifier of the selection
set debutCible to name of first cell of laSelection
-- nom de la première cellule cible
-- • name of first dest cell
set premColonne to item 1 of (index of first column of laSelection) as list
set premRangee to item 1 of (index of first row of laSelection) as list
set dernColonne to item 1 of (index of last column of laSelection) as list
set dernRangee to item 1 of (index of last row of laSelection) as list
set nb_Rangees to dernRangee - premRangee + 1
if not (dernColonne - premColonne) = 1 then error 8088
set cell11 to name of row premRangee of column premColonne
set cell12 to name of row dernRangee of column premColonne
set cell21 to name of row premRangee of column dernColonne
set cell22 to name of row dernRangee of column dernColonne
set vX to get select (cells cell11 thru cell12)
set the clipboard to vX
set vY to get select (cells cell21 thru cell22)
set nb to count of vX
set {X, Y, XY, x2} to {0, 0, 0, 0}
repeat with i from 1 to nb
set xi to vX's item i
set yi to vY's item i
set X to X + xi
set Y to Y + yi
set XY to XY + (xi * yi)
set x2 to x2 + (xi * xi)
end repeat
set slope to (XY - (X * Y) / nb) / (x2 - (X * X) / nb)
select menu item 4 of menu 3 (* copier *)
set slope to my calcule(nb_Rangees)
display dialog "" & slope
end tell
end tell
on calcule(nb_)
tell application "AppleWorks 6"
activate
set AWversion to (version as text)
select menu item 2 of menu item 1 of menu 2 (* Nouveau tableur
• New spreadsheet *)
tell front document
select cell "A1"
select menu item 5 of menu 3 (* Colle • Paste *)
set formula of cell "C1" to "=A1*B1"
set formula of cell "D1" to "=A1^2"
select cell ("C1..D" & nb_)
select menu item 3 of menu 5 (* Recopier vers le bas
• Fill down *)
if AWversion starts with "FU1-" then
set formula of cell "E1" to "=(SOMME(C1..C" & nb_ & ")-SOMME(A1..A" & nb_ & ")*SOMME(B1..B" & nb_ & ")/NOMBRE(A1..A" & nb_ & "))/(SOMME(D1..D" & nb_ & ")-SOMME(A1..A" & nb_ & ")^2/NOMBRE(A1..A" & nb_ & "))"
else
set formula of cell "E1" to "=(SUM(C1..C" & nb_ & ")-SUM(A1..A" & nb_ & ")*SUM(B1..B" & nb_ & ")/count(A1..A" & nb_ & "))/(SUM(D1..D" & nb_ & ")-SUM(A1..A" & nb_ & ")^2/count(A1..A" & nb_ & "))"
end if
set slope_ to cell "E1"
end tell
close document 1 without saving
end tell
return {slope_}
end calcule
--{/SCRIPT}
Yvan KOENIG (from FRANCE mercredi 1 août 2007 06:51:46)
edit:
When I edit my message, the script appears but when I look in the forum it doesn't appear.
It appears that it is a recent "feature" of this forum;
I made a last attempt.
If it doesn't work, you may send a mail to
koenig then a dot then yvan then an @ then tele2 then a dot then fr
I will send you the script as a mail attachment.
Yvan KOENIG (from FRANCE mercredi 1 août 2007 07:07:17)
Message was edited by: KOENIG Yvan

Similar Messages

  • How do i find where 2 best fit lines cross?

    Hi
    I was wondering if anyone knows a way to find where 2 best fit lines cross, I don't have the equation for the lines and i'm not sure if I can get it.
    I currently have the program tracing the lines and comparing y values however it will only increment in steps of 0.1 on the x-axis and i need an accuraccy of 0.0001

    If you have or can get a series of XY value pairs for both of the lines, getting the equation of the line is as simple as calling Linear Fit.vi.  Once you have the equations of both lines, the intersection is simple algebra, subject to the accuracy of your fit.  If the XY data pairs describe a curve, not a line, and you want more accuracy, you can try a polynomial fit using General Polynomial Fit.vi.  To find the intersection, set one polynomial equation equal to the other, compute the coefficients of the resulting polynomial equation, and find the root using Polynomial Roots.vi.  All this assumes you have a Pro or better version of LabVIEW.  If you don't, you can still do it, but you will need to write some code for the fits and roots.  Check out a copy of Numerical Recipes in C, by Press et. al. from your local library and it will give you the equations for all the above.  With LabVIEW's native matrix handling capabilities, the rest is straighforward.
    Let us know if you need more help.
    This account is no longer active. Contact ShadesOfGray for current posts and information.

  • How do I make a best fit line on a scatter plot?

    I have a set of data and I made a scatter plot on numbers, but how do I put a best fit line in there?

    select the graph, then open the Charts Inspector.
    Open the series section (from the options at the top "Chart", "Axis", "Series"), Then select the "Trendline" in the "Advanced" section near the bottom.  Finally select the type of trendline

  • Log scale of the axis and the best-fit line

    I try to plot a graph and set the scale of the x-axis to log scale and then i try to plot a linear trendline (best fit line). but the linear trendline does now show on the graph. but if i set the axis scale to linear, then the trendline does show.  i will need my graph in the log scale and also a linear best fit line. please help me out

    0
    100
    3.00E-09
    71.52
    1.00E-08
    57.3
    3.00E-08
    39.15
    1.00E-07
    24.13
    3.00E-07
    14.77
    1.00E-06
    7.22
    i meant you these data, and left column is x-axis and gonna use log scale for the axis. the right column is the y axis. and then i need a best fit line for this graph.. hope you can help me

  • Is it possible to apply a best fit line to charts?

    The topic pretty much says it all, I have a scatter chart that I need to apply a best fit line to in order to make a general slope assumption. Is it possible to do this, and if so how?
    Also, I can't seem to put a label on my X and Y axis'. I have the number increments that I need, but I need to give them a name. For example, the x-axis needs to be Volume in mL and the y-axis needs to say Mass in grams. Is it possible to do this?
    Thanks very much in advance to anyone who can help.
    Daniel

    The charting function in the iWork suite is fairly rudimentary -- there is no functionality for doing regression or best-fit lines, and the axes labels have to be created by hand.

  • Best fit lines for loops and sine waves

    I am trying to find a best fit line that will work for sine waves and loops (hysteresis loops). I can get the sine wave just fine, but when I switch to a hysteresis it just puts a line across the middle (I assume because of the 2 y values for every x). I am doing data acquisition that will take in both forms and graph them. I tried a polynomial fit and it doesn't work at least the way I implemented it and I tried a few others but it looks like they are all function based. Also, my y values are coming out of a Bessel filter. I don't think this would be affecting anything but I thought I would put it in here incase it does.
    Did I miss one that I haven't tried that works for my application?
    Thanks
    Patrick

    RiversDaddy wrote:
    ... currently I am doing it by looping and reducing the error towards zero to fit the amplitude and phase. (I know the frequency).  If this is what you are looking to do then I will help, or should I be doing things differently? All of the functions I have found to filter or extract tones seem to introduce a larger frequency of phase error than i get using this method, but am I missing something?
    "looping" is a bit vague. What is the actual algorithm to find better estimates (e.g. levenberg marquardt, etc.)
    What problems did you have with extract single tone. Can you show some data where the results from it are not good?
    LabVIEW Champion . Do more with less code and in less time .

  • "best fit" lines

    I have a basic line graph that shows the spending $ trend of three business units over time (5 year history at month level). I'd like to add "best fit" lines to make it easier for end users to discern the trend without all the hills and valleys. How do I accomplish that in 11g? I haven't seen any graph that adds this by itself, so I'm assuming I need to calculate a new "best fit" metric or something?
    Thanks,
    Scott

    Here's a visual example. Column C creates a 3-point moving average that is plotted along with the data values. I'll send you the example. You can create any equation that you'd like depending on your use.
    Regards,

  • Best fit Line on scatter chart

    Hi,
    I am trying to draw best fit line over two points using the formula y=mx+c.
    I have the following data,
    consider x=68, y=23 and a=82, b=30
    I interchanged the above values and form the points to plot
    basically using the above (x,y,a and b) I constructed (x,y),(a,y),(x,b) as points to plot.
    68,23 (x,y)
    82,23 (a,y)
    68,30 (x,b)
    I created a scatter chart based on the value, Now I want to draw the line only between (a,y) and (x,b).
    Is this achievable using any other chart or ways?
    Any help highly appreciated.
    Thanks,
    Vino

    Hi,
    Any input on this please.
    Thanks,
    Vino

  • Is it possible to show a best fit line

    i am plotting percent fructose V.S density and trying to do a best fit line. A connect the dots jagged line would not be appropreate. Is it possibleto do this?

    Short answer: No. Wait to see what the next version brings. The only real work-around is to add a data set using the same x values and new y values, predicted from the linear regression. You would then have to draw a line over the resulting plot points manually. Then, "hide" the extra data set by eliminating the data point fill and outline.
    Only help I can offer is to look in your Utilities folder for an app named "Grapher." It can do everything you ask (and then some) and also produces high quality graphs as well (which can be copied and pasted into other apps in a variety of formats). Best of all, it's free and you probably already have it. It plots both discrete data sets as well as true functions. And yes, it will do linear regressions (and power, exponential, polynomial, and "custom" ones as well).
    Unfortunately, iWork's charting abilities are best described as "laughably pathetic." In stead of revolutionizing the charting aspect of spreadsheets, Apple chose to follow in M$'s footsteps, aka the path of a sado-masochistic CPA or "the Excel way." In essence, Numbers is only capable of producing what I call "bin count" charts (as in pie charts, bar graphs, and line/area charts). The "scatterplots" Numbers produces are really a hacked version of bin count charts. As such, they are basically useless for real scientific/engineering/mathematic plots. In fact, it does them so badly, I'm surprised the "scatterplot" option even made the cut for the final release.
    Things that breaks/cripples Numbers' "scatterplot":
    • No control over range of axis. "Value Axis Format" controls don't function properly/always remain blank and there is only one set of values for both axis (just like a bin count chart, whose "x axis" has no real, numerical value; so, doesn't need any controls). And there is no way to lock the scale of the axis so, for example, 10 units on the x axis is the same physical distance as 10 units on the y axis.
    • Axis grid divisions are only allow to be integers between 1 and 10 (which only makes sense for a bin count plot).
    • No 3D, log, log-log, ln, ln-ln, cylindrical, or spherical plots.
    • No true function plots. And there is no way to connect points, it only plots discrete data sets.
    • No control of data point marker sizes, only the fill/outline color and outline thickness.
    • Chart legend gets it's text from the independant variable (aka x values) column title, not the dependant (y value) column title, like it should. (Something that only makes sense on a bin count chart, which usually only have one column of data per data set.)
    • Each data set must come from adjacent pairs of columns. (You can't have one set of x values for a table of multiple y values.)
    • No way to control the size of the plot area itself (only the overall size of the chart rectangular area, which includes the axis text). So you can't fake a line chart as an overlay over a scatterplot, there's no way to align them.
    • Only does linear regressions directly (and then you have to put it together from pieces). No exponential, log, ln, power, or polynomial fits.
    • Charting brings Numbers to it's knees as far as speed is concerned.
    • I haven't found a way to ADD a data set to chart, it always seems to replace the data already plotted (or am I missing something or fighting a bug?).
    Heck, there isn't even error bars on it's financial charts, so you can't even do a simple high-low-close stock price tracking, line chart. Other than that, it you want a 2 1/2D pie chart with wood grain texturing, Apple's got you covered!
    Scott
    P.S. Just in case those of you reading this think I'm an Apple/Numbers hater, you couldn't be more wrong. I'm a huge fan of Numbers and it has permanently bumped Excel off of my dock. (I just don't use it for charting.) I call'em like I see 'em. And Apple can't fix it if they don't know it's broken.

  • Other lines parallel to a Best fit line on a scatter graph?

    Can you put Lines of equal gradient to the best fit line on a scatter graph going through to points furthest above and below the best fit line?

    Simplified a bit so I am not so ashamed
    I2=SLOPE(C2:C9,B2:B9)
    I3=INTERCEPT(C2:C9,B2:B9)
    Y Linear (column D) =$I$3+B2×$I$2
    Y - YLinear (column G) is what it says
    Max Line (column E) = $D2+MAX(G)
    Min Line (column F) = =$D2+MIN(G)
    You have to format the "trend" lines with connecting lines and no data symbol

  • Is it possible to do best fit line in chart in numbers

    is it possible to do best fit line in chart in numbers

    Hi R,
    This is a Scatter Plot in Numbers 3.1. Data are in Body Columns, not Header Columns.
    Click on the chart, then Format Panel > Series > Trendlines
    Choose a Trendline. You may click on Show Equation and Show R2 (R squared).
    Regards,
    Ian.

  • How to Make a Line of Best Fit/Best Fit Line/Trendline in iWork Numbers '09

    I'm not sure if this is well-known or has been answered elsewhere already, but multiple Google searches have not shown this solution on how to create a line of best fit in Numbers '09 (there is another method that involves drawing a line yourself, but this is much easier and more accurate).
    I stumbled across this trying the above self-draw technique and got so excited I wanted to post the technique. So here is what you do:
    1) Type out your X and Y data
    2) Select the data and select Charts, then select the Scatter Plot
    3) Open up Inspector and select the Chart tab
    4) Select the "Series" tab below the picture of the Scatter Plot and the "Chart Colors..." button
    5) At the bottom of the Inspector window, open the "Advanced" arrow
    6) Select the "Trendline" tab and select the "Linear" trendline from the drop-down bar
    That's it! You can even select the options to show the line equation or the R-squared value!
    Here is a picture of the selected options and what your graph should look like (check that nice R-squared value!).
    http://i.imgur.com/AvfPv.png
    I hope this helps and hope it moves up to the top of the Google search page for this feature.

    Hi Asclepius37,
    Why not just search "trend" or "trendline" in the Numbers '09 User Guide?
    That would take you to page 149 of the guide and the article "Showing Trendlines in Charts," which lists a set of instructions very similar to those in your post.
    The Numbers '09 User Guide and the iWork Formulas and Functions User Guide are searchable pdf files, and may both be downloaded through kinks in the Help menu in Numbers. Both are excellent resources to have on hand.
    Regards,
    Barry
    PS: Searching "best fit" will return zero results, but "best" or "best-fit" will get you to the same article.
    B

  • Best fit/ linear equation in Numbers on the IPad?

    Does anyone know how to find the best fit line equation on Numbers for the IPad? I know how to find it in IWork for the MacBook and how to find the line on the Ipad. Thanks

    Can you tell me where line of best fit is in the iOS version? I havent seen it yet.
    You can search on the Internet for the linear regression formul, and compute the equation yourself. Then you could plot that series of points on your chart to show the line if it is not part of iOS.
    Jason

  • I have several 20,000+ point scatter plots that I'd like to graph with a best fit. Whats the best way to do this?

    Since they're so large and occupy the same range of y values, I'm kind of reluctant to plot them one over another so a best fit line would, I think, be the most helpful in analysing the data. I'm not quite sure however how to go about this since the data can be random

    Well, here's a very primitive way to decimate the data without any fancy algorithm. For this particular case, it looks pretty good. Each loop makes the array 3x smaller, averaging 3 adjacent elements. 4 iterations seem to be perfect. (I have included your raw data in diagram constants).
    For a polynomial fit, the more complex the data, the higher the order polynomial is needed to describe it. If it is a simple "banana" (my example above) you're OK with an order of 2 (up to quadratic), if it is s-shaped, you need at least 3rd order, etc. I tried your data with much higher orders (up to 40!) and it did not work.
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    Best_Fit2.vi ‏370 KB

  • Exponentia​l Best Fit Is Off?

    Hey again, wonderful forumers!
    So, my lab advisor came back from her trip to Italy… turns out using the Leven-Marquart fitting process is okay, so we turned our attention to the exponential fitting process.
    As we inspected this element further, we found out that there’s something fishy going on with our best fit line. I take theoretical Lorentzian data and plug said points in for tau in an exponential generation process. After generating the exponential data, I add Gaussian noise, and then pull THAT data into the standard exponential fit VI. The resulting best fit line is nowhere near the curve of original theoretical data, which is what I was predicting. Am I doing something wrong or is the data not appropriate for this fitting process? Peers here on my end have tried fitting the same data in different programs, and their processes work… so perhaps there’s something screwed up in my code!
    I’ve included the main VI and a few SubVIs with this message.
    Any help or comments would be appreciated.
    Sincere thanks,
    Vari
    Solved!
    Go to Solution.
    Attachments:
    Something's Wrong.vi ‏130 KB
    BL-BuildArrayFunction.vi ‏12 KB
    BL-DatatoChiSquared.vi ‏9 KB

    Varinem wrote:
    Anything to say on the matter or are me and my lab just crazy? 
    You have a pretty old LabVIEW version and the "unconstrained exponential fit" you are using is not directly supported, according to the context help. Wire a "refine=TRUE" to the lower input and things look better.
    Substituting the toplevel exponential fit from the palette gives excellent results. 
    (While you are at it, please get rid of these stupid detours via dynamic data. Remove the "to dynamic data" and "merge signal" nodes. A simple "built array" works just fine).
    LabVIEW Champion . Do more with less code and in less time .

Maybe you are looking for

  • Import, package, connection

    Here's my problem. This a second forum, first one; no answer. I think here are all the necessary information, codes are quite long... I have 3 servlets, S1, S2, S3. and a java class Data. All these servlets, classes and build.xml are in a same folder

  • Final Cut Express installation

    Can I install Final Cut Express on my iMac at work and then un-install it and install it on a second iMac. My older iMac at home does not have the power to run it and I'm getting a new iMac model in June. In the meantime I'd like to start working wit

  • File missing in specified location (I/O)

    I am actually writing a program where I need to read the content of a file and reproduce it exactly into another file for which. I began testing codes. public class Main {     public static void main(String[] args) throws IOException {         Scanne

  • I am going to an apple store and...

    me and my family are going on a vacation soon and the place we are staying is close to an apple store (the one in the oxmoor center in Kentucky.) i was wondering if you have to schedule an appointment for a genius, and can i ask them anything? can th

  • Inforecord Archive

    Hi All, I am trying to archive some inforecords , for that i am using MM_EINA archiving object in ME17. The job starts and gets cancelled immediately.The job log shows the following logs, Job started