@Test public void testP() { System.out.println("p"); KernelDensity instance = new KernelDensity(x); double expResult = 0.10122; double result = instance.p(3.5); assertEquals(expResult, result, 1E-5); }
@Override public double p(double x) { int start = Arrays.binarySearch(this.x, x-5*h); if (start < 0) { start = -start - 1; } int end = Arrays.binarySearch(this.x, x+5*h); if (end < 0) { end = -end - 1; } double p = 0.0; for (int i = start; i < end; i++) { p += gaussian.p(this.x[i] - x); } return p / this.x.length; }
KernelDensity implements Distribution { @Override public double p(double x) { int start = Arrays.binarySearch(this.x, x-5*h); if (start < 0) { start = -start - 1; } int end = Arrays.binarySearch(this.x, x+5*h); if (end < 0) { end = -end - 1; } double p = 0.0; for (int i = start; i < end; i++) { p += gaussian.p(this.x[i] - x); } return p / this.x.length; } }
KernelDensity implements Distribution { @Override public double p(double x) { int start = Arrays.binarySearch(this.x, x-5*h); if (start < 0) { start = -start - 1; } int end = Arrays.binarySearch(this.x, x+5*h); if (end < 0) { end = -end - 1; } double p = 0.0; for (int i = start; i < end; i++) { p += gaussian.p(this.x[i] - x); } return p / this.x.length; } KernelDensity(double[] x);  KernelDensity(double[] x, double h); }
KernelDensity implements Distribution { @Override public double p(double x) { int start = Arrays.binarySearch(this.x, x-5*h); if (start < 0) { start = -start - 1; } int end = Arrays.binarySearch(this.x, x+5*h); if (end < 0) { end = -end - 1; } double p = 0.0; for (int i = start; i < end; i++) { p += gaussian.p(this.x[i] - x); } return p / this.x.length; } KernelDensity(double[] x);  KernelDensity(double[] x, double h); double bandwidth(); @Override int length(); @Override double mean(); @Override double variance(); @Override double sd(); @Override double entropy(); @Override double rand(); @Override double p(double x); @Override double logp(double x); @Override double cdf(double x); @Override double quantile(double p); @Override double likelihood(double[] x); @Override double logLikelihood(double[] x); }
KernelDensity implements Distribution { @Override public double p(double x) { int start = Arrays.binarySearch(this.x, x-5*h); if (start < 0) { start = -start - 1; } int end = Arrays.binarySearch(this.x, x+5*h); if (end < 0) { end = -end - 1; } double p = 0.0; for (int i = start; i < end; i++) { p += gaussian.p(this.x[i] - x); } return p / this.x.length; } KernelDensity(double[] x);  KernelDensity(double[] x, double h); double bandwidth(); @Override int length(); @Override double mean(); @Override double variance(); @Override double sd(); @Override double entropy(); @Override double rand(); @Override double p(double x); @Override double logp(double x); @Override double cdf(double x); @Override double quantile(double p); @Override double likelihood(double[] x); @Override double logLikelihood(double[] x);  }