MathGroup Archive 2003

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Summation Problem w/ 5.0

  • To: mathgroup at smc.vnet.net
  • Subject: [mg44005] Re: Summation Problem w/ 5.0
  • From: andrea.knorr at engr.uconn.edu (Andrea)
  • Date: Fri, 17 Oct 2003 05:14:30 -0400 (EDT)
  • References: <bllp1h$c11$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

I've been asked to post a bit of code to help explain.  I didn't post
it originally since it's so long.

I've imported several .csv files, and grouped several elements into
the lists "virus", "infected", and "uninfected", which are blood
concentrations.  "vtime", "ytime", and "xtime" are the corresponding
points in time for when the concentrations were measured.  Below is
the relevant code, which is basically for nonlinear regression:


titer[lambda_, beta_, d_, k_, a_, u_] :=
    
    Module[{soln, x, y, v, valueslist, xeval, yeval, veval}, 
      
      soln = NDSolve[{
            x'[t] == lambda - d x[t] - beta x[t] v[t],
            y'[t] == beta x[t] v[t] - a y[t],
            v'[t] == k y[t] - u v[t], 
            x[0] == 10^9, y[0] == 0, v[0] == 10^9},
          {x, y, v}, {t, 0, 2500}];
      
      xtiter = Evaluate[x[xtime] /. soln];
      ytiter = Evaluate[y[ytime] /. soln];
      vtiter = Evaluate[v[vtime] /. soln];
      
      values = Table[Flatten[{xtiter, ytiter, vtiter}, 1]];
      values
      ];

calcs = titer[10^7, 5*10^-10, 0.1, 500, 0.5, 5];

minfcn[lambda_, beta_, d_, k_, a_, u_] :=
  
  Module[{i, j},
    
    diffsum = 
      Sum[10000*(uninfected[[i, 2]] - calcs[[1, i]])^2 + 
            10000*(infected[[i, 2]] - calcs[[2, i]])^2, {i, 
            Length[uninfected]}] + 
        Sum[(virus[[j, 2]] - calcs[[3, j]])^2, {j, Length[virus]}];
    diffsum
    ]

minfcn[10^7, 5*10^-10, 0.1, 500, 0.5, 5]



When I evaluate "minfcn" with the values listed above, which are
"correct" published values, that's where I get my problem.  If I
change the minfcn problem so that the sum doesn't cover the full
length of each list, but rather only up to a particular element, I get
one number.  Any summation past that point results in the problem I
have described below.



andrea.knorr at engr.uconn.edu (Andrea) wrote in message news:<bllp1h$c11$1 at smc.vnet.net>...
> Has anyone else had this problem with the new version?  I have created
> multiple lists with multiple elements, and I am trying to sum all
> elements of all lists.  As output I don't get a single value; instead
> I get several numbers separated by a plus sign.  For example, instead
> of Mathematica giving "2" as output, I get "1+1".  I'm pretty sure my
> code is correct, because if I stop my sum at a given element, I get a
> single number, but if I continue beyond that element I get output as I
> have described above.
> 
> (FYI, I'm using Mac OSX, version 10.2.6).
> 
> Thanks in advance for any help.
> ~Andrea


  • Prev by Date: RE: help with specify histogram count axis (frequency)
  • Next by Date: RE: Get rounds values in alist
  • Previous by thread: Re: Summation Problem w/ 5.0
  • Next by thread: Re: Summation Problem w/ 5.0