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

Community Tip - Need help navigating or using the PTC Community? Contact the community team. X

Hi everyone, I would like to fit my data with the function describe on the file

ptc-4749353
1-Visitor

Hi everyone, I would like to fit my data with the function describe on the file

Please can you tell me what is wrong in my thinking to solve my problem. which is fit my data with the function which is describe in the file.

Thank you

37 REPLIES 37
Werner_E
25-Diamond I
(To:ptc-4749353)

See if the attached helps. Have concentrated on your question about y being a scalar as you expected a vector. The magic is done by using the vectorize command from the matrix palette.

Maybe looking at http://communities.ptc.com/message/197133#197133 can help to get a better fit. On the other hand, as far as I see, you are trying a simple exponential fit (a*e^b*x) and I doubt that thats appropriate.

I was confused by some action you did in that sheet and its a little bit messy, so maybe I overlooked some detail.

OK. I will try to think more. Thank

Hi . Please why I could not see the value of f(x,ag) when I evaluate. when I do the operation I - f(x,ag) I don't have a result. This is because of the function f(x,ag).

thank

Werner_E
25-Diamond I
(To:ptc-4749353)

Patrick Seumo schrieb:

Hi . Please why I could not see the value of f(x,ag) when I evaluate. when I do the operation I - f(x,ag) I don't have a result. This is because of the function f(x,ag).

thank

