You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@mahout.apache.org by Sven Boekhoff <sv...@boekhoff.info> on 2009/09/04 14:04:36 UTC
Creating Multinomial Random numbers with Mahout
Hi.
I like to use the Mahout-Library to create multinomial random numbers
(strangely there is no other library available, as far as I know). I
tried several things, but nothing worked, and the documentation was not
very helpful for me (maybe because I'm a Java newbie). My last
sourcecode was:
//import java.util.Random;
//import java.util.Vector;
import org.apache.mahout.clustering.dirichlet.UncommonDistributions;
import org.apache.mahout.matrix.Vector;
public class Main {
public static void main(String[] args) {
//
http://lucene.apache.org/mahout/javadoc/core/index.html?org/apache/mahout/clustering/dirichlet/UncommonDistributions.html
Vector probabilities = new Vector();
/*
Vector<Float> probabilities = new Vector<Float>();
probabilities.add((float) 0.1);
probabilities.add((float) 0.2);
probabilities.add((float) 0.3);
probabilities.add((float) 0.4);
*/
// 100 Messpunkte
for(int i=0; i<100; i++) {
UncommonDistributions dist = (UncommonDistributions) new
Object();
// UncommonDistributions dist = new UncommonDistributions();
Vector newCoordinates = dist.rMultinom(100, probabilities);
}
}
}
I hope somebody can tell me how to use the library in a correct way. I'm
also searching for a library to create (multi-)HyperGeometric random
numbers.
Thanks in advance,
Sven
Re: Creating Multinomial Random numbers with Mahout
Posted by Ted Dunning <te...@gmail.com>.
All of our Vector classes implement Writable which immediately pulls in
Hadoop.
On Fri, Sep 4, 2009 at 4:22 PM, Sean Owen <sr...@gmail.com> wrote:
> SparseVector is part of Mahout actually. You may need the other
> libraries since some classes in Mahout import uncommons-math and
> hadoop classes.
>
--
Ted Dunning, CTO
DeepDyve
Re: Creating Multinomial Random numbers with Mahout
Posted by Sean Owen <sr...@gmail.com>.
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<sv...@boekhoff.info> 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)
>
Re: Creating Multinomial Random numbers with Mahout
Posted by Sven Boekhoff <sv...@boekhoff.info>.
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)
Sean Owen wrote:
> Well, sounds like you are loading classes that need Hadoop, and you
> have not put Hadoop in your classpath.
>
> These questions aren't particularly specific to Mahout -- I think
> you'd benefit from learning a bit more about how Java works first.
> It'll get you past a lot of small issues like this.
>
> On Fri, Sep 4, 2009 at 11:55 PM, Sven Boekhoff<sv...@boekhoff.info> wrote:
>> It does nor work.
>> It throws the error:
>>
>> Exception in thread "main" java.lang.NoClassDefFoundError:
>> org/apache/hadoop/io/Writable
>> at java.lang.ClassLoader.defineClass1(Native Method)
>> at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
>> at
>> java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
>> at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
>> at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
>> at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
>> at java.security.AccessController.doPrivileged(Native Method)
>> at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>> at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
>> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
>> at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
>> at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
>> Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.io.Writable
>> at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
>> at java.security.AccessController.doPrivileged(Native Method)
>> at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
>> at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
>> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
>> at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
>> at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
>> ... 12 more
>> Could not find the main class: Main. Program will exit.
>>
>> Do I need the hadoop library? This is not written in the requirements,...
>>
>>
>> Sean Owen wrote:
>>> I think you probably want to study basic Java first then or you're
>>> going to run into a lot more confusion.
>>>
>>> Vector probabilities = new SparseVector();
>>>
>>> is what you want. Interfaces and instantiating objects are the very
>>> basics of Java.
>>>
>>> On Fri, Sep 4, 2009 at 5:30 PM, Sven Boekhoff<sv...@boekhoff.info> wrote:
>>>> I never worked with interfaces.
>>>> And i also don't know what "instantiate an implementation" means.
>>>> How does it look like?
>>>>
>>>> Sean Owen wrote:
>>>>> Yes, Vector is an interface! You need to instantiate an implementation
>>>>> like DenseVector.
>>>>>
>>>>> On Fri, Sep 4, 2009 at 5:25 PM, Sven Boekhoff<sv...@boekhoff.info> wrote:
>>>>>> But i cant create an Vector object:
>>>>>>
>>>>>> Vector probabilities = new Vector();
>>>>>>
>>>>>> gives an error.
>>>>>>
Re: Creating Multinomial Random numbers with Mahout
Posted by Sean Owen <sr...@gmail.com>.
Well, sounds like you are loading classes that need Hadoop, and you
have not put Hadoop in your classpath.
These questions aren't particularly specific to Mahout -- I think
you'd benefit from learning a bit more about how Java works first.
It'll get you past a lot of small issues like this.
On Fri, Sep 4, 2009 at 11:55 PM, Sven Boekhoff<sv...@boekhoff.info> wrote:
> It does nor work.
> It throws the error:
>
> Exception in thread "main" java.lang.NoClassDefFoundError:
> org/apache/hadoop/io/Writable
> at java.lang.ClassLoader.defineClass1(Native Method)
> at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
> at
> java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
> at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
> at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
> at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
> at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
> Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.io.Writable
> at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
> at java.security.AccessController.doPrivileged(Native Method)
> at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
> at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
> at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
> at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
> ... 12 more
> Could not find the main class: Main. Program will exit.
>
> Do I need the hadoop library? This is not written in the requirements,...
>
>
> Sean Owen wrote:
>>
>> I think you probably want to study basic Java first then or you're
>> going to run into a lot more confusion.
>>
>> Vector probabilities = new SparseVector();
>>
>> is what you want. Interfaces and instantiating objects are the very
>> basics of Java.
>>
>> On Fri, Sep 4, 2009 at 5:30 PM, Sven Boekhoff<sv...@boekhoff.info> wrote:
>>>
>>> I never worked with interfaces.
>>> And i also don't know what "instantiate an implementation" means.
>>> How does it look like?
>>>
>>> Sean Owen wrote:
>>>>
>>>> Yes, Vector is an interface! You need to instantiate an implementation
>>>> like DenseVector.
>>>>
>>>> On Fri, Sep 4, 2009 at 5:25 PM, Sven Boekhoff<sv...@boekhoff.info> wrote:
>>>>>
>>>>> But i cant create an Vector object:
>>>>>
>>>>> Vector probabilities = new Vector();
>>>>>
>>>>> gives an error.
>>>>>
>
Re: Creating Multinomial Random numbers with Mahout
Posted by Ted Dunning <te...@gmail.com>.
Yes.
On Fri, Sep 4, 2009 at 3:55 PM, Sven Boekhoff <sv...@boekhoff.info> wrote:
> Do I need the hadoop library? This is not written in the requirements,...
--
Ted Dunning, CTO
DeepDyve
Re: Creating Multinomial Random numbers with Mahout
Posted by Sven Boekhoff <sv...@boekhoff.info>.
It does nor work.
It throws the error:
Exception in thread "main" java.lang.NoClassDefFoundError:
org/apache/hadoop/io/Writable
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.io.Writable
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
... 12 more
Could not find the main class: Main. Program will exit.
Do I need the hadoop library? This is not written in the requirements,...
Sean Owen wrote:
> I think you probably want to study basic Java first then or you're
> going to run into a lot more confusion.
>
> Vector probabilities = new SparseVector();
>
> is what you want. Interfaces and instantiating objects are the very
> basics of Java.
>
> On Fri, Sep 4, 2009 at 5:30 PM, Sven Boekhoff<sv...@boekhoff.info> wrote:
>> I never worked with interfaces.
>> And i also don't know what "instantiate an implementation" means.
>> How does it look like?
>>
>> Sean Owen wrote:
>>> Yes, Vector is an interface! You need to instantiate an implementation
>>> like DenseVector.
>>>
>>> On Fri, Sep 4, 2009 at 5:25 PM, Sven Boekhoff<sv...@boekhoff.info> wrote:
>>>> But i cant create an Vector object:
>>>>
>>>> Vector probabilities = new Vector();
>>>>
>>>> gives an error.
>>>>
Re: Creating Multinomial Random numbers with Mahout
Posted by Sean Owen <sr...@gmail.com>.
I think you probably want to study basic Java first then or you're
going to run into a lot more confusion.
Vector probabilities = new SparseVector();
is what you want. Interfaces and instantiating objects are the very
basics of Java.
On Fri, Sep 4, 2009 at 5:30 PM, Sven Boekhoff<sv...@boekhoff.info> wrote:
> I never worked with interfaces.
> And i also don't know what "instantiate an implementation" means.
> How does it look like?
>
> Sean Owen wrote:
>>
>> Yes, Vector is an interface! You need to instantiate an implementation
>> like DenseVector.
>>
>> On Fri, Sep 4, 2009 at 5:25 PM, Sven Boekhoff<sv...@boekhoff.info> wrote:
>>>
>>> But i cant create an Vector object:
>>>
>>> Vector probabilities = new Vector();
>>>
>>> gives an error.
>>>
>
Re: Creating Multinomial Random numbers with Mahout
Posted by Sven Boekhoff <sv...@boekhoff.info>.
I never worked with interfaces.
And i also don't know what "instantiate an implementation" means.
How does it look like?
Sean Owen wrote:
> Yes, Vector is an interface! You need to instantiate an implementation
> like DenseVector.
>
> On Fri, Sep 4, 2009 at 5:25 PM, Sven Boekhoff<sv...@boekhoff.info> wrote:
>> But i cant create an Vector object:
>>
>> Vector probabilities = new Vector();
>>
>> gives an error.
>>
Re: Creating Multinomial Random numbers with Mahout
Posted by Sean Owen <sr...@gmail.com>.
Yes, Vector is an interface! You need to instantiate an implementation
like DenseVector.
On Fri, Sep 4, 2009 at 5:25 PM, Sven Boekhoff<sv...@boekhoff.info> wrote:
> But i cant create an Vector object:
>
> Vector probabilities = new Vector();
>
> gives an error.
>
Re: Creating Multinomial Random numbers with Mahout
Posted by Sven Boekhoff <sv...@boekhoff.info>.
But i cant create an Vector object:
Vector probabilities = new Vector();
gives an error.
Sean Owen wrote:
> Just look at the org.apache.mahout.matrix.Vector interface? should be
> pretty clear. Like with the java.util.Vector interface the 'set'
> operation necessarily needs a position argument!
>
> probabilities.set(0, 0.2);
> probabilities.set(1, 0.1);
> ...
>
>
> On Fri, Sep 4, 2009 at 5:18 PM, Sven Boekhoff<sv...@boekhoff.info> wrote:
>> It solved the first part of my question. i do not know how to create a
>> vector.
>> I tried e.g.:
>>
>> Vector probabilities = new Vector();
>>
>> //to then set the values like:
>>
>> probabilities.set((double) 0.1);
>> probabilities.set((double) 0.2);
>> probabilities.set((double) 0.3);
>> probabilities.set((double) 0.4);
>>
>> But eclipse shows an error (but does not say what is wrong). I do not know
>> how to use interfaces. Obviously I can't use it as if it was a class.
>>
>> Should be easy,... somehow.
Re: Creating Multinomial Random numbers with Mahout
Posted by Sean Owen <sr...@gmail.com>.
Just look at the org.apache.mahout.matrix.Vector interface? should be
pretty clear. Like with the java.util.Vector interface the 'set'
operation necessarily needs a position argument!
probabilities.set(0, 0.2);
probabilities.set(1, 0.1);
...
On Fri, Sep 4, 2009 at 5:18 PM, Sven Boekhoff<sv...@boekhoff.info> wrote:
> It solved the first part of my question. i do not know how to create a
> vector.
> I tried e.g.:
>
> Vector probabilities = new Vector();
>
> //to then set the values like:
>
> probabilities.set((double) 0.1);
> probabilities.set((double) 0.2);
> probabilities.set((double) 0.3);
> probabilities.set((double) 0.4);
>
> But eclipse shows an error (but does not say what is wrong). I do not know
> how to use interfaces. Obviously I can't use it as if it was a class.
>
> Should be easy,... somehow.
Re: Creating Multinomial Random numbers with Mahout
Posted by Sven Boekhoff <sv...@boekhoff.info>.
It solved the first part of my question. i do not know how to create a
vector.
I tried e.g.:
Vector probabilities = new Vector();
//to then set the values like:
probabilities.set((double) 0.1);
probabilities.set((double) 0.2);
probabilities.set((double) 0.3);
probabilities.set((double) 0.4);
But eclipse shows an error (but does not say what is wrong). I do not
know how to use interfaces. Obviously I can't use it as if it was a class.
Should be easy,... somehow.
Sean Owen wrote:
> I'm sorry it's actually me that is wrong. UncommonDistributions is a
> Mahout class. I made the wrong assumption based on the name and the
> fact that you seemed to be talking about java.util.Vector. The
> "Vector" here is Mahout's class.
>
> So does Isabel's answer solve your problem? You get a Vector with all
> the values you want back. You simply access with get() methods.
>
> On Fri, Sep 4, 2009 at 4:42 PM, Sven Boekhoff<sv...@boekhoff.info> wrote:
>> there is no multinomial random number generator in UncommonsMath -
>> unfortonately. there is also no hypergeometric random number generator. I
>> thought it would be much easier to use an existing one, than write an own
>> one.
>> And once i know how to use the Vector interface, i might be ablie to use the
>> one provided by mahout. for the hypergeometric thing I might have to write
>> an own function,... (there should be a package providing those functions -
>> I'm wondering why there isn't one,...)
>>
>>
>> Sean Owen wrote:
>>> It seems like you're not really using Mahout, but a library that
>>> Mahout uses -- Uncommons Math. See
>>> https://uncommons-maths.dev.java.net/ . I think this is the library,
>>> and documentation, you really need. Everything you refer to are not
>>> Mahout APIs.
>>>
>>> On Fri, Sep 4, 2009 at 3:08 PM, Sven Boekhoff<sv...@boekhoff.info> wrote:
>>>> I did not realize that the methods are static methods (Thats why i tried
>>>> to
>>>> use a constructor).
>>>>
>>>> But how do I set up the vector with my probabilities?
>>>> And do I have to set a seed? which ones can I use?
>>>>
>>>> Why is Vector used for the Method, and not ArrayList/LinkedList?
>>>>
>>>> Thanks four your help.
Re: Creating Multinomial Random numbers with Mahout
Posted by Sean Owen <sr...@gmail.com>.
I'm sorry it's actually me that is wrong. UncommonDistributions is a
Mahout class. I made the wrong assumption based on the name and the
fact that you seemed to be talking about java.util.Vector. The
"Vector" here is Mahout's class.
So does Isabel's answer solve your problem? You get a Vector with all
the values you want back. You simply access with get() methods.
On Fri, Sep 4, 2009 at 4:42 PM, Sven Boekhoff<sv...@boekhoff.info> wrote:
> there is no multinomial random number generator in UncommonsMath -
> unfortonately. there is also no hypergeometric random number generator. I
> thought it would be much easier to use an existing one, than write an own
> one.
> And once i know how to use the Vector interface, i might be ablie to use the
> one provided by mahout. for the hypergeometric thing I might have to write
> an own function,... (there should be a package providing those functions -
> I'm wondering why there isn't one,...)
>
>
> Sean Owen wrote:
>>
>> It seems like you're not really using Mahout, but a library that
>> Mahout uses -- Uncommons Math. See
>> https://uncommons-maths.dev.java.net/ . I think this is the library,
>> and documentation, you really need. Everything you refer to are not
>> Mahout APIs.
>>
>> On Fri, Sep 4, 2009 at 3:08 PM, Sven Boekhoff<sv...@boekhoff.info> wrote:
>>>
>>> I did not realize that the methods are static methods (Thats why i tried
>>> to
>>> use a constructor).
>>>
>>> But how do I set up the vector with my probabilities?
>>> And do I have to set a seed? which ones can I use?
>>>
>>> Why is Vector used for the Method, and not ArrayList/LinkedList?
>>>
>>> Thanks four your help.
>
Re: Creating Multinomial Random numbers with Mahout
Posted by Sven Boekhoff <sv...@boekhoff.info>.
there is no multinomial random number generator in UncommonsMath -
unfortonately. there is also no hypergeometric random number generator.
I thought it would be much easier to use an existing one, than write an
own one.
And once i know how to use the Vector interface, i might be ablie to use
the one provided by mahout. for the hypergeometric thing I might have to
write an own function,... (there should be a package providing those
functions - I'm wondering why there isn't one,...)
Sean Owen wrote:
> It seems like you're not really using Mahout, but a library that
> Mahout uses -- Uncommons Math. See
> https://uncommons-maths.dev.java.net/ . I think this is the library,
> and documentation, you really need. Everything you refer to are not
> Mahout APIs.
>
> On Fri, Sep 4, 2009 at 3:08 PM, Sven Boekhoff<sv...@boekhoff.info> wrote:
>> I did not realize that the methods are static methods (Thats why i tried to
>> use a constructor).
>>
>> But how do I set up the vector with my probabilities?
>> And do I have to set a seed? which ones can I use?
>>
>> Why is Vector used for the Method, and not ArrayList/LinkedList?
>>
>> Thanks four your help.
Re: Creating Multinomial Random numbers with Mahout
Posted by Sean Owen <sr...@gmail.com>.
It seems like you're not really using Mahout, but a library that
Mahout uses -- Uncommons Math. See
https://uncommons-maths.dev.java.net/ . I think this is the library,
and documentation, you really need. Everything you refer to are not
Mahout APIs.
On Fri, Sep 4, 2009 at 3:08 PM, Sven Boekhoff<sv...@boekhoff.info> wrote:
> I did not realize that the methods are static methods (Thats why i tried to
> use a constructor).
>
> But how do I set up the vector with my probabilities?
> And do I have to set a seed? which ones can I use?
>
> Why is Vector used for the Method, and not ArrayList/LinkedList?
>
> Thanks four your help.
Re: Creating Multinomial Random numbers with Mahout
Posted by Sven Boekhoff <sv...@boekhoff.info>.
I did not realize that the methods are static methods (Thats why i tried
to use a constructor).
But how do I set up the vector with my probabilities?
And do I have to set a seed? which ones can I use?
Why is Vector used for the Method, and not ArrayList/LinkedList?
Thanks four your help.
Isabel Drost wrote:
> On Fri, 04 Sep 2009 14:04:36 +0200
> Sven Boekhoff <sv...@boekhoff.info> wrote:
>
>> UncommonDistributions dist = (UncommonDistributions) new
>> Object();
>
> That won't work - you are casting an object of type "Object" to type
> "UncommonDistributions".
>
>
>> // UncommonDistributions dist = new
>> UncommonDistributions();
>
> That won't work either because the constructor of UncommonDistributions
> is private (the class only contains static methods, so allowing
> the creation of an instance of it does not really make sense).
>
> UncommonDistributions.init(seed);
> double random = UncommonDistributions.rMultinom(100, probabilities);
>
> should work (seed being the seed you want to use) .
>
> Isabel
Re: Creating Multinomial Random numbers with Mahout
Posted by Isabel Drost <is...@apache.org>.
On Fri, 04 Sep 2009 14:04:36 +0200
Sven Boekhoff <sv...@boekhoff.info> wrote:
> UncommonDistributions dist = (UncommonDistributions) new
> Object();
That won't work - you are casting an object of type "Object" to type
"UncommonDistributions".
> // UncommonDistributions dist = new
> UncommonDistributions();
That won't work either because the constructor of UncommonDistributions
is private (the class only contains static methods, so allowing
the creation of an instance of it does not really make sense).
UncommonDistributions.init(seed);
double random = UncommonDistributions.rMultinom(100, probabilities);
should work (seed being the seed you want to use) .
Isabel