Subscribe Bookmark RSS Feed

Nonlinear Script

hockswender

Community Trekker

Joined:

Jul 9, 2012

Performing NLR via the Platform on a data table generates the expected results (see Croucher http://... [didnt see how to attach table but I can send as needed.]

I have used similar scripts [change data and equation] with no issue.

Any thoughts?

The equation section of the script is:  Parameter( {b0 = 1, b1 = 0.2},
 b0 * Cosine( b1 * :X ) + b1 * Sine( b0 * :X ))

Clear Log(); Clear Globals();
xv = [     -2,  -1.64,  -1.33,    -.07,      0,     0.45,    1.2,    1.64,     2.32, 2.9];
yv = [.699369,.700462,.695354,1.030905,1.97389,2.411430,1.910910,0.919576,-0.770975,-1.42001];
	
dt = New Table( "Croucher Data",
	New Column( "x", SetValues( xv ) ),
	New Column( "y", SetValues( yv ) ),   
	
); //close New Table

dt << 
Nonlinear(
	Y( :y ),
	X( :x ),
	Model( Parameter( {b0 = 1., b1 = 0.2},
	  b0 * Cosine( b1 * :x ) + b1 * Sine( b0 * :x ) ) ),
	QuasiNewton SR1,Finish,plot(1),
	Confidence Limits
);//close NonLinear

 

1 ACCEPTED SOLUTION

Accepted Solutions
ms

Super User

Joined:

Jun 23, 2011

Solution

Your script works well. There a slight difference in the input data if compared with the linked example (cf. xv[4] & yv[9]). 

 

It is also possible to do this nonlinear fit without using the platform:

Model = Expr(
    b0 * Cosine(b1 * xv) + b1 * Sine(b0 * xv)
);

xv = [-2, -1.64, -1.33, -0.7, 0, 0.45, 1.2, 1.64, 2.32, 2.9];
yv = [0.699369, 0.700462, 0.695354, 1.03905, 1.97389, 2.41143, 1.91091, 0.919576, -0.730975, -1.42001];	

b0 = 1;
b1 = 0.2;
SSE = Minimize(Sum((Model - yv) ^ 2), {b0, b1});
Eval List({b0, b1, SSE});

 

4 REPLIES
ms

Super User

Joined:

Jun 23, 2011

Solution

Your script works well. There a slight difference in the input data if compared with the linked example (cf. xv[4] & yv[9]). 

 

It is also possible to do this nonlinear fit without using the platform:

Model = Expr(
    b0 * Cosine(b1 * xv) + b1 * Sine(b0 * xv)
);

xv = [-2, -1.64, -1.33, -0.7, 0, 0.45, 1.2, 1.64, 2.32, 2.9];
yv = [0.699369, 0.700462, 0.695354, 1.03905, 1.97389, 2.41143, 1.91091, 0.919576, -0.730975, -1.42001];	

b0 = 1;
b1 = 0.2;
SSE = Minimize(Sum((Model - yv) ^ 2), {b0, b1});
Eval List({b0, b1, SSE});

 

hockswender

Community Trekker

Joined:

Jul 9, 2012

Thanks much for the script. It works fine for me. I've not used that function much but it obviously is ideal for many models.

ian_jmp

Staff

Joined:

Jun 23, 2011

Looks like one of your x values should be -0.7, not -0.07,

 

hockswender

Community Trekker

Joined:

Jul 9, 2012

Thanks, typing issue! I fixed them for my file.