public static < A > double [ ] alphaPWM ( A data , NumberArrayAdapter < ? , A > adapter , final int nmom ) { final int n = adapter . size ( data ) ; final double [ ] xmom = new double [ nmom ] ; double weight = 1. / n ; for ( int i = 0 ; i < n ; i ++ ) { final double val = adapter . getDouble ( data , i ) ; xmom [ 0 ] += weight * val ; for ( int j = 1 ; j < nmom ; j ++ ) { weight *= ( n - i - j + 1 ) / ( n - j + 1 ) ; xmom [ j ] += weight * val ; } } return xmom ; }
Compute the alpha_r factors using the method of probability - weighted moments .