Polynomial fitting for scatter plot

Hi all, 
I was wondering if there is any way to generate a polynomial fit to a scatter plot just like in excel. The data I am trying to fit has several y values for each x value. 
Thanks
Krish
Solved!
Go to Solution.

Well, my "solution" above is a bit misleading, because the polynomial fit of course does NOT depend on the x ordering. If the x-values are scranbled as in your case, a maybe better solution would be to simply create a linear x-ramp over the data range and use polynomial evaluation to calculate a smooth best fit line. This has also the advantage tha a smooth curve is generated even if the data points are sometimes far apart.
Here is one possible modification to show the technique.
LabVIEW Champion . Do more with less code and in less time .
Attachments:
Scatterplot_fitting_MODCA2.vi ‏13 KB

Similar Messages

  • Axis scale for scatter plots

    I'm trying to create a specialized scatter plot, which functions similar to Excel's scatter plot. I'm having problems determining what the min and max values should be for the axes. I would like the program to determine from the input data what the initial min and max values should be on the x- and y-axis, the user can adjust later.
    So, I don't want the program to just look at the maximum value imported and round up. For instance, data = {523.7, 514.4, 271.8, 128.5}. The max value is 523.7, round up to 524. Instead, I would like to program to make 600 the largest value on the axis, because that makes it nice round number for the user to view the dataset.
    Then, I thought it really depends on the range of the data. For instance, data = {523.4, 523.8, 523.2, 522.8, 523.9}. Here, the range is very small, so it doesn't make sense to have 600 the largest value on the scale. The largest value should be 524 or 525, and the small value on the axis scale should be 521 or 522.
    Has anyone else ever worked with this problem, or have a good solution? I would really appreciate it, I've spend way too many days working on this.
    Thank you,
    Joe

    This is off the top of my head and based on a slight variation of your data.
    data: 52.34, 52.38, 52.32, 52.28, 52.39
    min=52.28 max=52.39 range=0.11
    Looking at the range we see it is "on the order of" 0.1. Ie, it is closer to the next lower power of 10 (0.1) than it is to the next higher one (1.0). So we round min down to the next lowest multiple of 0.1 (52.2) and round max up (52.4). 52.2 and 52.4 can serve as the nice numbers.
    The range is just a little bigger than a power of 10, so it might be a good idea to check what happens when it's a little less.
    data: 135 226 141 143 etc
    min=135 max=226 range=91
    range is on the order of 100, and the nice numbers are 100 and 300.
    As a variation on this strategy if we always find the power of 10 below the range (10 in the second example) we get a tighter fit but the numbers are slightly less nice - 130 and 220.
    (I'm pretty sure I've seen - and used! - some java software from the Internet somewhere to find the best scale for axes, so it might pay to look around)
    Had to edit my second example and, while I was waiting, found what I have used for this sort of thing: http://geosoft.no/software/index.html (The NiceNumbers class - it finds numbers along a range suitable for major and minor "ticks" but, if memory serves me correctly it extends the range so that the ends are nice too.)

  • Line of best fit in scatter plots

    when making a line of best fit ( in this case a curve of best fit) how do I extend the curve beyond my data so that I can extrapolate information? Can I do this or will I have to do it manually? (print it out and draw it myself)

    If you graph your data you can allow Numbers to plot a best fit AND show the equation it used (which will depend on the type of fit you selected).
    Here I plotted some data where I introduced random noise (so it won't be "perfect") then had Numbers provide the best fit.:
    The bluse graph is the original data.  The Green is a prediction based on the coefficients from Numbers.
    Once you graph the original data click on the graph, and then click a second time on one of the points in the graph to highlight the series:
    Once you have the series highlighted you can use the Chart Inspector to turn on the Trendline.
    I selected Polynomial because (1) It fit best and (2) the equation I used to make my made-up data was actually a polynomial.  Check the "Show Equation" box to see the coefficients.  Now take these coefficients and place then in cells of your table that has the original data (or some other table).
    Now add a new column to your data (I called mine Ypredicated or Yextrapolated):
    Now add a fomula to use the coefficients which will produce a 2nd graph you may extend beyond the data set:
    C2=$E$6*A2*A2+$E$7*A2+$E$8
    select C2 and fill down as needed (make sure the references to the coefficients are absolute... hence the "$" before the cell row and column names in the formula)
    Finally add the extrapolated curve to your graph to see if it fits:
    click on the graph
    1) click the little cog at the top of the X column and select "Share X values"
    <can't include screen shot right now... not sure why>
    2) then expand the graph data set by clicking and holding the little circle at the bottom right of the highlighted area, and drag to the right so the new predicted column is included.
    <can't include screen shot right now... not sure why>

  • Trendline in Scatter plot

    Hi,
    I have a couple question on Power View 2010
    1. I want to know if I can plot regression Trendlines(Linear/polynomial/power) on scatter plot?
    2. Navigation between pages- Is it possible to navigate between report pages in Power View 2010 by passing parameters from the first page to the next page?
    3. I have a report that has 3 pages. I want to create 2 pages in SSRS 2012 and one in Power View 2010. Is it possible to navigate between these applications and also pass parameters in the URL?
    Thanks in advance.
    Ankit

    The reason why it hangs is because you have 2 event structures inside a loop. You should only have one event structure in a loop. This is documented in the LabVIEW Help. With 2 event structures one of them will block the other.
    Your code is also about 3 times larger than it needs to be:
    To create the array of names for the dropdowns you only need to autoindex a for-loop from the 2D array of data and use the Format Into String function.  You don't actually need to use the values - you only need to autoindex the for-loop.
    Using Delete From Array and Reshape Array just to pull out a row is simply silly (not to mention a Rube Goldberg). That's what Index Array is for.
    In the Cursor Move event case you only need one function: Index Array. The point index is already available to you from the event case's data.
    Half of the code really belongs outside of the while loop since none of that data ever changes, so what's the point of regenerating it each time?
    Instead of using 2 Index Array functions just to get the list of names, wire a True to the Read From Spreadsheet File's transpose? input and use the first row output.
    I've attached a simplified version of your VI.
    Attachments:
    PCoption2_MOD.vi ‏34 KB

  • How to I insert a line of best fit on a scatter plot????

    I have data already organized in tables, and I created a scatter plot. NOw I need to insert a line of best fit and get the equation. How do I do this??? I already calculated a and b (for y=a+bx) but I have no idea how to insert it on the plot. Every search tells me to "insert a trendline"..... but numbers doesnt have that function. Help please???

    Open inspector
    Go to chart tab
    Series
    Click on the "Advanced" to reveal the menu
    Trendline
    Choose the desired trendline (linear etc)
    Hope this helps.
    Dimitris

  • 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

  • Continuous Scatter Plot Comparison for Satellite Observation

    I am working on writing a java plug-in to analyze a scatter plot generated from satellite data(semi-major axis vs inclination). I have been looking at algorithms to do so and found DFS(Depth First Search) and BFS(Breath First Search). The point behind the code is to find out what is normal movement for the satellite and catch abnormal movement. The only problem is I don't have much experience with using algorithms so I was hoping maybe someone can help me get started. Thanks\
    Edited by: ncr7 on Jul 10, 2009 10:08 AM

    Hi Stuart
    Maybe this helps you.
    Thomas
    Using LV8.0
    Don't be afraid to rate a good answer...
    Attachments:
    Plots.vi ‏65 KB

  • 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

  • I need a curve fitting algorithim for polynomial fits, very compact for Fieldpoint implementation (can't use prebuilt VIs).

    I can't use the prebuilt VIs because the libraries take up too much memory on my FP-2000s.  Anyone built up a polynomial fit VI that doesn't include the LV libraries or dlls? 
    Thanks,
    Bill
    Solved!
    Go to Solution.

    Hey Bill,
    That puts you to about 21-22Mb MAX. Doesn't it fit?
    It seems like you may want to look into a controller with larger memory, such as the 2010/2015 or the newer compact FieldPoint controllers.
    Aashish M
    Applications Engineer
    National Instruments
    http://www.ni.com/support/

  • Scatter plot - any libraries available

    hi,
    i need to do a scatter plot for a given data. i gotta plot a line or curve which fits the data.
    is there any packages available that i can import in my project?
    i also need to output that as a image.
    guys, also tell me how do i import that in netbeans.
    i'm a beginner so please be elaborative.

    The free chart library JFreeChart
    Example chart

  • How do you make a horizontal average line in a scatter plot?

    In any version of Numbers, is there a way to make a horizontal average trendline?  Not a "moving average", but one line that is the average that goes through the data points on a scatter plot.

    sflakg wrote:
    hit a few roadblocks. 
    I tried:
    1. using the crop tool to make the canvas bigger with a transparent background.
    2. Used lasso tool over people in group shot (total of 5) and saved the selection
    3. Tried content aware scale to raise the image, but it keeps stretching out the people. 
    Any thoughts on what else I could try?
    Rather than trying to stretch it taller, try to squeeze it horizontally.  There are methods for telling it what to protect in the image if it gets touchy.
    Another possibility is to use Content Aware Fill to make up part at the top and bottom, without any stretching.
    -Noel

  • How to select all (dots) in a scatter plot matrix?

    I have a scatter plot matrix, and I'm manually changing the color of each trend line, which probably isn't the best way but it's an easy but time consuming way to do it. I can't feasibly change the color/stroke of every single scatter plot dot in every single scatter plot graph of the matrix. I'm trying various Select --> Same or Select --> All but it keeps trying to change everything, from the line to the border to the dots. I am not sure if I can group the dots and select all or something. Is there a way to select all of the dots and just the dots?

    I feel like I should have posted screenshots of my graphs for all of my questions. In any event I've been manually changing the colors of the lines and the dots (see the few graphs on the left, I highlighted the inside of the graph and changed the dots and the line and then just manually changed the line back)

  • Highlighting a single data point in a scatter plot - Numbers'09

    Is there a way to highlight a single data point on a scatter plot in Numbers'09 (or point to it using a line from each respective coordinate on the x & y axis).
    I don't think it matters but the data point i am looking to highlight is the [highest y value/2]... and of course its respective x coordinate once you plug the y value into the equation ( y = f(x) ) and solve for x.

    Here is my own tip :
    As you see, I use two sets of values.
    In the second one I define only the yValue of the data point which must be "highlighted".
    Yvan KOENIG (VALLAURIS, France) jeudi 10 février 2011 20:49:32

  • Swap X and Y in a Scatter Plot

    Seems like this should have a simple answer. I have a table of data, and I'd like to generate a scatter plot of two columns. The plot comes out fine, but I want to "swap" the X and Y axis in the resulting chart.
    Is there a simple way to do this? I can't find anything in the chart popup-menu, the inspector, or the application menus.
    Cheers
    Mike

    Michael,
    This is a user to user forum, and I'll admit that I don't have a great grip on Numbers Charts, so I may be missing something myself. However, I don't know of an easy way to swap the axes either. What I would do is to create an auxiliary column that repeats the X data in a column just to the right of the Y data. Then I would create a new chart that plots the second and third columns, effectively reversing the axes. The third column can be hidden. Of course you could also just reverse your x and y columns before plotting, but that might be more disruptive to your overall table organization.
    Jerry
    Update:
    I believe that, after some experimentation, I have a better method for you. Highlight the X Range only and create a Scatter Chart. The Chart will be blank since you have not yet supplied a Y range. Then highlight your Y range and drag it to the blank chart. A new Y series will be inserted.
    Hope this works for you.
    Jerry
    Message was edited by: Jerrold Green1

  • How do I connect the scatter plot points in the newest numbers?

    I just made a scatter plot for biology and I was wondering how I connect the points with lines

    It sounds like all of your wireless clients (computers & printer) are having issues with the overall signal quality of your Wi-Fi network.
    I suggest that you check out the following Apple Support article on the sources of Wi-Fi interference and try to identify & eliminate as many as possible to improve your wireless network.
    You may also find the following Macworld article helpful on troubleshooting for Wi-Fi interference. Although this article is specific to the AirPort routers, it can equally apply to any manufacturers' product.

Maybe you are looking for

  • Ipod & ipad not recognized by itunes

    ipod touch & ipad are not recognized by itunes. i already removed & restarted  & reinstalled  the amds & itunes hoping it would work, but nothing!  maybe 3rd party software is interfering?? i think i temporarily disabled some software from that 3rd p

  • Apple replacement unlocking question

    I recently got given a replacement phone from Apple for one that had a smashed screen and decided that I would give this to my partner as a gift.  However, she is on a different network than me and even though I thought all Apple iPhone's were unlock

  • New iPad and Gmail as Exchange

    I tried setting my gmail up using the Exchange method that works on all other iOS devices. It allows you to save the account and gives you check marks however it constantly says connection to server failed. I have deleted and re-added the account and

  • Acrobat DC upgrade breaks CS6 PDF export?

    Installed Acrobat DC and now my CS6 PDF export function is greyed out. Happens with old and new files. CC 2014 works fine. CS6 has been working fine yesterday up until the point I installed Acrobat DC. Anyone else have this issue? I still have client

  • Email password invalid

    I have been using my BB for 1 week today.  My email has been working fine on my blackberry until some time this afternoon.  I received an email stating my email password was invalid and to reset it to continue receiving my emails on my phone.  I have