@Override public void scaleEquals( final double scaleFactor ) { ArrayList<Number> X = this.sample( this.getRandom(), this.getNumSamples() ); ArrayList<Number> Z = new ArrayList<Number>( this.getNumSamples() ); for( int n = 0; n < this.getNumSamples(); n++ ) { Z.add( X.get(n).doubleValue() * scaleFactor ); } this.setDistribution( new ScalarDataDistribution.PMF( Z ) ); }
/** * Creates a new instance of UnivariateRandomVariable * @param distribution * Scalar distribution that backs the random variable, from which samples * will be drawn to approximate the distribution during algebra. * @param random * Random number generator used to sample the distribution * @param numSamples */ public UnivariateRandomVariable( final UnivariateDistribution<? extends Number> distribution, final Random random, final int numSamples ) { this.setDistribution( distribution ); this.setRandom( random ); this.setNumSamples( numSamples ); }
@Override public double getMeanAsDouble() { return this.getDistribution().getMeanAsDouble(); }
@Override public void scaledPlusEquals( final double scaleFactor, final RandomVariable<Number> other) { this.plusEquals(other.scale(scaleFactor)); }
@Override public boolean equals( final RandomVariable<Number> other, final double effectiveZero ) { // effectiveZero=0.0 -> null hypothesis probability = 1.0 // effectiveZero=1.0 -> null hypothesis probability >= 0.0 // effectiveZero=0.95 -> null hypothesis probability >= 0.05 double pValue = 1.0-effectiveZero; ArrayList<Number> data1 = this.sample( this.random, this.numSamples ); ArrayList<? extends Number> data2 = other.sample( this.random, this.numSamples ); KolmogorovSmirnovConfidence kstest = new KolmogorovSmirnovConfidence(); KolmogorovSmirnovConfidence.Statistic stat = kstest.evaluateNullHypothesis( data1, data2 ); return stat.getNullHypothesisProbability() >= pValue; }
@Override @SuppressWarnings("unchecked") public boolean equals( final Object obj ) { if( obj == null ) { return false; } else if( obj == this ) { return true; } else if( obj instanceof RandomVariable ) { return this.equals( (RandomVariable<Number>) obj, 0.95 ); } else { return false; } }
@Override public Number sample( final Random random) { return this.getDistribution().sample(random); }
@Override public void scaledPlusEquals( final double scaleFactor, final RandomVariable<Number> other) { this.plusEquals(other.scale(scaleFactor)); }
@Override public boolean equals( final RandomVariable<Number> other, final double effectiveZero ) { // effectiveZero=0.0 -> null hypothesis probability = 1.0 // effectiveZero=1.0 -> null hypothesis probability >= 0.0 // effectiveZero=0.95 -> null hypothesis probability >= 0.05 double pValue = 1.0-effectiveZero; ArrayList<Number> data1 = this.sample( this.random, this.numSamples ); ArrayList<? extends Number> data2 = other.sample( this.random, this.numSamples ); KolmogorovSmirnovConfidence kstest = new KolmogorovSmirnovConfidence(); KolmogorovSmirnovConfidence.Statistic stat = kstest.evaluateNullHypothesis( data1, data2 ); return stat.getNullHypothesisProbability() >= pValue; }
@Override @SuppressWarnings("unchecked") public boolean equals( final Object obj ) { if( obj == null ) { return false; } else if( obj == this ) { return true; } else if( obj instanceof RandomVariable ) { return this.equals( (RandomVariable<Number>) obj, 0.95 ); } else { return false; } }
@Override public void scaleEquals( final double scaleFactor ) { ArrayList<Number> X = this.sample( this.getRandom(), this.getNumSamples() ); ArrayList<Number> Z = new ArrayList<Number>( this.getNumSamples() ); for( int n = 0; n < this.getNumSamples(); n++ ) { Z.add( X.get(n).doubleValue() * scaleFactor ); } this.setDistribution( new ScalarDataDistribution.PMF( Z ) ); }
/** * Creates a new instance of UnivariateRandomVariable * @param distribution * Scalar distribution that backs the random variable, from which samples * will be drawn to approximate the distribution during algebra. * @param random * Random number generator used to sample the distribution * @param numSamples */ public UnivariateRandomVariable( final UnivariateDistribution<? extends Number> distribution, final Random random, final int numSamples ) { this.setDistribution( distribution ); this.setRandom( random ); this.setNumSamples( numSamples ); }
@Override public double getMeanAsDouble() { return this.getDistribution().getMeanAsDouble(); }
@Override public void scaledPlusEquals( final double scaleFactor, final RandomVariable<Number> other) { this.plusEquals(other.scale(scaleFactor)); }
@Override public boolean equals( final RandomVariable<Number> other, final double effectiveZero ) { // effectiveZero=0.0 -> null hypothesis probability = 1.0 // effectiveZero=1.0 -> null hypothesis probability >= 0.0 // effectiveZero=0.95 -> null hypothesis probability >= 0.05 double pValue = 1.0-effectiveZero; ArrayList<Number> data1 = this.sample( this.random, this.numSamples ); ArrayList<? extends Number> data2 = other.sample( this.random, this.numSamples ); KolmogorovSmirnovConfidence kstest = new KolmogorovSmirnovConfidence(); KolmogorovSmirnovConfidence.Statistic stat = kstest.evaluateNullHypothesis( data1, data2 ); return stat.getNullHypothesisProbability() >= pValue; }
@Override @SuppressWarnings("unchecked") public boolean equals( final Object obj ) { if( obj == null ) { return false; } else if( obj == this ) { return true; } else if( obj instanceof RandomVariable ) { return this.equals( (RandomVariable<Number>) obj, 0.95 ); } else { return false; } }
@Override public void scaleEquals( final double scaleFactor ) { ArrayList<Number> X = this.sample( this.getRandom(), this.getNumSamples() ); ArrayList<Number> Z = new ArrayList<Number>( this.getNumSamples() ); for( int n = 0; n < this.getNumSamples(); n++ ) { Z.add( X.get(n).doubleValue() * scaleFactor ); } this.setDistribution( new ScalarDataDistribution.PMF( Z ) ); }