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: [mg44125] Re: Summation Problem w/ 5.0
  • From: Paul Abbott <paul at physics.uwa.edu.au>
  • Date: Thu, 23 Oct 2003 07:15:47 -0400 (EDT)
  • Organization: The University of Western Australia
  • References: <bllp1h$c11$1@smc.vnet.net> <bmoda0$hph$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

In article <bmoda0$hph$1 at smc.vnet.net>,
 andrea.knorr at engr.uconn.edu (Andrea) wrote:

> 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.  

To run or even test minfcn, the form of this data is required.

> 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
>       ];

This code (a form of Kermack-MacKendrick disease model?), can be 
improved as follows. First, I think that it is better to use DSolve up 
find the numerical solution (up to the maximum time required) as 
interpolating functions:

  titer[lambda_, beta_, d_, k_, a_, u_][{xtime_,ytime_,vtime_}] := 

   Module[{x, y, v}, 
      
      {x, y, v} /. First[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, Max[{xtime,ytime,vtime}]}]]

   ]

(You probably should use scaling to reduce the size of the initial 
values, say from 10^9 to 1). In this way, a solution (note again that 
scaling would help), e.g.,

   endtimes = {100,120,150};

   nsol = titer[10^7, 5 10^-10, 0.1, 500, 0.5, 5][endtimes]

can be plotted (here v is scaled by 10^(-2)),

  Plot[Evaluate[{1, 1, 10^(-2)} Through[nsol[t]]], 
   {t, 0, Min[endtimes]}, PlotRange -> All, 
   PlotStyle -> {Hue[0], Hue[1/3], Hue[1/2]}]; 

and then separately compute the endpoints

  calcs = Inner[Compose, nsol, endtimes, List]

> 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.

I do not understand the problem you are encountering. Values for 
"virus", "infected", and "uninfected" might help ...

Cheers,
Paul

-- 
Paul Abbott                                   Phone: +61 8 9380 2734
School of Physics, M013                         Fax: +61 8 9380 1014
The University of Western Australia      (CRICOS Provider No 00126G)         
35 Stirling Highway
Crawley WA 6009                      mailto:paul at physics.uwa.edu.au 
AUSTRALIA                            http://physics.uwa.edu.au/~paul


  • Prev by Date: Re: Integrate piecewise with Assumptions
  • Next by Date: Re: Concentric contours about the centroid, having the same length, and interior to an initial contour.
  • Previous by thread: Re: Summation Problem w/ 5.0
  • Next by thread: Airy's Gi(x) function; asymptotic matching and asymptotic limits