Example usage for org.apache.mahout.math.random MultiNormal MultiNormal

List of usage examples for org.apache.mahout.math.random MultiNormal MultiNormal

Introduction

In this page you can find the example usage for org.apache.mahout.math.random MultiNormal MultiNormal.

Prototype

public MultiNormal(int dimension) 

Source Link

Usage

From source file:zx.soft.mahout.knn.search.AbstractSearchTest.java

License:Apache License

protected static Matrix randomData() {
    Matrix data = new DenseMatrix(1000, 20);
    MultiNormal gen = new MultiNormal(20);
    for (MatrixSlice slice : data) {
        slice.vector().assign(gen.sample());
    }/*from   ww  w .  j a v a  2  s .  c om*/
    return data;
}

From source file:zx.soft.mahout.knn.search.AbstractSearchTest.java

License:Apache License

@Test
public void testOrdering() {
    Matrix queries = new DenseMatrix(100, 20);
    MultiNormal gen = new MultiNormal(20);
    for (int i = 0; i < 100; i++) {
        queries.viewRow(i).assign(gen.sample());
    }//  ww  w  . j a v  a 2s.  c o m

    Searcher s = getSearch(20);
    // s.setSearchSize(200);
    s.addAllMatrixSlices(testData());

    for (MatrixSlice query : queries) {
        List<WeightedThing<Vector>> r = s.search(query.vector(), 200);
        double x = 0;
        for (WeightedThing<Vector> thing : r) {
            assertTrue("Scores must be monotonic increasing", thing.getWeight() > x);
            x = thing.getWeight();
        }
    }
}