de.lmu.ifi.dbs.elki.math.statistics.distribution.Distribution类的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(9.9k)|赞(0)|评价(0)|浏览(198)

本文整理了Java中de.lmu.ifi.dbs.elki.math.statistics.distribution.Distribution类的一些代码示例,展示了Distribution类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Distribution类的具体详情如下:
包路径:de.lmu.ifi.dbs.elki.math.statistics.distribution.Distribution
类名称:Distribution

Distribution介绍

[英]Statistical distributions, with their common functions.
[中]统计分布及其共同功能。

代码示例

代码示例来源:origin: elki-project/elki

/**
 * Test the quality of a fit.
 * 
 * @param x Input data
 * @param test Scratch space for testing (will be overwritten!)
 * @param dist Distribution
 * @return K-S-Test score
 * @throws ArithmeticException
 */
private static double testFit(double[] x, double[] test, Distribution dist) throws ArithmeticException {
 for(int i = 0; i < test.length; i++) {
  double v = dist.cdf(x[i]);
  if(Double.isNaN(v)) {
   throw new ArithmeticException("Got NaN after fitting " + dist.toString());
  }
  test[i] = (v >= 1.) ? 1 : (v <= 0.) ? 0. : v;
 }
 Arrays.sort(test); // Supposedly not necessary, but to be safe.
 return KolmogorovSmirnovTest.simpleTest(test);
}

代码示例来源:origin: elki-project/elki

@Override
 public boolean visit(double val, int row, int col, boolean selrow, boolean selcol) {
  assert (selrow && selcol);
  mat[row][col] = replacement.nextRandom();
  return false;
 }
});

代码示例来源:origin: elki-project/elki

/**
 * Compute density for cluster model at given double[] p-
 *
 * @see GeneratorInterface#getDensity(double[])
 */
@Override
public double getDensity(double[] p) {
 if(trans != null) {
  p = trans.applyInverse(p);
 }
 double density = densitycorrection;
 for(int i = 0; i < dim; i++) {
  density *= axes.get(i).pdf(p[i]);
 }
 return density;
}

代码示例来源:origin: de.lmu.ifi.dbs.elki/elki

@Override
public double getScaled(double value) {
 if (dist == null) {
  throw new AbortException("Programming error: outlier scaling not initialized.");
 }
 double s = inverted ? (1 - dist.cdf(value)) : dist.cdf(value);
 return (phi > 0.) ? (phi * s) / (1 - s + phi) : s;
}

代码示例来源:origin: elki-project/elki

public void checkRandom(Distribution d, int size, double err) {
  double[] data = new double[size];
  for(int i = 0; i < size; i++) {
   data[i] = d.nextRandom();
  }
  Arrays.sort(data);
  final double q0 = d.cdf(data[0]);
  final double q50 = d.cdf(data[size >> 1]);
  final double q100 = d.cdf(data[size - 1]);
  assertEquals("0% quantile not as expected.", .5 / size, q0, err);
  assertEquals("50% quantile not as expected.", 0.5, q50, err);
  assertEquals("100% quantile not as expected.", 1. - .5 / size, q100, err);
  int errlev0 = (int) Math.ceil(Math.log10(Math.abs(.5 / size - q0)));
  int errlev50 = (int) Math.ceil(Math.log10(Math.abs(0.5 - q50)));
  int errlev100 = (int) Math.ceil(Math.log10(Math.abs(1 - .5 / size - q100)));
  int errlev = MathUtil.max(errlev0, errlev50, errlev100);
  assertEquals("Error magnitude is not tight", errlev, Math.log10(err), 0.1);
 }
}

代码示例来源:origin: elki-project/elki

/**
  * Test the goodness of fit, keep the best.
  * 
  * @param est Estimator
  * @param d Distribution
  */
 public void test(DistributionEstimator<?> est, Distribution d) {
  double score = testFit(x, scratch, d);
  if(LOG.isDebuggingFine()) {
   LOG.debugFine(est.getClass().getSimpleName() + ": " + score + " " + d.toString());
  }
  if(score < this.score) {
   this.dist = d;
   this.score = score;
   this.est = est;
  }
 }
}

代码示例来源:origin: elki-project/elki

