T O P I C R E V I E W |
palmieri2 |
Posted - 01/04/2018 : 2:15:05 PM Hello!
I am trying to create a parameter initialization code for my user-defined function (aka the Avrami equation):
y=1-e^((-k*x)^n)
I converted the equation to the linear form:
ln(ln(1/(1-y))) = ln(k) + nln(x)
Then, following the PI help guide, created the following code:
{ sort( x_y_curve ); Dataset dx; x_y_curve.AttachX(dx); dx = ln(x); x_y_curve = ln(ln(1/(1- x_y_curve )); vector coeff(2); fitpoly(x_data, y_data, 1, coeff); k = exp( coeff[0] ); n = coeff[1]; }
The code compiles without any errors, but I think the 1 in my y definition is causing some issues with the definition of the parameters. Help appreciated!
|
9 L A T E S T R E P L I E S (Newest First) |
palmieri2 |
Posted - 01/10/2018 : 12:44:38 PM Hello,
I have been working in Origin 8, but have access to Origin 2017. The problem I am having in Origin 2017 is that I cannot use both the code I have already generated for initializing n and k while also using a built-in function to determine A. I may be wrong, but I do not think the built-in functions can help me determine n and k which are derived from the linear form of my model equation. This would then require that I define A using code.
Additionally, the yatxmax function isn't quite what I'm looking for. I need the extrapolated y value of the horizontal asymptote that my curve approaches at very large values of x. It is impractical for me to acquire data at these extremes, so I need to extrapolate the value.
Thank you for your continued help everyone!
-Paige |
snowli |
Posted - 01/09/2018 : 4:32:23 PM Hello Paige,
Which version of Origin are you using? Since Origin 2017, we provide some pre-defined formula for parameter initialization so user doesn't have to write code. E.g. When defining a fitting function, i can choose "Y at X Max" to initialize parameter A to be Y value at max X.
Also see this blog http://blog.originlab.com/data-analysis/use-initial-formula-to-better-guess-fitting-parameter-values-from-data
Thanks, Snow
quote: Originally posted by palmieri2
Hi,
The equation is the one Castiel mentioned.
I do have one additional question: I would like to add a parameter A so my new equation is y=A*(1-exp(-k*x^n)) where A = y when x approaches infinity.
I think my best bet is to use the initialization function Curve_yfromX to extrapolate a value for A given a very large value of x (say 10,000), but I am having issues initializing this parameter.
My code for that step is: A = Curve_yfromX( x_y_curve ,10000);
Advice here? Thank you again for your help! I apologize for that silly mistake and the extra work you did because of it.
-Paige |
palmieri2 |
Posted - 01/09/2018 : 3:16:11 PM Hi,
The equation is the one Castiel mentioned.
I do have one additional question: I would like to add a parameter A so my new equation is y=A*(1-exp(-k*x^n)) where A = y when x approaches infinity.
I think my best bet is to use the initialization function Curve_yfromX to extrapolate a value for A given a very large value of x (say 10,000), but I am having issues initializing this parameter.
My code for that step is: A = Curve_yfromX( x_y_curve ,10000);
Advice here? Thank you again for your help! I apologize for that silly mistake and the extra work you did because of it.
-Paige |
yuki_wu |
Posted - 01/08/2018 : 9:23:17 PM Hi Paige,
You better check which equation is the user-defined function you desired at first. Is the original equation you posted or the one Castiel mentioned? If it is the original one, you can set a bound to make sure k < 0.
More info about fitpoly function: https://www.originlab.com/doc/OriginC/ref/Fitpoly-GlobalFunction
Regards, Yuki OriginLab
|
Castiel |
Posted - 01/08/2018 : 8:45:20 PM quote: Originally posted by palmieri2
I am trying to create a parameter initialization code for my user-defined function (aka the Avrami equation):
y=1-e^((-k*x)^n)
That is NOT Avrami equation. Have a try of this: y = 1 - e^(-k * x^n)
#####
#### _\_ ________
##=-[.].]| \
#( _\ | |------|
# __| | ||||||||
\ _/ | ||||||||
.--'--'-. | | ____ |
/ __ `|__|[o__o]|
_(____nm_______ /____\____
|
palmieri2 |
Posted - 01/08/2018 : 1:48:57 PM Hi,
I'm sorry, I don't think that is correct. All of the sources I can find say the linear form should be as I've listed it. Plus, you cannot have a log of a negative number as you have in your transformation.
Could you please tell me more about the coeff and fitpoly commands in my code? I'm not sure that I have built that part of the code properly for my particular function.
Best, Paige |
yuki_wu |
Posted - 01/08/2018 : 01:16:41 AM Hi,
I just found you made a mistake in the transformation: The equation should be transformed as: ln(ln(1-y)) = n ln(-k) + n ln(x) So the code should be modified:
{
sort( x_y_curve );
Dataset dx;
x_y_curve.AttachX(dx);
dx = ln(dx);
x_y_curve = ln(ln(1- x_y_curve));
vector coeff(2);
fitpoly(x_data, y_data, 1, coeff);
n = coeff[1];
k = -exp( coeff[0]/n );
}
Regards, Yuki OriginLab
|
palmieri2 |
Posted - 01/05/2018 : 09:20:46 AM Hi Yuki,
I'm sorry for the lack of clarity.
The fit does not converge with my dataset and the code's output values for k and n are not what I'd expect (looking for n ~ 3 and k ~ 0.015 but I'm getting n ~ 0.66 and k ~ 7*10^-7). |
yuki_wu |
Posted - 01/04/2018 : 9:48:55 PM Hi, I am sorry that I cannot understand your question fully. You said the code compiles without any errors, so anything else wrong? Are the fit results not good?
Regards, Yuki OriginLab
|