cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X

Curve fitting of a complex function

Gigiont
1-Newbie

Curve fitting of a complex function

Hello,
I'm trying to fit the imaginary component of an electrical impedance as a function of the real component. Both depend on frequency and I don't see how to express explicitly the imaginary component as a function of the real one.
To do the fit I tried to use a solve block and minimize the residuals for both real and imaginary parts but the result is not that good. Also all the parameters' values need to be positive. I understand that this may not give the best fit, but why MathCad ignores the constraint "Lsc>0"?
I there a better way to fit Im(Re, parameters)?
Thanks,
Gigi
63 REPLIES 63
StuartBruff
23-Emerald II
(To:Gigiont)

On 12/8/2009 3:38:47 PM, gigiont wrote:
== I'm trying to fit the imaginary component of an
electrical impedance as a function of the real
component. Both depend on frequency and I don't
see how to express explicitly the imaginary
component as a function of the real one.
== To do the fit I tried to use a solve block and
minimize the residuals for both real and imaginary
parts but the result is not that good. Also all
the parameters' values need to be positive. I
understand that this may not give the best fit,
but why MathCad ignores the constraint "Lsc>0"?
== I there a better way to fit Im(Re, parameters)?

I looked at your worksheet before looking at
Tom's. As Tom says, it is usually better to work
directly with complex numbers. To try and get the
values as 'real' as possible, I've introduced a
scaling factor that emphasizes the importance of
the real part. I then take the real part of the
answer and evaluate that. Seems to give closeish
answers but could doubtless be improved.

Interesting differences between M11 and M14.

Stuart

This problem is extremely simple if the ordinary electrical theory formulas are used.

Tom and Stuart,
thank you very much. Then the mean square error of the fit, taking only the real part of the parameters, can be minimized by changing the value of the scaling factor.
The final fit is quite good but you say "doubtless could be improved": are there more "tricks" (oh sorry, one should be careful in using this word these days...) one can use?
Thanks,
Gigi

Why can't you post a circuit diagram showing how the parts are wired together? My work was utterly too simple, now that I see the problem. There are endless possibilities of 1-pole, 2-pole, 4-pole, filters, etc. that can model your measurted data.

On 12/9/2009 9:18:04 AM, study wrote:
>This problem is extremely
>simple if the ordinary
>electrical theory formulas are
>used.
________________________________

Totally correct: complex components produce complex value, or compose complexly. Some Fourier transforms may be needed.

jmG



I am not certain I am right - but here is an attempt to your request.

Further experimentation gave a plot of the real part vs. the imaginary plot in a novel form. The trick was to develop an empirical linear equation for the frequency. Be sute to examiune the plot at the end of the worksheet.



A search on-line for a worksheet to find the complex roots of a complex non-polynomial function did not turn up anything. The MathCad (root) function can be used to search for them, and a follow up with a coincidence plot reveals the thinned out and eliminated repeat values.

There were errors on the final graph that have been corrected.

More editing and a discussion of conjugate root pairs of a simple real function, then complex roots of complex non-poly functions.



On 12/8/2009 3:38:47 PM, gigiont wrote:
>Hello,
>I'm trying to fit the
>imaginary component of an
>electrical impedance as a
>function of the real
>component. Both depend on
>frequency and I don't see how
>to express explicitly the
>imaginary component as a
>function of the real one.
>To do the fit I tried to use a
>solve block and minimize the
>residuals for both real and
>imaginary parts but the result
>is not that good. Also all the
>parameters' values need to be
>positive. I understand that
>this may not give the best
>fit, but why MathCad ignores
>the constraint "Lsc>0"?
>I there a better way to fit
>Im(Re, parameters)?
>Thanks,
>Gigi
______________________________

I scrolled down the work sheet saved by Tom [XX1563]
I don't understand the data set and doubt even more that you can fit it with this approach. You need a model, in the worst case, easy to generate a populated data set using NURBS.

Did you ask for help to fit ?

jmG




The project starts here:
1. remove and ignore the units
2. collect the variables
3. log function for the plot

If you can't approach manually ?
Maybe the model is not correct.
The solver might be incorrectly set.

jmG

I will leave it there with a manual fit
on part of the data set, data set not trustable.
That kind of looping reminds me something, what ?

jmG

I think that the attached give a general model about how to handle a minimization problem with a complex function with real parameters.

Regards. Alvaro.

Done.

Regards. Alvaro.