public void checkPDF(Distribution d, String key, double err) {
 // Also check that toString is meaningful.
 assertEquals("No meaningful toString()", -1, d.toString().indexOf('@'));
 double[] data = this.data.get(key);
 assertNotNull("Key not in test data: " + key, data);
 assertEquals("Not NaN for NaN", Double.NaN, d.pdf(Double.NaN), 0.);
 assertEquals("Not zero at neginf", 0., d.pdf(Double.NEGATIVE_INFINITY), 0.);
 assertEquals("Not zero at almost neginf", 0., d.pdf(-Double.MAX_VALUE), 0.);
 assertEquals("Not zero at posinf", 0., d.pdf(Double.POSITIVE_INFINITY), 0.);
 assertEquals("Not zero at almost posinf", 0., d.pdf(Double.MAX_VALUE), 0.);
 int maxerrlev = -15;
 for(int i = 0; i < data.length;) {
  double x = data[i++], exp = data[i++];
  double val = d.pdf(x);
  if(val == exp) {
   continue;
  }
  double diff = Math.abs(val - exp);
  final int errlev = (int) Math.ceil(Math.log10(diff / exp));
  maxerrlev = Math.max(errlev, maxerrlev);
  if(diff < err || diff / exp < err) {
   continue;
  }
  assertEquals("Error magnitude: 1e" + errlev + " at " + x, exp, val, err);
 }
 int given = (int) Math.floor(Math.log10(err * 1.1));
 assertTrue("Error magnitude is not tight: measured " + maxerrlev + " specified " + given, given <= maxerrlev);
}

代码示例来源:origin: elki-project/elki

@Override
 public double[] computeMean() {
  double[] v = new double[dim];
  for(int i = 0; i < dim; i++) {
   v[i] = axes.get(i).quantile(0.5);
  }
  if(trans != null) {
   v = trans.apply(v);
  }
  return v;
 }
}

代码示例来源:origin: elki-project/elki

@Override
public double getScaled(double value) {
 if(dist == null) {
  throw new AbortException("Programming error: outlier scaling not initialized.");
 }
 double s = inverted ? (1 - dist.cdf(value)) : dist.cdf(value);
 return (phi > 0.) ? (phi * s) / (1 - s + phi) : s;
}

代码示例来源:origin: de.lmu.ifi.dbs.elki/elki-core-math

/**
  * Test the goodness of fit, keep the best.
  * 
  * @param est Estimator
  * @param d Distribution
  */
 public void test(DistributionEstimator<?> est, Distribution d) {
  double score = testFit(x, scratch, d);
  if(LOG.isDebuggingFine()) {
   LOG.debugFine(est.getClass().getSimpleName() + ": " + score + " " + d.toString());
  }
  if(score < this.score) {
   this.dist = d;
   this.score = score;
   this.est = est;
  }
 }
}

代码示例来源:origin: de.lmu.ifi.dbs.elki/elki-data-generator

@Override
 public double[] computeMean() {
  double[] v = new double[dim];
  for(int i = 0; i < dim; i++) {
   v[i] = axes.get(i).quantile(0.5);
  }
  if(trans != null) {
   v = trans.apply(v);
  }
  return v;
 }
}

代码示例来源:origin: de.lmu.ifi.dbs.elki/elki-core-math

/**
 * Test the quality of a fit.
 * 
 * @param x Input data
 * @param test Scratch space for testing (will be overwritten!)
 * @param dist Distribution
 * @return K-S-Test score
 * @throws ArithmeticException
 */
private static double testFit(double[] x, double[] test, Distribution dist) throws ArithmeticException {
 for(int i = 0; i < test.length; i++) {
  double v = dist.cdf(x[i]);
  if(Double.isNaN(v)) {
   throw new ArithmeticException("Got NaN after fitting " + dist.toString());
  }
  test[i] = (v >= 1.) ? 1 : (v <= 0.) ? 0. : v;
 }
 Arrays.sort(test); // Supposedly not necessary, but to be safe.
 return KolmogorovSmirnovTest.simpleTest(test);
}

代码示例来源:origin: de.lmu.ifi.dbs.elki/elki-clustering

@Override
 public boolean visit(double val, int row, int col, boolean selrow, boolean selcol) {
  assert (selrow && selcol);
  mat[row][col] = replacement.nextRandom();
  return false;
 }
});

代码示例来源:origin: de.lmu.ifi.dbs.elki/elki-outlier

@Override
public double getScaled(double value) {
 if(dist == null) {
  throw new AbortException("Programming error: outlier scaling not initialized.");
 }
 double s = inverted ? (1 - dist.cdf(value)) : dist.cdf(value);
 return (phi > 0.) ? (phi * s) / (1 - s + phi) : s;
}

代码示例来源:origin: elki-project/elki

