Sorry, indeed I forgot to put some of the factors in the code. Here it  
is again, now updated:

calcurve <- cbind(1:2e4, 1:2e4, rep(100, length=2e4));

caldist <- function(cage, error, sdev=2, times=5, By=1)
  {
   calcurve <- calcurve[which((calcurve[,2]+calcurve[,3]) >=  
cage-(times*error)),];
   calcurve <- calcurve[which((calcurve[,2]-calcurve[,3]) <=  
cage+(times*error)),];
   theta <- seq(min(calcurve[,1]), max(calcurve[,1]), by=By);

   interpolate <- function(th, col)
    {
     if(th==calcurve[1,1]) {calcurve[1,col]}else
     if(th==calcurve[nrow(calcurve),1]) {calcurve[nrow(calcurve),col]}else
      {
       k <- min(which(calcurve[,1] > th));
       slope <-  
(calcurve[k-1,col]-calcurve[k,col])/(calcurve[k-1,1]-calcurve[k,1]);
       calcurve[k-1,col] + slope*(th-calcurve[k-1,1]);
      }
    }

   mu <- c();
   cerror <- c();
   for(i in 1:length(theta))
    {
     mu[i] <- interpolate(theta[i],2);
     cerror[i] <- interpolate(theta[i],3);
    }

   caldist <- dnorm(mu, cage, (error^2+cerror^2)^.5);
   cbind(theta, caldist/sum(caldist));
  }

caldist(2450,50);

Strangely enough the stacking error message seems not to happen every  
time. It also has happened on the WinXP partition of the same Toshiba  
laptop. So it is not as reproducible as I first hoped/feared.

-- 
Dr. Maarten Blaauw
School of Geography, Archaeology & Palaeoecology
Queen's University Belfast, U.K.
On leave from Department of Earth Sciences
Uppsala University, Sweden
[EMAIL PROTECTED]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to