[R] Computational problems in R

Xiaoxu LI lixiaoxu at gmail.com
Fri Oct 24 21:43:57 CEST 2008


I think you should try one X for A/X=sum(exp(c_i/d -log(X)))
The optional X could be as the following ...

## to test ### C = c(c_i/d; i=1,2,...,n)
n<-1000;
C<-runif(n,700,1000);
#####################

M<-1;while (2*M < Inf) M<-2*M;
X<- exp(max(C) - log (M/n));
cat('A=',sum(exp(C-log(X))),'*',X)


On Sat, Oct 25, 2008 at 12:42 AM, A.Noufaily <A.Noufaily at open.ac.uk> wrote:
>
> Dear all,
>
> I would be grateful if anyone can help me with the following:
>
> My aim is to compute explicitely the sum S=A+B where A=sum(exp(c_i/d)),
> i=1,...,n;
> B, c_i, and d are real numbers with -Inf<B,c_i<+Inf; and d>0.
> The problem is that when c_i/d >710 (for some i) R is setting
> exp(c_i/d) to be equal to +Inf and hence the whole summation S.
> So in simple cases where for example c_i=8 (for some i), and d=0.01 the
> whole summation is turning out to be infinite.
> Is there a way to get round that in R?
> Can anyone suggest any computational trick to calculate S when c_i/d>710
> (for some i)?
>
> Any suggestions would be much appreciated.
>
> Regards,
>
> Amy
>
>
>
>
>
> ---------------------------------
> The Open University is incorporated by Royal Charter (RC 000391), an exempt charity in England & Wales and a charity registered in Scotland (SC 038302).
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at 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.
>



More information about the R-help mailing list