[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to implement a summation function for numerical solving?

From: andrewcd
Subject: Re: How to implement a summation function for numerical solving?
Date: Wed, 15 Jun 2011 07:21:12 -0700 (PDT)

Thanks everybody for all of your help so far.  Now I have a new problem --
fsolve is highly sensitive to the initial "guess" vector.  I guess that it
is not iterating enough, or something.  Or, since it is guessing at the
value of an exponent, small changes by its standards lead to big changes in
my results.  Any thoughts on how I can get around this?  Increase the number
of iterations somehow?  Or is there a different way to solve simultaneous
nonlinear equations?

To get a flavor for my problem, try to run my code below, using guess =
[.5,0] and guess = [0,0].  The code *should* eventually spit out a normal
curve with a mean and variance of 2.  But the wrong guess gives the wrong

Thanks again, and thanks in advance.

clear all

global mu;
global x;
global lx;
global xmin;
global variance;
AT = .5;
xmin = -10;
xmax = 10;
stp = .1;
x = xmin:stp:xmax;
lx = length(x);
mu = 2;
variance = 2;

guess = [.5,0]

function fcns = eqns(z);
global x;
global lx;
global mu;
global variance;
f1 = x;
f2 = (x-mu).^2;
p = exp(-lam1*f1 - lam2*f2) ;
fcns = [(f1-mu)*p', (f2-variance)*p'];

result = fsolve(@eqns, guess)

p = e.^(-result(1)*x - result(2)*(x-mu).^2);    

Z = sum(p);

plot( x, P);

c = cumsum(P);
for n = 1:length(c);
        if c(n)<AT;
                EV(n) = c(n);

L = length(EV);
EV = stp*L+xmin

View this message in context:
Sent from the Octave - General mailing list archive at

reply via email to

[Prev in Thread] Current Thread [Next in Thread]