Thinks thats because ag is e 2-element vector and you had written your function f with single arguments (f(x,a0,a1). So you could use f(x,ag[0,ag[1). I feel its better to rewrite f to accept a vector of parameters as second argument. I did it in the other sheet of yours and explained why here: http://communities.ptc.com/message/197137#197137

Hi

Please, I transformed the function f to a vector but it is still impossible to sustract I and f(x,ag). I have sent the file of my work.

Thank you

Werner_E
25-Diamond I
(To:ptc-4749353)

Patrick Seumo schrieb:

Hi

Please, I transformed the function f to a vector but it is still impossible to sustract I and f(x,ag). I have sent the file of my work.

Thank you

I is a vector, f is a function. You could either turn I into a function or (simpler) f into a vector by applying the vector timescan as parameter:

subtraction.png

Thank you for explanation you gave to me. now I now to transform a function to a vector.

I have another question, how did you do to have the guess value. what guide you? because I see that when I change the guess value, my fitting can be very wrong. other question is that how to transform a vector to a function.

Thank you

Werner_E
25-Diamond I
(To:ptc-4749353)

Turning I into a function would be a trick and not recommended thing. You would either have to program a function where you would have to make use of timescan, too, or you could try some kind of approximation/interpolation. It was only a theoretical idea to make clear, that both, I and f, have to be of the same "type" to be able to plot the difference.

According to the choice of the guess values - I lack the experience as I seldom have to use methods like genfit. I guess that chosing good guess values is always a tricky thing and it helps a lot if you know about the background of your functions (which I don't in case of your chemical reactions).

BTW, in your sheet you had set the number of decimal places for ALL results to zero (with exception to the symbolic one) - was that on purpose?

The sheet now seems to be for the identical problem as the one provided here: http://communities.ptc.com/message/197133#197133 - are there any differences? At least the fit values are identical.

One additional remark: It was unnecessary for the whole genfit process to vectorize f at the top. But when it comes to plotting f with vector timescan as parameter it is important you did so, as in your function f there is a product (simplified something the form e^x * e^x) which would otherwise be interpreted as inner vector product and f(timesscan,ag) would simplify to a single constant. Vectorizing at this stage fails - i am not sure why, but I guess this is because ag, too, is a vector.

Thank you for explanation. I think that instead of used genfit I can also use the residuals as you show me 4 gaussians??

Werner_E
25-Diamond I
(To:ptc-4749353)

Think Richard was quite helpful there http://communities.ptc.com/message/190719#190719

Hi!

I want to know why for example the position of this function doesn't change. or event the heigth of the function doesn't change.

I ask this question because I have tried to fit the subtration (I - f) between 0 to 30. but it seems to me that the position is fixed.

Thank you

Hi

I have tried a new fitting using your help.

This is the best fitting I have obtained. according to my guess value of course. I would like to know if you can have much better than mine.

Thank you

Werner_E
25-Diamond I
(To:ptc-4749353)

No, playing a bit around with the guess values I didn't come to a closer fit - either the one you found or totally unusable "solutions".

If you look at your fit function, you see that af0 is a scaling factor only. So af1 alone is responsible for the overall shape and so for most of the fitting work. That in mind the fit you found isn't that bad for this fitting function with only two parameters. f1 seems to slide the graph in horizontal direction combined with some scaling. The width seems to stay rather unchanged, so the bad fit.

With only two parameters to work in your fit functions I guess you can't ask genfit for anything better.

Hi,

I have another problem. I would like to present the fitting but with the data in that way (please see attached file).

Thank you

Werner_E
25-Diamond I
(To:ptc-4749353)

Patrick Seumo schrieb:

Hi,

I have another problem. I would like to present the fitting but with the data in that way (please see attached file).

Thank you

What is the problem? Reading data from an excel sheet or genfitting the data? In your last example the provided fit function wasn't that suitable for the data provided and the results therefore were unsatisfying.

It is about the fitting with the function that I have write. the proble is that the curve starts to another side.

Thank you

Werner_E
25-Diamond I
(To:ptc-4749353)

Patrick Seumo schrieb:

It is about the fitting with the function that I have write. the proble is that the curve starts to another side.

Thank you

Not clear what you mean. You sure should post a worksheet.

Werner_E
25-Diamond I
(To:ptc-4749353)

Still not sure what the problem is, but as I found a sheet from yours in an older post I took a fit function which looks like the one you had used but added additional parameters to fit. The one in your prior post had to few which made for a really bad fit.

This is what I came up with - fits pretty well, I think.

fit3.png

jkowalski
12-Amethyst
(To:Werner_E)

In Mathematica result is the same

Werner_E
25-Diamond I
(To:jkowalski)

Jan Kowalski schrieb:

In Mathematica result is the same

But without guess values. Mathcad is very sensible about these in this example. If I change the values in the direction of the (now known) outcome, genfit either fails to converge or I get the error that MC had found a number with magnitude greater than 10^307. So I seemed to have been just lucky with my guess values.

Not lets see if the original poster is happy with four instead of only two parameters in the fit function.

jkowalski
12-Amethyst
(To:Werner_E)

No need to guess in Mathematica.This is in the software. I'm use the function NMinimize


"Use Method->NMinimize to search more exhaustively for a global minimum"

a few little changes, result is see attach->

Werner_E
25-Diamond I
(To:jkowalski)

Jan Kowalski schrieb:

No need to guess in Mathematica.This is in the software. I'm use the function NMinimize

Yes, I know. Was just about to point out that drawback of Mathcad

Please

is it a programm or what? is it Mathcad?

I don't understand anything here.

Werner_E
25-Diamond I
(To:ptc-4749353)

Patrick Seumo schrieb:

Please

is it a programm or what? is it Mathcad?

I don't understand anything here.

As you hadn't provided a fit function to work with (guess you forgot to include your worksheet) I created a solution based on a previous sheet of yours, but gave the genfit a better chance for a better solution as I provide four parameters to play with instead of the two you allowed in your last sheet. You find that solution above http://communities.ptc.com/message/198781#198781.

Jan did the same with Mathematica, that's another (or better: that's THE) math program and arrived at the same solution. Mathematice needs no guess values even when asked to do a numerical solve, while Mathcad, as you know, needs guess values for ist numerical solve. I found these guess value to be very sensitive and ever so often genfit wouldn't find a solution after a small change, That was the reason I provided a second way to find a fit using minerr (http://communities.ptc.com/message/198811#198811).

Please see attached the function.

Werner_E
25-Diamond I
(To:ptc-4749353)

Patrick Seumo schrieb:

Please see attached the function.

No need to post twice. I had alread seen your file and commented on it. See here: http://communities.ptc.com/message/198855#198855

Werner_E
25-Diamond I
(To:ptc-4749353)

Find attached an enhanced version of the previous sheet in which I have added a solution using a solve block with MinErr. Its less sensible wrt to guess values, but basically finds the same solution.

jkowalski
12-Amethyst
(To:Werner_E)

Hi. I have seen your file but I am lost.

Please see what I have done and try to correct my file. the guesser is tricky to have.

Thank

Announcements

Top Tags