Multivariable least square fitting

Can Labview, specifically General LS linear Fit VI do the following fitting?
I have x, y, P as independent variables, and fit a curve B to a function of :
B = b0 +b1*x +b2* y +b3 *P + b4 *x^2 + b5*y^2 + b6 * P^2 + b7* x*y + b8*x*P + b9 * y*P;
There are 12 data points to get 10 coefficients, b0-b9.
I'd appreciate any comments. Thanks,

You have three independent variables (x,y,P), one dependent variable (B), 10 linear coefficients, and 12 datapoints B(x,y,P) in 3D.
All coeefficinets are linear, so all you need to do is setup the H matrix and B vector according to your data, then use general linear fit.
How does the data look like? What does it represent? Can you attach a typical dataset?
Note: Since you call it "general LS linear fit", you must have an older LabVIEW version, but it is the same as "general linear fit" I mentioned above. It should be able to handle this problem easily. Have you tried?
LabVIEW Champion . Do more with less code and in less time .

Similar Messages

  • Linear Least-Squares Fit

    Im farely new to programming and I got stuck with a linear least-squares fit problem. I am supposed to develop a method that will calculate slope and intercept of the least-squares line that best fits an input data set.
    Ive been trying to figure out just how to write this program for a couple of days, but with no luck.
    Can anyone give me some tips on how to write this program and what the finished program should look like?
    Any help would be greatly appreciated

    Atleast I believe that I am needed to return a graph. The assignment says
    "Test your method usin a test driver program that calculates the least-squares fit to the following 20-point input data set, and plots both the original input data and the resulting least-squares fit line"
    And then itgives me a chart of the x and y values

  • Nonlinear least square fit problem

    Hello,
           I have been trying to fit the data given in the attached file. When you click command button1, the routine goes thru the NonLinearFitModelProcedure, calculates some points and gives an error message like "The return parameter in NonLinearFitCallback must be assigned a scalr value". I do not understand this error message. Any ideas? Thank you.
    Cem
    Option Explicit
    Const numpoints = 49
    Private Sub CWStat1_NonLinearFitModelProcedure(x As Variant, c As Variant, f As Variant)
        ' Enter the equation to fit in this callback.
        ' The fitter will attempt to find the best set of Coefficients that will fit the model result (f)
        ' to the expected result (y) generated by the GenerateData subroutine below.
        ' In this example, we fit the data to an exponential (f = a * exp(b*x) + c).
        'f = Coefficients(0) * Exp(Coefficients(1) * x) + Coefficients(2)
            If x <= c(1) Then
                f = 0
            ElseIf x >= c(1) And x <= (c(1) + c(2)) Then
                f = 2 * (1# - Exp(-c(0) * (x - c(1))))
            ElseIf x >= (c(1) + c(2)) And x <= (2# + c(2)) Then
                f = 2 * Exp(-c(0) * x) * Exp(c(0) * c(1)) * (Exp(c(0) * c(2)) - 1#)
            End If
            Debug.Print x, f
    End Sub
    Private Sub Form_Load()
        Open "fldwhite.txt" For Input As #1
    End Sub
    Private Sub Command1_Click()
        'Compute the fit now.
        ComputeFit
    End Sub
    Private Sub GenerateData(x As Variant, Y As Variant)
        Dim i
        Dim dum
        Input #1, dum, dum
        ReDim x(numpoints)
        ReDim Y(numpoints)
        i = 0
        Do While Not EOF(1)
            i = i + 1
            Input #1, x(i), Y(i)
        Loop
    End Sub
    Private Sub ComputeFit()
        Dim x, Y, z, ynoisy, MSError, coef
        ' generate sample data
        GenerateData x, Y
        a0 = 0.02
        b0 = 2
        c0 = 2
        ' initial guess coefficients
        coef = Array(a0, b0, c0)
        ' perform the fit
        ' The function returns the results within coef.
        ' The function also returns a gauge of the results as MSError.
        ' A higher value for this number implies a "worse" fit.
        z = CWStat1.NonLinearFit(x, Y, coef, MSError)
        ' plot the results:
        '   Plot1 = Original data
        '   Plot2 = Original data plus noise
        '   Plot3 = Fitted curve
        CWGraph1.PlotXvsY x, CWArray1.BuildArray(Array(Y, z))
        ' Display computed coefficints and Mean Squared Error
        a1.Caption = Format(coef(0), "0.0##")
        b1.Caption = Format(coef(1), "0.0##")
        c1.Caption = Format(coef(2), "0.0##")
        mse.Caption = Format(MSError, "0.00E+00")
    End Sub
    Attachments:
    fldwhite.txt ‏1 KB

    Hello Sam,
         Thank you for the reply. The error number was something like 10024(?) I found out that my problem was to do with the function definition. The function limits were not set right. When I corrected it worked. But you are right that somehow I do not define the type correctly. See the routine below:
          The xData and yData are defined as variant, likewise the yFit variable. The first two are populated in a for loop, therefore they are redimensioned prior to this. On the other hand the yFit variable is filled as an array by the NonLinearFit routine. This typing works for the fit routine, but it doesn't work for the plot routine where two differently typed variables, yData and yFit are used as arguments of the Array function. In order to make this to work I used CWDSP function for the XData, yData arrays which is an overkill. What is the reasonable solution for type casting these variables? Thank you.
    Cem
    Private Sub cmdFit_Click()
    Dim i As Integer
    Dim j As Integer
    Dim k As Integer
    Dim NCoeff As Integer
    Dim Coefficients
    Dim mse
    Dim yFit
    Dim xData
    Dim yData
    Dim tArray() As Double
        With sprResults
            For j = 0 To 4
    '            xData = CWDSP1.Ramp(nPts(j), 0, 1)
    '            yData = CWDSP1.Ramp(nPts(j), 0, 1)
                ReDim xData(0 To nPts(j) - 1)
                ReDim yData(0 To nPts(j) - 1)
                 For i = 0 To nPts(j) - 1
                        xData(i) = CDbl(sTime(i))
                        yData(i) = CDbl(sData(i, j))
                Next
                fitType = j
                NCoeff = 2
                Coefficients = Array(CoefValues(0), CoefValues(1))
                yFit = CWStat.NonLinearFit(xData, yData, Coefficients, mse, 25)
                cwgPlot(j).PlotXvsY xData, CWArray.BuildArray(Array(yData, yFit))
            Next
    End With
    End Sub

  • Least squares from file

    hi i have a final project i have to write least squares best fit vi,vi should read the datas from a txt file and draw best fit line according to least squares method calculations and also it should show the datas in point form pls help to me i tried a lot but i got nothing...thx

    Hey siktigit ys,
    There are built in Least Square Fit functions in LabVIEW. Here is some information about them. If you are having trouble reading the data from the file, here is an example showing how to use the read and write VIs. In order to show your data in a graph, I'd just read the data from the text files into an array and display that array on an XY graph. That should be enough to get you started. If you need more help, just let me know and have a great weekend!
    John B.
    Embedded Networks R&D
    National Instruments
    Certified LabVIEW Developer

  • Least square circle calculation on a series of data points

    I am taking a series of (x,y) part measurements that describe a circle  (radius & rotation angle). The center of the part and center of rotation are offset. Looking for code to do a least square circle calculation on this data set so diameter and out-of-roundness can be estimated. Platform LabView 8.2.

    Here is my simple solution from the above mentione thread:
    (Is it not exaclty "least squares" in the classical sense but the sphere fit works typically very well..)
    LabVIEW Champion . Do more with less code and in less time .

  • Least squares method from file

    hi i have a final project i have to write least squares best fit vi,vi should read the datas from a txt file and draw best fit line according to least squares method calculations and also it should show the datas in point form pls help to me i tried a lot but i got nothing...thx

    Hi,
    I recommend that you search the following websites for assistance:
    www.ni.com
    www.ni.com/community
    Kareem W.
    National Instruments
    Web Product Manager

  • The covariance of the least square methods

    what is the meaning of the covariance? In the least square method fitting problems ,if I should make it equal to zero??
    If it isnt equal to zero ? what is the matter?
    thanks for any one can explain it to me !
    As a man you should be ....

    Hi Sharad,
    Try to rename the component name and reload+rebulid the project.
    If there is any build errors try to repair the DC with classpath structure and deploy the DC in server.
    Hope this helps you...
    Regards,
    Saleem Mohammad

  • I need to plot the Least Squares Regression Line (not just calculate it with the LINEST function).  How?

    I need to plot the Least Squares Regression Line (not just calculate its values with the LINEST function).  Can anyone advise me on how to graph this line?

      Grapher.app in OS X Utilities is excellent for that : entering data from Numbers Excel etc. into a Grapher "Point Set", plotting all your data, computing and plotting a regression curve linear or exponential or polynomial.
      Unfortunately there is not a single word about point sets and regression in the Grapher Help.
    So, suggest you download (free) "Instruction for Use - Grapher on web site
    http://y.barois.free.fr/grapher/Documentation.html
    and go to page 31 to 37, "Initiation > Lesson 6 : Treating a point set (Regression curve), and also page 68, "Appendix 1. Points sets : from speadsheets to Grapher".
      If you try Grapher's regression curves, please tell us about the manual above : useful or not, too easy or difficult, readable or not etc.
      Thank you.
    YB24
    PS. Documentation about Grapher is also here : Google "Apple Grapher" > http://en.wikipedia.org/wiki/Grapher > Article > Talk > Grapher 1.1 to 2.3 (French and English) (11th september 2012)

  • Multi variate damping least square solver

    Hello all,
    I am hoping to get some advice and a starting point for a challenging problem I am working on.
    I have a 33x37 matrix that i need to minimize using a damping least square approach.  in order to achieve the minimization I need to use a set of 50 Matrices (33x37, representing adjustment impacts) that are grouped in 12 separate catagories with different starting points and degrees of freedom, and none of the adjustment matrices are truly independent of each other (they all interact with each other to some extent.)
    For the output I need the minimized matrix and the amount of each vector applied to achieve the minimized solution.
    To hopefully clarify the inputs and outputs I have included an example vi with a dummy set of data.
    I am hoping that someone can give me an idea of where to start, can this be accomplished using the labview libraries or will this have to use scripting via a mathscript node, or matlab?  If it can be done in different ways which method is the most efficient?
    I hope this is enough information, but if you need more details please let me know, although giving exact details can be difficult in this case due to IP considerations.
    As always thank you in advance for any help/suggestions you may be able to offer.
    Chris
    Attachments:
    example2.vi ‏25 KB

    Other then using a least square method I dont have a function defined yet (trying to figure out what function to use), but essentially I am trying to find out how much of each of the adjustment matrices need to be applied to minimize the original matrices..
    I hope that explains what i am trying to do a little better

  • Least square linear-phase FIR filter

    I need to geta second order derivative of an array based on 2 stage filtering with a least square linear phase FIR "differentiator " filter. Previously this was done using the matlab routine firls using the "differentiator" tag. Any ideas how this can be done in LabView?
    Thanks in advance.

    I don't believe that LabVIEW has any differentiation functions that use this algorithm. The only derivative function is located in the analyze, signal processing, time domain. You would probably have to build your own.

  • Partial Least Square software in Mac OS X!

    Hi! Is there anyone can help me out with any other Partial Least Regression software name that will run in mac os x, apart from smartPLS 3.0 (this is just too expensive)? Thanks

    There's R: http://www.r-project.org
    Not sure if the package is built in, but there is a package you can install: http://cran.r-project.org/web/packages/pls/index.html

  • Problems about nonlinear least square( waiting online)

    This time I met a problem again,as you see when I set the parameters Amplitude=10000 or greater ,then the output will not turn out .
    Another problem is the derivative of the output on the waveform wobble after I click run for a while
    As a man you should be ....
    Attachments:
    ZQH_BYSJ.llb ‏330 KB

    Can you explain what you mean by wobble? (e.g. attach a picture)
    Your toplevel VI only runs once because there is no while loop. How do you run it "for a while" then? I pressed the run button 50 times, but nothing changed....
    If your amplitude is set to 10000, the function has a range of over 10^17, mostly because you take the fourth power. On that same scale, the influence of the lower order terms(a , b) now only contribute an infinitesimal small fraction to the signal (way beyond the scope of DBL or EXT) and thus can no longer be determined. Your problme is out of balance because the C and D completely dominate the result. As explained elsewhere, you need to keep your amplitude in a reasonable range and instead scale the fitting parameters.
    LabVIEW Champion . Do more with less code and in less time .

  • How do I get the error on fit parameters in Diadem

    I am using Diadem "linear least-square fit" with weighted Y-channel. The typical fit model is y=a+b*x. Here is my question:
    How do I get the error on the fit parameters a and b ?
    Okay, I can ask Diadem to calculate the co-variance matrix, and then use a script to calculate the errors, but there must be a short-cut?
    BR,
    Chr

    Hi schoric,
    The only quantitative regression fit assesment that is built into the DIAdem function is the coefficient of determination of the regression (r^2), which is stored in the global DIAdem variable:
     RegrPrecision 
    Does that help?
    Brad Turpin
    DIAdem Product Support Engineer
    National Instruments

  • Using the "fit" function with "mFct" ?

    having a problem with declaring a function and using it in a nonlinear least squares fit:
    function Fit5(a,x,y)
    rslt5 = a[1]*(2.0*besselj(sqrt(.....;
    return rslt5;
    end function;
    [a, res1, q1, qVar1] = fit(g, Top_data, fit5, guess,,,iterMax,w,rho );
    getting the following error message:
    is not a valid signature for the function"fit"

    having a problem with declaring a function and using it in a nonlinear least squares fit:
    function Fit5(a,x,y)
    rslt5 = a[1]*(2.0*besselj(sqrt(.....;
    return rslt5;
    end function;
    [a, res1, q1, qVar1] = fit(g, Top_data, fit5, guess,,,iterMax,w,rho );
    getting the following error message:
    is not a valid signature for the function"fit"

  • Time to get charts correct.

    3D bar charts are all very pretty but sometimes people want to represent quantitative data in an genuinely informative way. To this end it is time to provide some simple changes to the way Pages does its graphing in order to provide this resource. (Yeah I know how to use a dozen other tools to do this but it would be nice if Pages (and by extention: Keynote since it is the same underlying software) did this natively.
    Almost all these suggestions pertain to scatter plots:
    1. For scatter plots provide properly scaled axes. This is a simple algorithm guys! Set the scale so that the number along the axes come out close to whole or 1/2 whole numbers.
    2. By default, scatter plots, should show the full x AND y grid. Provide a way to show a grid for minor grid points as an option.
    3. Pick up the titles at the top of the data columns as axis labels.
    4. Provide for a graph title (sure I can work around this with a text box but shouldn't it be built in to every graph?
    5. (low priority) Allow for the inclusion of a simple "trend-line" (as our friends in Redmond call it.) A simple least squares fit and titling of the line on the same graph.
    I like pages. I build complicated documents as handouts for my students. Pages gets all the text flows correct where MS Word just chokes. This graphing stuff isn't hard to fix and should have been right in the first release.
    G5 2Ghz Mac OS X (10.4.7) Pages 2.01
    G3 450Mhz Mac OS X (10.2.x)
    G5 2Ghz   Mac OS X (10.4.7)  

    Websites remembering you and automatically log you on is stored in a cookie.
    * Create an allow cookie exception (Tools > Options > Privacy > Cookies: Exceptions) to keep such a cookie, especially for secure websites and if cookies expire when Firefox is closed.
    Make sure that you do not run Firefox in Private Browsing mode.
    * https://support.mozilla.com/kb/Private+Browsing
    Do not use Clear Recent History to clear the "Cookies" and the "Site Preferences"
    * https://support.mozilla.com/kb/Clear+Recent+History
    Clearing "Site Preferences" clears all exceptions for cookies, images, pop-up windows, software installation, and passwords.
    *http://kb.mozillazine.org/Cookies

Maybe you are looking for

  • Open Item Mng. Problem

    Hello, I have an account on which I want to switch on "Open Item Management", but I can't. This account was originaly "open item", but then I changed it and now I want to change it back. After some posting to make balance zero on this account it's st

  • Request xy in system xy: internal error 0000000040/ in spooler ()

    Hi SAP community, when I am running a customized COPA report in background I got the following error message when I am trying to access the spool (job itself finished successfully): <b>Request xy in system xy: internal error 0000000040/ in spooler ()

  • Cant burn getting Error 4280 (Yes I have latest version)

    I was having this issue before I upgraded to the newest version and still seem to not be able to burn. I am getting Error 4280? There isnt much info on this to fix it it seems... I'm running Win7 64 Never had a problem before. Ideas to fix this?

  • Change PER column in conditions tab

    Hi, it says here that decimal places are not allowed in the Per column under conditions tab in me23n.  Can we configure this and allow decimal places? Thanks!

  • Help on XI HA post installation

    Hi Expert, I am installing a XI in an HA enviorment. Both node are building on HPUX. Installation process are successful, after installation, I am going thru the post installation step which mentioned in notes:951910, after I followed notes and I ope