On 4/17/2010 6:53:19 AM, adiaz wrote:
>Done.
>
>Regards. Alvaro.
____________________________________

Smoothing data in a fitting session is an heresy. The ksmooth might be applied in Fourier fitting as a decision making. The other unique case I have found is the Carbon 12 data. Each of the Mathcad built-in smoother is very limited in application. Two of them deserve consideration: the Paul W SVG an the ksmooth. The Mathcad Built-in ksmooth is the traditional Gaussian, it works well up until it fails. It is a quick built-in tool but again in the case of the Carbon 12, it fails.
This project is back before square 0:
a Mathcad work sheet w/o a data table.



Your model [or Kristjan model] fits well enough some columns but not all, thus proving the model is insufficient. My linfit model is an "�bauche" but inherently more powerful, flexible and faster. It does not seem to fit all as well. It can be generalised to be a "linfit Cheby", but to early considering the data set. Data are just data but normally they come sorted from collection, though this is not a general rule. In fact, experiments may be carried with poor accuracy and still carry the information. In that case, data aren't then sorted, a conjectural case that Mathcad manages pretty well.
So, reach my � page below Marlett and experiment the two options: sorted and not sorted. I'm willing for an act of faith but only one out of several: Not sorted, both sorted, vx sorted, vy sorted. My other act of faith is that you have only ordinates vs an index, that gives sense to the project for a "Gaussian" model or a "linfit Cheby". Again the data column should be truncated, many values are meaningless.

Hope it helps to reconsider the project.

jmG

... why not consider the relationship between the two figurative columns,
i.e: simple ratio, or indexed ratio.
So many interpretations !
"fit", but fit what in there.

Ratio and indexed ratio added.

jmG