for(int i = 0; i < cursclus.getDim(); i++) {
 Distribution gen = cursclus.getDistribution(i);
 outStream.append("##   ").append(gen.toString()).append(LINE_SEPARATOR);

代码示例来源:origin: de.lmu.ifi.dbs.elki/elki-data-generator

/**
 * Compute density for cluster model at given double[] p-
 *
 * @see GeneratorInterface#getDensity(double[])
 */
@Override
public double getDensity(double[] p) {
 if(trans != null) {
  p = trans.applyInverse(p);
 }
 double density = densitycorrection;
 for(int i = 0; i < dim; i++) {
  density *= axes.get(i).pdf(p[i]);
 }
 return density;
}

代码示例来源:origin: elki-project/elki

public void checkQuantile(Distribution d, String key, double err) {
 double[] data = this.data.get(key);
 assertEquals("Not NaN for NaN", Double.NaN, d.quantile(Double.NaN), 0.);
 assertEquals("Not NaN for -inf", Double.NaN, d.quantile(Double.NEGATIVE_INFINITY), 0.);
 assertEquals("Not NaN for -1", Double.NaN, d.quantile(-1), 0.);
 assertEquals("Not NaN for 2", Double.NaN, d.quantile(2), 0.);
 assertEquals("Not NaN for inf", Double.NaN, d.quantile(Double.POSITIVE_INFINITY), 0.);
 assertNotNull("Key not in test data: " + key, data);
 int maxerrlev = -15;
 for(int i = 0; i < data.length;) {
  double x = data[i++], exp = data[i++];
  if(Double.isNaN(exp)) {
   continue;
  }
  double val = d.quantile(x);
  if(val == exp) {
   continue;
  }
  double diff = Math.abs(val - exp);
  final int errlev = (int) Math.ceil(Math.log10(diff / exp));
  maxerrlev = Math.max(errlev, maxerrlev);
  if(diff < err || diff / exp < err) {
   continue;
  }
  assertEquals("Error magnitude: 1e" + errlev + " at " + x, exp, val, err);
 }
 int given = (int) Math.floor(Math.log10(err * 1.1));
 assertTrue("Error magnitude is not tight: measured " + maxerrlev + " specified " + given, given <= maxerrlev);
}

代码示例来源:origin: de.lmu.ifi.dbs.elki/elki

/**
 * Test the quality of a fit.
 * 
 * @param x Input data
 * @param test Scratch space for testing (will be overwritten!)
 * @param dist Distribution
 * @return K-S-Test score
 * @throws ArithmeticException
 */
private double testFit(double[] x, double[] test, Distribution dist) throws ArithmeticException {
 for(int i = 0; i < test.length; i++) {
  test[i] = dist.cdf(x[i]);
  if(test[i] > 1.) {
   test[i] = 1.;
  }
  if(test[i] < 0.) {
   test[i] = 0.;
  }
  if(Double.isNaN(test[i])) {
   throw new ArithmeticException("Got NaN after fitting " + dist.toString());
  }
 }
 // Should actually be sorted already...
 Arrays.sort(test);
 return KolmogorovSmirnovTest.simpleTest(test);
}

代码示例来源:origin: de.lmu.ifi.dbs.elki/elki

@Override
 public boolean visit(double val, int row, int col, boolean selrow, boolean selcol) {
  assert (selrow && selcol);
  mat[row][col] = replacement.nextRandom();
  return false;
 }
});

代码示例来源:origin: elki-project/elki

public void checkCDF(Distribution d, String key, double err) {
 double[] data = this.data.get(key);
 assertNotNull("Key not in test data: " + key, data);
 assertEquals("Not NaN for NaN", Double.NaN, d.cdf(Double.NaN), 0.);
 assertEquals("Not zero at neginf", 0., d.cdf(Double.NEGATIVE_INFINITY), 0.);
 assertEquals("Not zero at almost neginf", 0., d.cdf(-Double.MAX_VALUE), 0.);
 assertEquals("Not one at posinf", 1., d.cdf(Double.POSITIVE_INFINITY), 0.);
 assertEquals("Not one at almost posinf", 1., d.cdf(Double.MAX_VALUE), 0.);
 int maxerrlev = -15;
 for(int i = 0; i < data.length;) {
  double x = data[i++], exp = data[i++];
  double val = d.cdf(x);
  if(val == exp) {
   continue;
  }
  double diff = Math.abs(val - exp);
  final int errlev = (int) Math.ceil(Math.log10(diff / exp));
  maxerrlev = Math.max(errlev, maxerrlev);
  if(diff < err || diff / exp < err) {
   continue;
  }
  assertEquals("Error magnitude: 1e" + errlev + " at " + x, exp, val, err);
 }
 int given = (int) Math.floor(Math.log10(err * 1.1));
 assertTrue("Error magnitude is not tight: measured " + maxerrlev + " specified " + given, given <= maxerrlev);
}

相关文章