public static < A > double [ ] alphaBetaPWM ( A data , NumberArrayAdapter < ? , A > adapter , final int nmom ) { final int n = adapter . size ( data ) ; final double [ ] xmom = new double [ nmom << 1 ] ; double aweight = 1. / n , bweight = aweight ; for ( int i = 0 ; i < n ; i ++ ) { final double val = adapter . getDouble ( data , i ) ; xmom [ 0 ] += aweight * val ; xmom [ 1 ] += bweight * val ; for ( int j = 1 , k = 2 ; j < nmom ; j ++ , k += 2 ) { aweight *= ( n - i - j + 1 ) / ( n - j + 1 ) ; bweight *= ( i - j + 1 ) / ( n - j + 1 ) ; xmom [ k + 1 ] += aweight * val ; xmom [ k + 1 ] += bweight * val ; } } return xmom ; }
Compute the alpha_r and beta_r factors in parallel using the method of probability - weighted moments . Usually cheaper than computing them separately .