List of usage examples for org.apache.commons.math3.distribution NormalDistribution sample
@Override public double sample()
From source file:org.ranksys.novdiv.reranking.DitheringReranker.java
@Override public int[] rerankPermutation(Recommendation<U, I> recommendation, int maxLength) { List<Tuple2od<I>> items = recommendation.getItems(); int M = items.size(); int N = min(maxLength, M); if (variance == 0.0) { return getBasePerm(N); }/*from w ww.j av a 2s. co m*/ NormalDistribution dist = new NormalDistribution(0.0, sqrt(variance)); IntDoubleTopN topN = new IntDoubleTopN(N); for (int i = 0; i < M; i++) { topN.add(M - i, log(i + 1) + dist.sample()); } topN.sort(); return topN.stream().mapToInt(e -> M - e.v1).toArray(); }