List of usage examples for org.apache.commons.math3.distribution MultivariateRealDistribution density
double density(double[] x);
From source file:org.apache.solr.client.solrj.io.eval.DensityEvaluator.java
@Override public Object doWork(Object first, Object second) throws IOException { if (!(first instanceof MultivariateRealDistribution)) { throw new IOException(String.format(Locale.ROOT, "Invalid expression %s - found type %s for the first value, expecting a MultiVariateRealDistribution for density", toExpression(constructingFactory), first.getClass().getSimpleName())); }//from w ww . ja v a2s .c om if (!(second instanceof List)) { throw new IOException(String.format(Locale.ROOT, "Invalid expression %s - found type %s for the second value, expecting a numeric array.", toExpression(constructingFactory), first.getClass().getSimpleName())); } MultivariateRealDistribution multivariateRealDistribution = (MultivariateRealDistribution) first; List<Number> nums = (List<Number>) second; double[] vec = new double[nums.size()]; for (int i = 0; i < vec.length; i++) { vec[i] = nums.get(i).doubleValue(); } return multivariateRealDistribution.density(vec); }