List of usage examples for org.apache.commons.math3.distribution NormalDistribution NormalDistribution
public NormalDistribution()
From source file:net.demilich.metastone.game.behaviour.decicionTreeBheavior.DecisionDataBase.java
public synchronized void learn(Example[] examples) { double totalGood = Arrays.asList(examples).stream().filter(e -> e.classification == 2).count(); NormalDistribution norm = new NormalDistribution(); this.percentGood = totalGood / examples.length; for (int i = 0; i < examples[0].values.length; i++) { final int feature = i; //i feel like smeting should be wrong with this.... doesn't compile without the final variable //System.err.println("feature: " + feature); List<Example> featureTrue = Arrays.asList(examples).stream().filter(e -> e.values[feature] > .5) .collect(Collectors.toList()); makeNewStat(featureTrue, feature, totalGood, norm, (double) examples.length, 1); List<Example> featureFalse = Arrays.asList(examples).stream().filter(e -> e.values[feature] < .5) .collect(Collectors.toList()); makeNewStat(featureFalse, feature, totalGood, norm, (double) examples.length, 0); }/*w w w .j a v a 2 s .c o m*/ Collections.sort(stats); for (int i = 0; i < usedFeatures.length; i++) { usedFeatures[i] = stats.get(i).feature; if (stats.get(i).pValue < MaxBiasedProbability.threshold) { stats.get(i).percentGood = this.percentGood; } } }
From source file:edu.cmu.tetrad.data.DataUtils.java
public static DataSet getNonparanormalTransformed(DataSet dataSet) { final TetradMatrix data = dataSet.getDoubleData(); final TetradMatrix X = data.like(); final double n = dataSet.getNumRows(); final double delta = 1.0 / (4.0 * Math.pow(n, 0.25) * Math.sqrt(Math.PI * Math.log(n))); final NormalDistribution normalDistribution = new NormalDistribution(); double std = Double.NaN; for (int j = 0; j < data.columns(); j++) { final double[] x1 = data.getColumn(j).toArray(); double std1 = StatUtils.sd(x1); double mu1 = StatUtils.mean(x1); double[] x = ranks(data, x1); for (int i = 0; i < x.length; i++) { x[i] /= n;/*w w w .j a va2 s .c o m*/ if (x[i] < delta) x[i] = delta; if (x[i] > (1. - delta)) x[i] = 1. - delta; x[i] = normalDistribution.inverseCumulativeProbability(x[i]); } if (Double.isNaN(std)) { std = StatUtils.sd(x); } for (int i = 0; i < x.length; i++) { x[i] /= std; x[i] *= std1; x[i] += mu1; } X.assignColumn(j, new TetradVector(x)); } return ColtDataSet.makeContinuousData(dataSet.getVariables(), X); }
From source file:Option2017Interface.DistFunctions.java
public static double PDF(double z) { NormalDistribution nD = new NormalDistribution(); double pdf;/* ww w . java 2 s . c o m*/ pdf = nD.density(z); return pdf; }
From source file:org.alfresco.bm.event.DelayingSampleEventProcessor.java
/** * @param outputEventName the output event name * @param minTime the minimum apparent execution time * @param maxTime the maximum apparent execution time * @param failurePercent the percentage of events that must fail *///ww w . j a va 2 s. c o m public DelayingSampleEventProcessor(String outputEventName, long minTime, long maxTime, int failurePercent) { this.outputEventName = outputEventName; this.normalDistribution = new NormalDistribution(); this.minTime = minTime; this.maxTime = maxTime; this.failurePercent = failurePercent; }
From source file:org.alfresco.random.NormalDistributionHelper.java
/** * Use a simple normal distribution to generate random numbers */ public NormalDistributionHelper() { this.normalDistribution = new NormalDistribution(); }
From source file:org.briljantframework.data.dataframe.MixedDataFrameTest.java
@Test public void testNiceBuilder() throws Exception { NormalDistribution gaussian = new NormalDistribution(); DataFrame df = DataFrame.of("a", Vector.of(1, 2, 3), "b", Vector.of(2, 3, 3), "c", Vector.fromSupplier(gaussian::sample, 3), "d", Vector.singleton("hello", 3)); DataFrame df2 = DataFrame.builder().set("a", Vector.fromSupplier(gaussian::sample, 4)) .set("b", Vector.fromSupplier(gaussian::sample, 4)).build(); System.out.println(df.transpose()); }
From source file:org.hawkular.datamining.forecast.stats.AugmentedDickeyFullerTest.java
/** * Returns MacKinnon's approximate p-value for the given test statistic. * * MacKinnon, J.G. 1994 "Approximate Asymptotic Distribution Functions for * Unit-Root and Cointegration Tests." Journal of Business & Economics * Statistics, 12.2, 167-76.//w w w .ja va 2 s .c o m * * @param testStat "T-value" from an Augmented Dickey-Fuller regression. * @param maxLag The number of series believed to be I(1). For (Augmented) Dickey-Fuller n = 1. * @return The p-value for the ADF statistic using MacKinnon 1994. */ private double macKinnonPValue(double testStat, int maxLag) { double[] maxStat = ADF_TAU_MAX.get(type); if (testStat > maxStat[maxLag - 1]) { return 1.0; } double[] minStat = ADF_TAU_MIN.get(type); if (testStat < minStat[maxLag - 1]) { return 0.0; } double[] starStat = ADF_TAU_STAR.get(type); double[] tauCoef = testStat <= starStat[maxLag - 1] ? ADF_TAU_SMALLP.get(type)[maxLag - 1] : ADF_TAU_LARGEP.get(type)[maxLag - 1]; return new NormalDistribution().cumulativeProbability(polyval(tauCoef, testStat)); }
From source file:org.lightjason.agentspeak.action.builtin.TestCActionMathStatistics.java
/** * test add random sample/*from ww w .ja va 2s. c om*/ */ @Test public final void randomsample() { final List<ITerm> l_return = new ArrayList<>(); new CRandomSample().execute(false, IContext.EMPTYPLAN, Stream.of(new NormalDistribution(), 3).map(CRawTerm::from).collect(Collectors.toList()), l_return); Assert.assertEquals(l_return.size(), 1); Assert.assertTrue(l_return.get(0).raw() instanceof List); Assert.assertEquals(l_return.get(0).<List<Number>>raw().size(), 3); }
From source file:org.nmdp.ngs.tools.GenerateBedTest.java
@Before public void setUp() { chrom = "1";/*from w w w.ja v a 2 s.co m*/ n = 10; size = 100; random = new JDKRandomGenerator(); length = new NormalDistribution(); }
From source file:org.nmdp.ngs.tools.GeneratePairedEndReadsTest.java
@Before public void setUp() throws Exception { firstReadFile = File.createTempFile("generatePairedEndReadsTest", "fq.gz"); secondReadFile = File.createTempFile("generatePairedEndReadsTest", "fq.gz"); random = new JDKRandomGenerator(); length = new NormalDistribution(); insertSize = new NormalDistribution(); quality = new RealDistributionQualityStrategy(new NormalDistribution()); coverage = GeneratePairedEndReads.DEFAULT_COVERAGE; mutationRate = 0.0d;//from w w w . j ava 2 s . c o m mutation = GeneratePairedEndReads.DEFAULT_MUTATION; }