qt grace non linear fitting
Oct 15, 2023
example of non linear curve fitting using qt grace
Yes, it's a screen capture and also here's our voices, so this will all be recorded.
So to do it, you have to grab your data first, right?
So let's grab like a data set, like this negative 11, C1 and negative C2, right?
So those are both .dat files.
So we can input those, you go to data, go to import, ASCII, you have to tell it where
those are at.
So let's tell it it's in our download file, and there they are.
So doing that didn't actually select it, so you actually have to now input it.
We have to tell it what type it is, so this should just be an XY file, but if you had
like X, error bar X, Y, error bar Y, you'd have to change what type it is here, and there's
lots of different ones to pick from.
Ours is simple, it's just an XY.
So take this, move it over, and let me see if it actually does it correctly, and you
hit OK.
OK, so it grabbed it, and that looks more or less OK, except I'm a little bit worried
about that.
I think that we didn't grab it at the right time.
So we probably need to fix that before we try and fit the data to it.
Let's grab this one, and let's input it, and it's the same.
So both of those, we've got to grab it at the right spot.
So just get it just at the minimum.
I think what we want to do is find the point at which it monotonically increases, and the
point, the very last point before it starts to monotonically increase, that's our zero.
So we should probably go back and edit that.
Sure.
So I can go in and do that, but just show me how it would fit.
OK, regardless, this is how you'd fit it though.
So now you've got the data in there, you can close this.
So great, we've got two data sets.
So here then you go to Data, Transformations, Nonlinear Curve Fitting.
So Nonlinear Curve Fitting.
From here, we need to create...
So here's where the data is going to come from, the source and destination, right?
Source, destination.
So we're going to actually apply our curve to some data set, this one or that one, and
we're going to send it somewhere.
But right now, the only data sets it has are the same ones that we're starting with.
So we need to create two new data sets, right?
So let's...
I think we can just clone these.
OK, we'll just duplicate those.
Let's try it.
Anyways, we're going to take from this data set, and we're going to send it to that one.
OK.
So what's our equation?
Well, it's going to be 1 minus exponential of negative...
You have to use variable names that are a0, a1, a2, a3, you can't call it k and n.
So we want to fix n and just solve for k, so we're going to call this negative a underscore
zero.
I'll double check that.
We might need to Google it.
I think that's what it's supposed to be called.
Times x.
X is not t.
It's time, right?
That's what we have on our x, right?
And then raised to the whatever our exponent was.
So you have that here.
This is c1, so that's for charging.
So the n value.
So you want to use for charging averages 1.272, right?
So let's do raised to 1.272, like that.
Does that give us a positive curve?
It does, doesn't it?
I think this is right.
So then we have to tell it how many parameters, k1, a0, we might need to write it like that.
I don't know.
Well, I don't remember.
Let's try it.
And then you have to tell it a rough starting point and how many iterations, like a least
square for regression.
Try it a bunch of times to get the best fit.
Let's just leave it as is, but we should give it a decent starting point.
Do you have the data of what our starting point values were?
If you go, so we're at 11, right?
What k should be to start with.
That's another file.
If you don't give it a good starting point, it struggles.
Let's pull that up from our other one.
So we go to drive, group, research, and then go to...
If you give it a starting point, it does much better.
And so this is just a k, like the estimated one that we talked about earlier?
Yeah.
It's not going to be very different, right?
So for charging at negative 11, it was somewhere around like 1, e to the negative 2, roughly.
I think I should see it.
1.3, e to the negative 3.
So let's just do 1, e to the negative 3.
That should find it.
Okay.
So 1.
And let's try this.
I think it didn't like our variable.
It didn't like a.
I think we have to call that a zero.
Let's try that.
Let's try this.
Okay.
It did it.
The correlation coefficient is 0.998.
It means it's a good fit.
Pretty good.
Right?
Even with that little bump at the bottom, right?
Oh, yeah.
It's still fitting most of the data correctly.
It's just messing up.
So you don't really care if this goes on for a long time flat up top?
No.
You don't care about that?
I don't know.
I don't know the best way to think about that.
This should fit that, regardless, right?
That curve does that.
But my issue is that each data set has a different amount of data that's flat lined, right?
Right.
And so it's going to place different emphasis on that.
Like some data sets, it's going to take, let's say, like 1.3, 1.3, 1.3, 1.3, 1.3,
So I don't know the best way to do that.
So let's just take our data as it is and do it now.
Okay.
Do it.
But what I'll do is I'll go in and I'll just start it at the minimum.
Okay.
So if it's worth it on the other curves, if it goes down, as soon as it reaches that minimum,
if it starts to go back up.
Same.
Stop it.
Okay.
Stop it.
Yeah.
So I can go through and do that.
And then...
Or you can...
So...
And then...
I mean, I think this is good for the video.
As far as fitting the curves, that's fine.
Yeah.
Okay.
So I'm going to go through and do that.
And then...
Or you can...
So...
And then...
I mean, I think this is good for the video.
As far as fitting the curves, that's fine.
Okay.
So I'm going to go through and do that.
And then...

