List of usage examples for weka.core.matrix Matrix random
public static Matrix random(int m, int n)
From source file:org.mitre.clustering.AffinityPropagation.java
License:Open Source License
public AffinityPropagation(Matrix sims, int max, int cons, double lambda, double p) { s = sims;/*from w w w . j a v a 2s. c om*/ maxits = max; convits = cons; lam = lambda; count = s.getColumnDimension(); /* * Add noise to get rid of degeneracies */ Matrix rand = Matrix.random(count, count); Matrix small = new Matrix(count, count, .0000001); Matrix t = s.times(Double.MIN_VALUE).plus(small); t = t.times(rand); s = s.plus(t); /* * Put preferences on diagonal of S */ for (int i = 0; i < count; i++) { s.set(i, i, p); } try { run(); } catch (Exception ex) { ex.printStackTrace(); } }