Weight values in weighted linear fit
I am using Labview 8.5, which has the weighted linear fit vi.
What values are acceptable as weights? In other fitting software the weights expected are usually standard deviations of each value. It seems to me that the weights expected by the weighted linear fit vi are in a range from 0 to 1, corresponding to how much you value that point.
What is the vi actually looking for? Some value between 0 and 1 or the standard deviation for each particular value of the dependent variable?
I can't tell just by reading the help or looking online.
Solved!
Go to Solution.
Prior to LabVIEW 8.0, there was a "standard deviation" input instead of a weight input for the nonlinear fit function, but internally the code was basically the same (It was immediately converted to a weight internally).
Weight is better and more convenient because you can completely disregard portions of the data by setting the weight to zero, while it would be weird trying to set the standard deviation to infinity to get the same effect (well, it would not work unless the function can detect that special case and adapt to it).
Since it is mathematically very simple to translate an standard deviation into a weight, you can do that easily yourself.
LabVIEW Champion . Do more with less code and in less time .
Similar Messages
-
Hello,
I'm new in this forum and unfortynately I'm not so confident with LabView.
Now I'm working with LabView 7.1 and I have a normal linear fit in my program. What I would like to do is change this fitting with a weighted linear fit.
Searching a bit in the web I found that in the version 8 there is already a VI for this fitting. I guess should be possible with a bit of math to write a subVI, but I have some problem to estimate the weights. is someone can help me?
And just another question: which of these fitting methods is the best:
-least square
-Least Absolute Residual
-Bisquare
ThanksHi laser81,
Thanks for posting your query on the National Instruments forums.
If you are new to LabVIEW then I would like to strongly recommend that you consider pursuing the LabVIEW Basics courses. The LabVIEW Basics 1: Introduction course is part of a series of courses designed to build your proficiency with LabVIEW and help you prepare for NI LabVIEW certification exams.
The courses offer:
The most efficient way to learn LabVIEW
Training courses for new and experienced users
Hands-on training with experienced LabVIEW instructors
Basics courses to help you get started quickly
Intermediate courses to help you learn how to optimize applications
Advanced courses to help you learn advanced features and architectures
The context help for linear fit VI in LabVIEW version 7.1 states:
Finds the line values and the set of linear coefficients slope and intercept, which describe the line that best represents the input data set using the least-squares solution.Finds the line values and the set of linear coefficients slope and intercept, which describe the line that best represents the input data set using the least-squares solution.
The context help for linear fit VI in LabVIEW version 8.2 states:
Returns the linear fit of a data set (X, Y) using the Least Square, Least Absolute Residual, or Bisquare method
If you then click the detailed help link in the context help window it will fire up the LabVIEW help document file where the help file explains the differences between Least Square, Absolute Residual and Bisquare method and equations are given.
I have attached the help file to this forum. Have you considered upgrading to the latest release of LabVIEW? It is jam packed with even more technology.
Check out the release notes for more information on what’s new with a particular release. Please goto www.ni.com/manuals
I have also found a similar discussion forum link that might be offer some help on the issue this explains a programmatic approach to curve fitting using low level VI’s in LabVIEW.
http://forums.ni.com/ni/board/message?board.id=170&message.id=181569&requireLogin=False
I hope this helps
Best Regards,
Kirtesh Mistry
National Instruments UK & Ireland -
Linear Fit Weight Input Modifying Control Input - Impossible? Bug?
I was having some strange data array issues with a program I was debugging and ended up distilling the issue to this. When "Linear Fit" is called twice it modifies the weight input array passed to it. Sounds crazy; but its true. I've been able reproduce this with a simple vi that I've attached.
The terrible thing is that if the weight array input is a control; its values will be modifed after calling Linear Fit. And if you've branched that wire and used its values for some other part of your program; the values on that wire will also change.
I'm using LV 8.5.1
I'd appreciate it if someone could verify this is happening on their machine. I'm too delirious from beating my head against the wall after tracking this down.
Milan
Attachments:
Linear Fit Test.vi 19 KB
Linear Fit Test capture.png 79 KBYou can also patch the problem by inserting an "always copy" primitive right before the linear fit. See attached.
Message Edited by altenbach on 12-15-2008 01:52 PM
LabVIEW Champion . Do more with less code and in less time .
Attachments:
LinFitpatch.png 11 KB
Linear_Fit_TestMOD.vi 20 KB -
I'm attempting to create a calibration program, using the printer port, and a Vernier Serial Box by modifying a calibration program designed for the serial box.
There are six calibration points, and to collect them, I have it controlled by while loops so that the numbers are taken when a button is pushed, and this is inside a sequence structure so that I can get the six different points. I feed these numbers into two different arrays (for x and y values) and then try to use the linear coefficient analysis on these points, but the values for the slope and intercepts it returns are not correc
t.
If I cut out the array and coefficient analysis, and feed the same numbers in directly without the while loop and sequence structures, it produces the proper values... I don't know why the numbers it is producing are different, and I'd really like to know.
Thanks,
Karinne.I would use a data manager sub-vi that would be called by each from of the sequence structure that produced a data point. The data manager sub-vi could auto append new items or could place items in a specific entry of an array. Later on when you want to calculate the linear fit, call the sub-vi to return the array of values.
Stu -
Rounding off net weight value.
Hi experts,
I want to round off the quantity value to the next integer value.
I am using the FM 'J_1I6_ROUND_TO_NEAREST_AMT' as follows...
call function 'J_1I6_ROUND_TO_NEAREST_AMT'
exporting
i_amount = gross_weight
i_amount1 = net_weight
importing
e_amount = gross_weight
e_amount1 = net_weight.
i want to round off the gross weight and net weight values.
In Global definitions, these are given as of type VEKP-BRGEW. The field BRGEW is of datatype QUAN (length - 15 and decimal -3 )
But when i tried executing i am getting dump .... saying
"The function module interface allows you to specify only
fields of a particular type under "I_AMOUNT".
The field "GROSS_WEIGHT" specified here is a different field type"
Please help me solve this and please let me know how to round off these fields.
Regards
AmmuHi,
the both fm parameters you fill have a currency data element of length 13, while you pass a quantity data element of length 15.
You can't use this fm for your fields.
Regards,
Klaus -
Limiting weight values to be transferred to target system
Hi All,
I have a requirement according to which I need to reduce the number of digits being passed to IDOC segmnet fields Z1BP_J_1BNFDOC-BRGEW and Z1BP_J_1BNFDOC-NTGEW. This IDOC will transfer data to a non-SAP target system. In the target system, the gross weight & net weight (BRGEW & NTGEW respectively having total length 13 with 3 decimal places in SAP) have mask: 9999999.99999 (7 digits before decimal and 5 digits after decimal). So the total digits that should be transferred to the target system should not be more than 12.
The method to achieve this, as suggested by functional, was to divide the weight values by 1000 instead of directly truncating the values so that there is no loss of data. For example, if the value in weight field is 123,234,432.000 KG, then on dividing it by 1000, it will result in 123,234.432 KG, which is correct. But using this method, if the number of digits in the weight field is less than 4 digits, for example, 123.000 KG, then on dividing this value by 1000, it will result in 0.123 KG, which is incorrect. And to avoid such a situation, if I apply a condition that the weight values should be divided by 1000 only when the number of digits before the decimal is more than 3, then I am facing the following issue:
Say, there is one value 123,4.000 KG, then in this case since the number of digits is more than 3 before the decimal, it will be divided by 1000, so we get: 1.234 KG. Now, there is another value say, 123.000 KG, then since in this case the number of digits before the decimal is 3, it will not be divided by 1000, so it will remain the same, that is, 123.000 KG. But comparing the two values, initially: 123,4.000 KG > 123.000 KG; and after applying the above logic: 1.234 KG < 123.000 KG, which is again incorrect.
Please suggest an appropriate solution.
Thanks & Regards,
AnkitReverse logic can figured out if boundary conditions are taken care of.
For input conversion, you are doing something like:
if input > 1000.
output = input / 1000.
endif.
Reverse case can be:
if frac( output ) > 0.
input = output * 1000.
endif.
FRAC function strips the integer part and gives only the fraction part.
Both logic would fail for specific cases.
Imagine 123KG becoming 123.000 KG as it is less than 1000.
On the other hand, 123,000 KG would also become 123.000 KG because input is greater than 1000.
When last 3 digits are anything other than 000, both input and output logic would work fine.
Tell your functional about above scenario.
Your requirement sounds really weird.
For exception cases, think about this.
Technically variable can store negative, but logically negative input weight may never come.
Whenever input ends with 000, can you apply negative sign and change 000 to 001, so that both logic work. -
Hello everyone
I am using Linear Fit.vi to calculate Slope. Are there guidelines to make the right choice for "weight", "tolerance" and "method" taking into consideration the kind of data?
Thanks.
Dan07.
Solved!
Go to Solution.Don't wire the weight unless you have additional information about the data. For example if you know the standard deviation of each point because it is derived from several measurements, or if there is a known relation between x and the noise in the data. For example if certain points have a larger error, you could downweight them accordingly. (common is weight = 1/variance, see also).
The method is not a plain U16 but an enum, to get a correctly typed input simply right-click the terminal and "create control" or "create constant".
Tolerance is only used for the iterative methods (least absolute residual, bisquare). These are most useful if you have outliers in the data. Just try a few values over a few orders of magnitude and see how the results vary.
For regular use, only wire the x and y arrays and leave everything else at the default.
LabVIEW Champion . Do more with less code and in less time . -
Bug in MSE output of General LS Linear Fit.vi?
Hi: In the General LS Linear Fit.vi, output MSE. Help for the vi describes the formula as (I attached a picture, but I'm not sure if it will appear in the post), but it looks like something is missing, because if I use the formula to my input values, I get a match only if all input Standard Deviations are 1's. As Standard Deviations increase, this formula gives me smaller MSE, higher MSE if Standard Deviations decrease; but I noticed MSE of the vi doesn't change so much, and every time all input Standard Deviations have the same value (no matter how large or small they are), MSE returns to the same original value.
According to the formula, MSE is inverse proportional to the square of Standard Deviations, no way to return to original value if they're changed. Is this formula correct or shuld it be different?
Attachments:
untitled6.jpg 5 KBHi, Karunya:
I actually rechecked my stuff, and I found that the formula that Mehak_D showed me in
MSE formula.JPG
is correct and really works. and the one I found in one of the LV 5 help files were wrong
untitled6.jpg
I'm attaching 2 pictures showing the LV5 Help file where I found it, as well as the Index where I clicked to open it. Just let me know if the formula were corrected in the Help file for later LV versions.
Thank you very much.
Attachments:
General LS Linear Fit Theory.jpg 96 KB
Help Index.jpg 34 KB -
Anyone here to help me how to use the linear fir vi?
Is this vi capable of analyzing a line with a negative slope?
What shold i input in this vi? I tried connecting my x and y arrays in this vi but still outputs nothing. Is there a bug on this vi?
Is there a way to fit a line in my data points like what excel does?
Thanks again for helping me numerous times.
Brein
Stuck againBrein wrote:
This is my vi. I am using labview 7.0 and vision 7.0. This project is about finding a relationship between concentration of a certain solution and its color value using rgb space. I am already able to plot the relation ship found in sequence structure 3 of 3(assuming the first sequence is 0 of 3). How to put a linear fit in my data points?
So you need to do a global fit to three datasets (R, G, & B). Since you seem to deal with a greyscale image, it is probably sufficient to fit only a single channel. What function do you use in excel?
Sorry, I don't have the vision module. Can you strip down your VI as follows:
create indicators on the three orange arrays in frame #2. (right-click wires, create indicator)
Run the VI so the indicators contain data.
Turn the indicators into diagram constants (right-click..change to constants). Wires will be broken, leave them broken!
Save the VI under a new name and attach it again.
I am quite busy today, maybe I can look at it tonight if nobody else gives a solution.
LabVIEW Champion . Do more with less code and in less time . -
I want to be able to graph both the data and the linear fit of the data stored in the chart buffer in real time. I can't seem to figure out how to split the x and y arrays from the output on the chart buffer. Any help would be appreciated. I have attached a sample program.
Solved!
Go to Solution.
Attachments:
Graph Test.vi 10 KBHeres one thing you could do:
Have your original data as two 1D arrays.
One is X values, and one is Y values.
Cluster those values together and that will be one data set.
Then, use the 'linear fit' function, and input your x and y arrays.
Use this new generated array of y-values and bundle them with the original array of x values.
If you build an array of the two data sets, then send them to an XY graph you should be all set.
Good luck :-)
Sorry I cant open your VI, Im in 8.2, not 8.6 :-(
Message Edited by Cory K on 02-16-2009 04:40 PM
Cory K
Attachments:
Linear Fit.PNG 5 KB -
I have some data that should follow a straight line, but there are spikes in
it. Rather than manually editing the data to remove the spikes, which is
tedious and time consuming, I wanted a function that would intelligently
decide which datapoints were bad and zap them.
Initially I thought this would be trivial; do the fit, calculate residuals
and zap all data lying further than one standard deviation from the line.
However, the spikes are sufficiently large that they can skew the linear
fit, and hence the determination of which points to drop. Doing a threshold
zap on the raw data isn't adequate since the values of the data aren't
sufficiently consistent between sets.
I tried differentiating the residuals- and in another attempt the straight
line data- reasoning that the differential should be constant everywhere
other than around the spike, and a simple thresholding would then tell me
which data to kill. Again no success; the data either side of the spike are
far from the constant line, the data of the spike itself are not.
The approach I've settled with is to do the linear fit on all the data, get
the MSE, zap the first datapoint and get the MSE, replace the first and zap
the second and so on until I have a table showing the effect of removing
each individual datapoint on the overall fit quality. I then find the most
significant datapoint, see if the effect of removing that gives a percentage
decrease in the MSE better than a user defined threshold, and then repeat
the process until either there are no more significant gains to be made or a
limit for the percentage of data that can be dropped is reached. To avoid
zapping down to two datapoints, I've chosen 50% as the maximum number of
points to lose and 50% as the increase in fit quality required to justify
the loss of a data point.
This works well, but it means that if there are n datapoints, n linear fits
must be carried out for each data point dropped. Execution time is therefore
going to increase exponentially with the data size, which always worries me
slightly.
One thing I've already thought of is the possibility of zapping more than
one point per iteration; however the fit changes so much when a single
outlier is removed that I suspect valid data may be lost this way.
Does anyone have any other suggestions to zap erroneous data without zapping
good data? This technique is fine for small datasets, and I guess the
threshold-based zapping is fine for large datasets, where the loss of a few
points changes the fit only very little, but if I ever need to do this on
data in the intermediate region I might have to start playing about again.
Craig Graham
Physicist/Labview Programmer
Lancaster University, UKI have a question about your approach:
Does "ZAP" mean that you are going to completely "delete" the outlier point or to "modify" it? Be advise that if you completely delete an outlier, your resulting data will be shifted to the right from that point, and thus your resulting data will no longer resemble a straight line.
www.vartortech.com -
Hi
I compiled my application from LabView 7.1.1 to LabView 8.5.1. This application use the "General LS Linear Fit.vi". I noticed that there differences in the calculation of the coefficients.
There are attached two files, one comiled in LV7.1.1 and the other with LV 8.5.1, with two different results. Please make sure you open this files with the correct version.
If I change in "General LS Linear Fit.vi" the link to the lvanlys.dll of the LV7.1.1 version, the calculations are correct.
Any help would be appreciated, thanks.
FilHi André
I think the results in the 8.5 Version are completely wrong. If the result would deviate a few percent one could say that the new version could be more exact. But not like that.
Fil
Attachments:
calc_71.JPG 154 KB
calc_85.JPG 184 KB -
Equal weighting AND Unequal weighting in Vendor Evaluation ?
Hi Experts,
Can u pls explain me this small issue with Vendor Evaluation weighting
SPRO - IMG - MM - PURCHASING - VENDOR EVALUATION - Maintain Purchasing Organization Data - SELECT PURCH .ORG -
DOUBLE CLICK ON Weighting - THERE IS I AM SEEING THIS LIST BELOW - Equal weighting AND Unequal weighting
REPETING. my client wants vendor evaluation Unequal . so i have to delet the Equal weighting 5 line or what to do ?
can u pls explain me.
01 Equal weighting 01 Price 1
01 Equal weighting 02 Quality 1
01 Equal weighting 03 fecha/cantidad 1
01 Equal weighting 04 Serviceservicio 1
01 Equal weighting 05 servicio 1
02 Unequal weighting 01 Price 1
02 Unequal weighting 02 Quality 1
02 Unequal weighting 03 fecha/cantidad 2
02 Unequal weighting 04 Serviceservicio 1
02 Unequal weighting 05 servicio 1
Thanksin Advance,
Anthyodaya.Hi Priyanka,
thank you for the reply . but finalley my question is
my client wants Unequal weighting .
so i have to delete that Equal weighting lines or not .?
i mean line of below list .which is in BOLD letters. ?
01 Equal weighting 01 Price 1
01 Equal weighting 02 Quality 1
01 Equal weighting 03 fecha/cantidad 1
01 Equal weighting 04 Serviceservicio 1
01 Equal weighting 05 servicio 1
02 Unequal weighting 01 Price 1
02 Unequal weighting 02 Quality 1
02 Unequal weighting 03 fecha/cantidad 2
02 Unequal weighting 04 Serviceservicio 1
02 Unequal weighting 05 servicio 1
can u pls explain me.
Thanksin Advance,
Anthyodaya. -
Linear Fit using Bisquare method fails on certain data sets.
I noticed some behavior that I didn't understand, so I thought I'd post it. I'm using Linear Fit.vi in LabVIEW 8.2 to calculate a slope and offset. This VI has a method input that accepts an enum. When I select the "Bisquare" method on some data sets I get error -20104 (Analysis: Input parameters have at least one NaN element). I think that if some data sets don't work with certain algorithms, this should be mentioned in the help. This took quite some time to track down.
Here is an example of a data set that doesn't work with Linear Fit.
X: Y:
0.40336656 -4.04062388
0.20171238 -2.01997989
0.00072204 -0.00951483
-0.20006598 1.99094268
-0.39979904 3.99578023I can reproduce the problem.
Interestingly, it works fine if you increase the tolerance input a little bit, e.g. to 0.0004 (from the default 0.0001). It also starts working if you change the data a little bit.
Curious that it works on the Mac. There must be something pathalogical with this exact data set. Maybe it cause an unhandled division by zero in one of the iterations.
LabVIEW Champion . Do more with less code and in less time . -
Linear fit between two cursors from a signal from a NI-instruments via DAQ-Assistant
Hi !
I'm currently having som problem with my labview code. I'm trying to make regression on a specific part of my graph. The graph consist of a signal gathered from a NI cDAQ-9178. Currently I can get the live data in a graph (Raw Signal) and then "zoom in" to the part of the graph that im intrested in by two cursors and then display the results in a new graph (Adjusted Signal). Now a want to make regresion in the new graph. How can i do this the best way ?
To be noted I'm a beginner of labview so my code maybe a bit off.
Best regards Maurlind
Solved!
Go to Solution.
Attachments:
Rawsignal test.vi 245 KB
rawsignal test.png 64 KBHi maurlind,
I got it, the function that derived the linear fit couldn't handle that large numbers on the x-axis. I edited the VI so that the large number is suctracted for the fit, i.e. the array will now begin at zero time for the fit. It will not affect your plots though, only the algorithm .
Try it now with the files I provided. The file "pm_mod2_Rawsignal test.vi" should be used with "test3.lvm" (your data). The file "pm_mod3_Rawsignal test.vi" is the same as "pm_mod2_Rawsignal test.vi", but it is arranged to work with the simulated data. The file "test3.lvm" is your data, but the file is slightly edited to work on my system.
Edit "pm_mod3_Rawsignal test.vi" to fit with your acquired signal as you did with the first file you got from me.
Attachments:
1412794.zip 483 KB
Maybe you are looking for
-
Multiple iTunes on External Hard Drive?
I am wondering if I can have multiple iTunes libraries on a Maxtor External Hard Drive? My husband has one for his desktop and there is PLENTY of space and now my laptop is low on disk space so I need to move my iTunes to an external drive as well. I
-
HI, I have a labview program which loads default values of all the variables from a .xml file when executed. I am trying to build a standalone '.exe application' using (Tools Menu --> Build Application from VI) , however I am not sure where to incl
-
Hey everyone, Here is my problem: -I am shooting a movie on a Panasonic hx200: it's in 720p60 -I am using the FS-100 drive to record the media -When going to view the footage in Quicktime 7.5.5, I get a solid black screen with audio. Quicktime then a
-
What is an appropriate method to use spool data for further processing?
Hello SCN! First of all, i am new to both: ABAP & SCN. So please be considerate I have a given spool and want to search for specific error lines in it to use the information for futher processing. I already serached for answers, but maybe with the wr
-
Don't know what to do to restore Please help