Buggy code:
public class Nystrom implements DataTransform { private static final long serialVersionUID = - 3227844260130709773L ; private KernelTrick k ; private List < Vec > basisVecs ; private List < Double > accelCache ; private Matrix transform ; public enum SamplingMethod { UNIFORM , DIAGONAL , NORM , KMEANS ; } public Nystrom ( KernelTrick k , DataSet dataset , int basisSize , Nystrom . SamplingMethod method ) { } @ SuppressWarnings ( "fallthrough" ) public Nystrom ( KernelTrick k , DataSet dataset , int basisSize , Nystrom . SamplingMethod method , double ridge , boolean sampleWithReplacment ) { } protected Nystrom ( Nystrom toCopy ) { } public static List < Vec > sampleBasisVectors ( KernelTrick k , DataSet dataset , final List < Vec > X , Nystrom . SamplingMethod method , int basisSize , boolean sampleWithReplacment , Random rand ) { List < Vec > basisVecs = new ArrayList < Vec > ( basisSize ) ; final int N = dataset . getSampleSize ( ) ; switch ( method ) { case DIAGONAL : double [ ] diags = new double [ N ] ; diags [ 0 ] = k . eval ( X . get ( 0 ) , X . get ( 0 ) ) ; for ( int i = 1 ; i < N ; i ++ ) <START_BUG> diags [ i ] = ( diags [ 0 ] ) + ( k . eval ( X . get ( i ) , X . get ( i ) ) ) ; <END_BUG> Nystrom . sample ( basisSize , rand , diags , X , sampleWithReplacment , basisVecs ) ; break ; case NORM : double [ ] norms = new double [ N ] ; List < Vec > gramVecs = new ArrayList < Vec > ( ) ; for ( int i = 0 ; i < N ; i ++ ) gramVecs . add ( new DenseVector ( N ) ) ; List < Double > tmpCache = k . getAccelerationCache ( X ) ; for ( int i = 0 ; i < N ; i ++ ) { gramVecs . get ( i ) . set ( i , k . eval ( i , i , X , tmpCache ) ) ; for ( int j = i + 1 ; j < N ; j ++ ) { double val = k . eval ( i , j , X , tmpCache ) ; gramVecs . get ( i ) . set ( j , val ) ; gramVecs . get ( j ) . set ( i , val ) ; } } norms [ 0 ] = gramVecs . get ( 0 ) . pNorm ( 2 ) ; for ( int i = 1 ; i < ( gramVecs . size ( ) ) ; i ++ ) norms [ i ] = ( norms [ ( i - 1 ) ] ) + ( gramVecs . get ( i ) . pNorm ( 2 ) ) ; Nystrom . sample ( basisSize , rand , norms , X , sampleWithReplacment , basisVecs ) ; break ; case KMEANS : HamerlyKMeans kMeans = new HamerlyKMeans ( new EuclideanDistance ( ) , SeedSelection . KPP ) ; kMeans . setStoreMeans ( true ) ; kMeans . cluster ( dataset , basisSize ) ; basisVecs . addAll ( kMeans . getMeans ( ) ) ; break ; case UNIFORM : default : if ( sampleWithReplacment ) { Set < Integer > sampled = new IntSet ( basisSize ) ; while ( ( sampled . size ( ) ) < basisSize ) sampled . add ( rand . nextInt ( N ) ) ; for ( int indx : sampled ) basisVecs . add ( X . get ( indx ) ) ; } else for ( int i = 0 ; i < basisSize ; i ++ ) basisVecs . add ( X . get ( rand . nextInt ( N ) ) ) ; } return basisVecs ; } private static void sample ( int basisSize , Random rand , double [ ] weightSume , List < Vec > X , boolean sampleWithReplacment , List < Vec > basisVecs ) { } @ Override public DataPoint transform ( DataPoint dp ) { } @ Override public Nystrom clone ( ) { } public static class NystromTransformFactory extends DataTransformFactoryParm { private double ridge ; @ ParameterHolder private KernelTrick k ; private int dimension ; private Nystrom . SamplingMethod method ; private boolean sampleWithReplacment ; public NystromTransformFactory ( KernelTrick k , int dimension , Nystrom . SamplingMethod method , double ridge , boolean sampleWithReplacment ) { } public NystromTransformFactory ( Nystrom . NystromTransformFactory toCopy ) { } public void setRidge ( double ridge ) { } public double getRidge ( ) { } public void setDimension ( int dimension ) { } public int getDimension ( ) { } public void setBasisSamplingMethod ( Nystrom . SamplingMethod method ) { } public Nystrom . SamplingMethod getBasisSamplingMethod ( ) { } @ Override public DataTransform getTransform ( DataSet dataset ) { } @ Override public Nystrom . NystromTransformFactory clone ( ) { } } }

Fix:
diags [ i ] = ( diags [ ( i - 1 ) ] ) + ( k . eval ( X . get ( i ) , X . get ( i ) ) ) ;