s-news
[Top] [All Lists]

multiplication problem - what happens at 46341?

To: s-news@lists.biostat.wustl.edu
Subject: multiplication problem - what happens at 46341?
From: Henrik Parn <henrik.parn@bio.ntnu.no>
Date: Fri, 03 Mar 2006 19:20:59 +0100
Organization: NTNU
Reply-to: henrik.parn@bio.ntnu.no
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.3) Gecko/20040910
Dear all,

Why can't calculate 46341*46341 using '*'? I must have missed something very basic...

> 46340.99999*46340.99999
[1] 2147488280
> 46341*46341
[1] NA
> 4.6341E4
[1] 46341
> 4.6341E4*4.6341E4
[1] 2147488281
> 46341^2
[1] 2147488281

My function of for unbiased skew (Sokal & Rohlf 3ed p 115) involves a multiplication, and when my samples are 'big' the answer is just 'NA' due to the problem described above:

skew.sokal <- function(x){
   m3 <- length(x) * sum((x-mean(x))^3)/((length(x)-1)*(length(x)-2))
   s3 <- sqrt(var(x))^3
   m3/s3}

> x <-  rnorm(46342)
> skew.sokal(x)
[1] 0.0101318
> x <-  rnorm(46342)
> skew.sokal(x)
[1] -0.00613662
> x <-  rnorm(46343)
> skew.sokal(x)
[1] NA

Thanks in advance for any suggestion! And sorry if I have overseen something basic...
S-plus 6.2 Build 6713
WinXP

--
************************
Henrik Pärn
Department of Biology
NTNU
7491 Trondheim
Norway

+47 735 96282 (office)
+47 909 89 255 (mobile)
+47 735 96100 (fax)
************************


<Prev in Thread] Current Thread [Next in Thread>