SparseVector is part of Mahout actually. You may need the other libraries since some classes in Mahout import uncommons-math and hadoop classes.
The class javadoc is not very good here, but as you may suspect, the exception indicates the vector is not sized to let you set all these elements. Try "new SparseVector(4)" to create a vector with cardinality 4, if you wish to set 4 elements of the vector. On Sat, Sep 5, 2009 at 12:17 AM, Sven Boekhoff<[email protected]> wrote: > Would be enough for me to know, where in the documentation i can find which > implemantation is valid to be instatiated. I imported uncommons-math and > haddop (which is needed for this "SparseVector"), but stil it doesn't work. > > import org.apache.mahout.clustering.dirichlet.UncommonDistributions; > import org.apache.mahout.matrix.SparseVector; > import org.apache.mahout.matrix.Vector; > > public class Main { > > public static void main(String[] args) { > > Vector probabilities = new SparseVector(); > probabilities.set(0, 0.1); > probabilities.set(1, 0.2); > probabilities.set(2, 0.3); > probabilities.set(3, 0.4); > > // 100 Messpunkte > for(int i=0; i<100; i++) { > > Vector newCoordinates = > UncommonDistributions.rMultinom(100, probabilities); > > System.out.println(newCoordinates.size()); > > } > > } > > } > > it throws the error: > > Exception in thread "main" org.apache.mahout.matrix.IndexException > at > org.apache.mahout.matrix.AbstractVector.set(AbstractVector.java:142) > at Main.main(Main.java:12) >
