The nonlinear Lev-Mar curve fit vi works but when changed to the constrained vi it does not fit. The Fit simple gamma variate demo shows this behavior.
I think the constrained version will be faster and would like to be able to use it.
Solved! Go to Solution.
Thanks. I was actually able to look at it on a VM with LabVIEW 2022.
The problem is that your x array and y arrays have different sizes. The non-constraint fit can gloss over that, but the constraint can't.
Your X array has 360 elements, while your Y array has 361 elements. Once you delete one element from Y, both fits succeed! Try it!
Here's what happens if I delete the last elements (of course you need to decide what needs to go).:
On a side note, here's a "near literal" translation of your model into graphical code. It is about 40% faster on my rig.
(Yours could probably be streamlined a bit more too if you would take some of the scalar calculations out of the loop. I have not tried, because I don't do text based code. 😄 )
That is a great help.
I had tried that too, but yours is a better implementation.
I have about 100K of these fits to do in a single brain scan so anything to speed things up helps a lot.
I think you really need to fit the raw sparse data instead of the derivative of splined data at a much finer (fake!) resolution. No need to resample with a much larger number of points that all directly depend on the original sparse data anyway. (I haven't studied how the function would look like.). I am sure it would be significantly faster, and more importantly, more honest. You cannot base your goodness of fit on 360 points if you actually only have 25!
You should really eliminate all these small loops because there is always the danger that they will never stop. For example in your "resample" code, the wile loop would never stop if the user would accidentally enter a negative interval. Not bulletproof!
Also, wiring [i] to index array is the same as autoindexing, no need to wire N.
I wanted to increase my timing resolution, hence the resampling.
Think about it -- by resampling, you are adding "guesses/estimates/values based on pre-set assumptions" on a fixed data set, then hoping to increase "timing resolution" based on the "real" and the "made-up/interpolated" data. If you attempted to publish this data and a reviewer who knew a bit of math and statistics saw it, you'd be in Deep Weed ...