[R] Construct a lower-triangular matrix

peter dalgaard pdalgd at gmail.com
Sat Oct 10 15:21:20 CEST 2015


>> 
>> I'm also not buying the sqrt(length(a))+1 bit --- floor(2*length(a)) is more like it.
>> 
> 
> Shouldn’t that be
> 
> m <- sqrt(floor(2*length(a)))
> M <- matrix(0,m,m)
> 
> for the general case?
> 
> Berend
> 

Closer, but I actually meant:

floor(sqrt(2*length(a)))

if k is m*(m+1)/2, 2*k will be between m^2 and (m+1)^2, so sqrt(2*k) will be between m and m+1. QED.

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd.mes at cbs.dk  Priv: PDalgd at gmail.com



More information about the R-help mailing list