I would like to use EnumeratedIntegerDistribution()out org.apache.commons.math3.distributionto get a discrete probability distribution
int[] nums_to_generate = new int[] { -1, 1, 0 };
double[] discrete_probabilities = new double[] { 0.4, 0.4, 0.2 };
I work with jdk7, on windows Xp, working from the command line
I do:
add to source file
import org.apache.commons.math3;
- download commons-math3-3.2 and unzip it into my current folder
Compile my source using classpath: (either)
javac -cp ./commons-math3-3.2/commons-math3-3.2.jar:. ConflictsAnimation.java
javac -cp commons-math3-3.2/commons-math3-3.2.jar ConflictsAnimation.java
However, I have a mysterious
"error: package org.apache.commons does not exist"
Who knows what is going on? I really need some help.
Note:
compilation (and start) in order without a class path and without importing "apache" and calling for numberatedIntegerDistribution ().
using classpath and without "appache" are meaningless errors.
Thank you very much for your excellent skills, programmers!
Here is a short demo:
import java.lang.Math.*;
import org.apache.commons.math3;
public class CheckMe {
public CheckMe() {
System.out.println("let us check it out");
System.out.println(generate_rand_distribution (10));
}
private static int[] generate_rand_distribution (int count){
int[] nums_to_generate = new int[] { -1, 1, 0 };
double[] discrete_probabilities = new double[] { 0.4, 0.4, 0.2 };
int[] samples = null;
EnumeratedIntegerDistribution distribution =
new EnumeratedIntegerDistribution(nums_to_generate, discrete_probabilities);
samples = distribution.sample (count);
return (samples);
}
public static void main (String args[]) {
System.out.println("Main: ");
CheckMe animation = new CheckMe();
}
}