The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Parameter initialization within a NLSF loop

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
hauli Posted - 11/14/2006 : 03:03:47 AM
Origin Version (Select Help-->About Origin): 7.5
Operating System: Windows XP

Dear All,

I am using a user defined equation (named logECF) that has 3 parameters; one parameter should vary from 5 to 95 step 5 and is fixed during the fit as in the code below.

The problem is concerned with parameter initialization: as the equation is very sensitive to good initial values, I want to use the fitting results of the first loop to be used as the initial values for the second loop, the results of the second loop as initial values for the third loop, and so on.

my second question is how to apply correctly to the fitting result of the (let's say) 7th loop, i.e the value of NLSF.p3 of the 7th loop?

void test()
{
int FF;
for (FF=5; FF<=95; FF+=5)
{
using NLSF = LabTalk.NLSF;
NLSF.Init();
NLSF.Begin();
NLSF.Func$="logECF";
NLSF.FitData$="Data1_B";
NLSF.p1=0.3;
NLSF.p2=FF;
NLSF.p3=-3;
NLSF.v2=0;
NLSF.IterateEx(100);
NLSF.IterateEx(100);
NLSF.ParamWks();
NLSF.PasteParams("P");
NLSF.KeepParam=1;
NLSF.End(4);
}
}

Thanks for any suggestions

Hauli

3   L A T E S T    R E P L I E S    (Newest First)
zachary_origin Posted - 11/14/2006 : 08:43:57 AM
Sorry, I have not looked carefully into the code you wrote. Have you noticed that there is a line "NLSF.v2 = 0;"? you can see from Origin Programming Help:

nlsf.vn : Tells whether parameter n is fixed or allowed to vary during fitting: 1 = vary, 0 = fixed. (You can fix a parameter using linear constraints.)

I think you must have used the options wrong. It should be NLSF.v2 = 1;. In fact, by fault the parameter will be allowed to vary without any specification.

Another thing is why you use NLSF.IterateEx(100) twice? you can replace it with NLSF.IterateEx(200).

Zachary
OriginLab Technical Services.
hauli Posted - 11/14/2006 : 05:57:01 AM
Dear Zachary,

I tried your code, thank you for that.
it performs 19 consecutive fits (as I want)
but unfortunately with NLSF.p2 always fixed to 5.
Any idea?

I will try to use your suggestion and write a piece
of initial code for the equation

Hauli

zachary_origin Posted - 11/14/2006 : 04:08:33 AM
Hi Hauli,

How about this? Add some vectors to record all the fitted parameters?
I rewrote the function, is this what you wanted?


void test()
{
// int FF;
vector vP1(20), vP2(20), vP3(20);//these vectors will record the fitted paramters.
int ii;
for (ii=1; ii<=19; ii++)
{
using NLSF = LabTalk.NLSF;
NLSF.Init();
NLSF.Begin();
NLSF.Func$="logECF";
NLSF.FitData$="Data1_B";
if (ii == 1)
{
NLSF.p1=0.3;
NLSF.p2 = ii*5;//NLSF.p2=5; ??
NLSF.p3=-3;
}
else
{
// fitted parameter value in last loop, because ii starts as 1,
//so it is not ii-1 but ii-2;

NLSF.p1 = vP1[ii-2];
NLSF.p2 = vP2[ii-2];
NLSF.p3 = vP3[ii-2];
}
NLSF.v2=0;
NLSF.IterateEx(100);
NLSF.IterateEx(100);
NLSF.ParamWks();
NLSF.PasteParams("P");
NLSF.KeepParam=1;
NLSF.End(4);
//After fitting, record the paramters.
vP1[ii-1]=NLSF.p1;
vP2[ii-1]=NLSF.p2;
vP3[ii-1]=NLSF.p3;
}

//then you can use the fitted paramters for any loop by the parameter vectors.
double aa = vP3[6];//P3 for the 7th loop.
}


But I still do not think this is a good method for the problem. If the equation is very sensitive to initial values, you'd better write a piece of initial code for the equation. You can reference a similar build-in function to write it. If you have any problem for the code, you can post your equation here and we will try to write it for you.



Zachary
OriginLab Technical Services.

Edited by - zachary_origin on 11/14/2006 04:11:19 AM

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000