[R] Strange integer result on Debian/amd64

Dave Ewart davee at ceu.ox.ac.uk
Wed Mar 21 10:35:51 CET 2007


On Wednesday, 21.03.2007 at 09:29 +0000, Prof Brian Ripley wrote:

> >OK, I understand the problem now.  I was wondering if it something along
> >those lines, but initially dismissed that as a possibility since I
> >expected 'choose' to be an integer calculation.
> 
> It is not, because it would be far too easy to get integer overflow.

Yes, of course.  And, also, as I have now remembered, it is perfectly
feasible to use non-integer parameters to n-choose-k as well.

It is clearly too long since I did my Stats degrees *blush*

> >However, the underlying problem that gave rise to the difficulty was as
> >follows.  A colleague wishes to create a matrix, where one of the
> >dimensions of the matrix is the result of the 'choose' function, i.e.
> >
> > mycols<-choose(11,6)
> > a_matrix<-matrix(0,nrow=11,ncol=mycols)
> >
> >Clearly, 'ncol' casts mycols as as integer.  In this case, a_matrix has
> >only 461 columns, not 462.
> >
> >What's the best way to make this work as required?
> 
> Use round(mycols).  I think we ought to do this internally: we do when 
> using computations via beta/gamma functions.

*nods* - thanks.

Dave.
-- 
Dave Ewart
davee at ceu.ox.ac.uk
Computing Manager, Cancer Epidemiology Unit
Cancer Research UK / Oxford University
PGP: CC70 1883 BD92 E665 B840 118B 6E94 2CFD 694D E370
Get key from http://www.ceu.ox.ac.uk/~davee/davee-ceu-ox-ac-uk.asc
N 51.7518, W 1.2016
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: Digital signature
Url : https://stat.ethz.ch/pipermail/r-help/attachments/20070321/6596b470/attachment.bin 


More information about the R-help mailing list