... You can investigate the project and discover that the linfit [that may be insufficient] is a good explorer. You will realise that the data don't all go sorted or unsorted.
2, 3, 4, 6 are shuffled [say: don't fit]
5, 7 ... 14 go sorted
15 ... 20 go unsorted.

Conclusion: all experiments must be done again, following a single procedure, data must be supplied raw [as collected]. Make sure the setup is "technical or scientific" and the lab equipment adequate. This project is a "pseudo project", i.e: a false project. At least you know where it stands ... to be done again. There is no point trying to make data mean something if they don't.

jmG


Just Jean's linfit model added.

Regards. Alvaro.

On 4/18/2010 5:14:12 PM, adiaz wrote:
>Just Jean's linfit model
>added.
>
>Regards. Alvaro.
_________________________

Thanks Alvaro,

3 in one, pretty smart. I don't understand why the column of the frequency is so noisy. The measured is always � noisy but with the independent also noisy does not help. The lab tests aren't reliable enough. At least up to this point this fitting session is not productive. I'm still willing for another act of faith about the data set itself, but Kristjan must help in telling what to believe ... don't you think so ?

Jean



Hello,

thank you!
I will measure again and try to get better results.
All I would like to ask you is: please accept this type of model I did propose in my first post here.
I can use only this type of models. The model has to be a kind of circuit model, otherwise there is no interpretation available in electrical terms (well, for me at least).
Let`s say: in the first step of my project I need here a fitting using an electrical circuit model consisting of impedances of CPE (constant phase elements). The definition was there
I will come back with better data (hopefully).

KL

Hello,

thank you!
I will measure again and try to get better results.
All I would like to ask you is: please accept this type of model I did propose in my first post here.
I can use only this type of models. The model has to be a kind of circuit model, otherwise there is no interpretation available in electrical terms (well, for me at least).
Let`s say: in the first step of my project I need here a fitting using an electrical circuit model consisting of impedances of CPE (constant phase elements). The definition of it was proposed here in the beginning of this thread. Find it below in the attachment.
I will come back with better data (hopefully).

KL

I guess you can draw the circuit model and then compose a math formula for it. Having done that, whatever is the use of trying to run it yourself and then ask the Forum to approve. The modern printed circuits are nowhere like that model, which is about 60 years old.

You must take into account all the guidances you are given:

Start by the beginning ... you MUST zap your Excel data table and plug the data as collected in a Mathcad input table. Your Excel table is truncated and can't be opened as per the image error message few threads ago. The result is that on that two columns in the sheet, there are 6 duplicates, that I have removed manually.

Next: if the X column is frequency as you pretend, why is it not collected over a linear split rather than like it rains ?

What is the relationship between the Y's and X's ... are they just like that or is there an unknown to be discovered relationship [Y/X ....]

Is Y's sorted only, X's sorted only, both sorted ? Look at the plot. Strictly following Alvaro help in your circuit and the solution of it, the independent variate 'f' does not reach the end of the X's ... your circuit or the fit of it saturates and drops dead .

In the other thread, I have proved that some columns go sorted, some don't. So, make sure you carry the experiment yourself rather than taking from unknown experimenter. Before entering all these gyzmatic decorations, can't you not make it visible X, Y, n1,2,3 subscripted as a,b,c.

When I read gyzmas, my brain dilutes.

Assuming data are not sorted, then again, the single model fits only some columns ... the conclusion is quite clear: you must design another model or several more models.

jmG

PS: reduce your image ... I did.
Please use "logspace" on that long range.

Comments added.

Alvaro.

PS: Data is ordered by time, the new independent variable (even it can be analized in the time domain) it's the frequency, which is in decreasing order. All other can't be sorted individually, only all toghether: augmenting, sorting by column, and then assigninig each column to one row vector of values.

On 4/19/2010 6:39:06 PM, adiaz wrote:
>Comments added.
>
>Alvaro.
>
>PS: Data is ordered by time,
>the new independent variable
>(even it can be analyzed in
>the time domain) it's the
>frequency, which is in
>decreasing order. All other
>can't be sorted individually,
>only all together:
>augmenting, sorting by column,
>and then assigning each
>column to one row vector of
>values.
______________________________

" ... it's the frequency, which is in decreasing order"

In fact, lot worse than that. The model does not start a the minimum frequency, it runs down and it stops before the 2nd segment can catch.

5.897 e 10^5 ... 150 :::: 9.051 e 10^5 ... 1.138 e 10^6

The model winds in a weird way.
The source and material would help.

jmG

On 4/20/2010 9:42:10 PM, jmG wrote:
>On 4/19/2010 6:39:06 PM, adiaz wrote:
>>Comments added.
>>
>>Alvaro.
>>
>>PS: Data is ordered by time,
>>the new independent variable
>>(even it can be analyzed in
>>the time domain) it's the
>>frequency, which is in
>>decreasing order. All other
>>can't be sorted individually,
>>only all together:
>>augmenting, sorting by column,
>>and then assigning each
>>column to one row vector of
>>values.
>______________________________
>
>" ... it's the frequency, which is in
>decreasing order"
>
>In fact, lot worse than that. The model
>does not start a the minimum frequency,
>it runs down and it stops before the 2nd
>segment can catch.
>
>5.897 e 10^5 ... 150 :::: 9.051 e 10^5
>... 1.138 e 10^6
>
>The model winds in a weird way.
>The source and material would help.
>
>jmG
___________________________________

This is the final fit. You can use either: continued fraction, partial fraction, rational fraction. As you can see, the lab is in cause ... probably all of them: inadequate procedure, bad collection, insufficient test equipment, the "object" being tested. My opinion goes another route [a route of no commerce], the data aren't genuine, they have been forged. This is a very, more than very serious assertion easy to support and prove.

CPE = "Constant Phase Element".
No idea what that is, if has a mathematical equivalent.

jmG



hello jmG,

do not expect much from me ... unfortunately too stupid .) No cure for the stupidity, only the grave helps.
Please find new data. I put here the excel table where they are. There you see short explanations in the top of the columns (frequency, real part, imaginary part etc.)

In earlier data the disaster at lower frequencies was due to the bad shielding of the sample: the Faraday cage was left half open and outer fields became interfering.
Still two last curves (at voltages +0.9 and +1 V) have this problem. This is not clear why there again. But this is not accidental, this happens again and again.
At higher frequencies (around 100 kHz) the device makes some noise like switching and three subsequent measurement points go out from the smooth trace. No cure for that yet.

KL

It turned out that this switching effect can be relieved by not allowing a certain block of the device to operate during the measurement.
These strange two curves with unhappy low frequency results also had their explanation: my friendly colleagues had interfered during the time I was out of the lab!
They eagerly looked inside the Faraday cage during the measurement and did not close it correctly!
I will post other results tomorrow. My wife is fighting with our boys at home. She seeds backup forces there.

KL

These data that will be posted here, are the best at the moment.
This switching trouble remains, but this seems to be a specific trouble of the device used. I have heard many complaints from many people in connection with this.
KL
Top Tags