@Override public void consume(List<Datum> records) throws Exception { if (!hasConsumed) { n = records.get(0).metrics().getDimension(); mean = new ArrayRealVector(n); covV = new ArrayRealVector(n, 1d/n); covM = new DiagonalMatrix(covV.toArray()); mnd = new MultivariateNormalDistribution(mean.toArray(), covM.getData()); mnd.reseedRandomGenerator(randomSeed); randomProjectionMatrix = new BlockRealMatrix(mnd.sample(k)); hasConsumed = true; } for (Datum d: records){ metricVector = d.metrics(); transformedVector = randomProjectionMatrix.operate(metricVector); output.add(new Datum(d,transformedVector)); } }