/** * Computes the conditional probability between a collection of objects and a new object. * @param prior The collection of objects that's conditioned on. If conditional probability is thought of as "A given B", this is the B. * @param posterior The new object; finding its probability given the prior. This is the "A" in the conditional probability definition. * @param priorDistribution The distribution which the prior is over. * @param posteriorDistribution The distribution which the posterior is over. If the prior contains n elements, this is a distribution over collections of size n+1 * @return The double representing the conditional probability. */ public double computeConditionalProbability(Collection<DataType> prior, DataType posterior, ComputableDistribution<Collection<DataType>> priorDistribution, ComputableDistribution<Collection<DataType>> posteriorDistribution) { Collection<DataType> realPosterior = new ArrayList<DataType>(prior); realPosterior.add(posterior); double numerator = posteriorDistribution.getProbabilityFunction().evaluate(realPosterior); double denominator = priorDistribution.getProbabilityFunction().evaluate(prior); if (denominator == 0) { throw new IllegalArgumentException("Prior does not appear in prior distribution."); } return numerator/denominator; }
/** * Computes the conditional probability between two objects. This is used when the data type contains the historical data. * @param prior The object that's conditioning the posterior. If conditional probability is thought of as "A given B", this is the B. * @param posterior The object whose probability is based off the prior. This is the "A" in the conditional probability definition. * @param priorDistribution A distribution for the objects. * @param posteriorDistribution A distribution for all pairs of objects. * @return The double representing the conditional probability. */ public double computeConditionalProbabilityWhenDataTypeHasHistoricalData(DataType prior, DataType posterior, ComputableDistribution<DataType> priorDistribution, ComputableDistribution<DataType> posteriorDistribution) { double numerator = posteriorDistribution.getProbabilityFunction().evaluate( posterior); double denominator = priorDistribution.getProbabilityFunction().evaluate(prior); if (denominator == 0) { throw new IllegalArgumentException("Prior does not appear in prior distribution."); } return numerator/denominator; } }
/** * Computes the conditional probability between two objects. This is used when the data type contains the historical data. * @param prior The object that's conditioning the posterior. If conditional probability is thought of as "A given B", this is the B. * @param posterior The object whose probability is based off the prior. This is the "A" in the conditional probability definition. * @param priorDistribution A distribution for the objects. * @param posteriorDistribution A distribution for all pairs of objects. * @return The double representing the conditional probability. */ public double computeConditionalProbabilityWhenDataTypeHasHistoricalData(DataType prior, DataType posterior, ComputableDistribution<DataType> priorDistribution, ComputableDistribution<DataType> posteriorDistribution) { double numerator = posteriorDistribution.getProbabilityFunction().evaluate( posterior); double denominator = priorDistribution.getProbabilityFunction().evaluate(prior); if (denominator == 0) { throw new IllegalArgumentException("Prior does not appear in prior distribution."); } return numerator/denominator; } }
/** * Computes the conditional probability between a collection of objects and a new object. * @param prior The collection of objects that's conditioned on. If conditional probability is thought of as "A given B", this is the B. * @param posterior The new object; finding its probability given the prior. This is the "A" in the conditional probability definition. * @param priorDistribution The distribution which the prior is over. * @param posteriorDistribution The distribution which the posterior is over. If the prior contains n elements, this is a distribution over collections of size n+1 * @return The double representing the conditional probability. */ public double computeConditionalProbability(Collection<DataType> prior, DataType posterior, ComputableDistribution<Collection<DataType>> priorDistribution, ComputableDistribution<Collection<DataType>> posteriorDistribution) { Collection<DataType> realPosterior = new ArrayList<DataType>(prior); realPosterior.add(posterior); double numerator = posteriorDistribution.getProbabilityFunction().evaluate(realPosterior); double denominator = priorDistribution.getProbabilityFunction().evaluate(prior); if (denominator == 0) { throw new IllegalArgumentException("Prior does not appear in prior distribution."); } return numerator/denominator; }
/** * Computes the conditional probability between two objects. This is used when the data type contains the historical data. * @param prior The object that's conditioning the posterior. If conditional probability is thought of as "A given B", this is the B. * @param posterior The object whose probability is based off the prior. This is the "A" in the conditional probability definition. * @param priorDistribution A distribution for the objects. * @param posteriorDistribution A distribution for all pairs of objects. * @return The double representing the conditional probability. */ public double computeConditionalProbabilityWhenDataTypeHasHistoricalData(DataType prior, DataType posterior, ComputableDistribution<DataType> priorDistribution, ComputableDistribution<DataType> posteriorDistribution) { double numerator = posteriorDistribution.getProbabilityFunction().evaluate( posterior); double denominator = priorDistribution.getProbabilityFunction().evaluate(prior); if (denominator == 0) { throw new IllegalArgumentException("Prior does not appear in prior distribution."); } return numerator/denominator; } }
/** * Computes the conditional probability between a collection of objects and a new object. * @param prior The collection of objects that's conditioned on. If conditional probability is thought of as "A given B", this is the B. * @param posterior The new object; finding its probability given the prior. This is the "A" in the conditional probability definition. * @param priorDistribution The distribution which the prior is over. * @param posteriorDistribution The distribution which the posterior is over. If the prior contains n elements, this is a distribution over collections of size n+1 * @return The double representing the conditional probability. */ public double computeConditionalProbability(Collection<DataType> prior, DataType posterior, ComputableDistribution<Collection<DataType>> priorDistribution, ComputableDistribution<Collection<DataType>> posteriorDistribution) { Collection<DataType> realPosterior = new ArrayList<DataType>(prior); realPosterior.add(posterior); double numerator = posteriorDistribution.getProbabilityFunction().evaluate(realPosterior); double denominator = priorDistribution.getProbabilityFunction().evaluate(prior); if (denominator == 0) { throw new IllegalArgumentException("Prior does not appear in prior distribution."); } return numerator/denominator; }
public ProbabilityFunction<ObservationType> call() { final int N = this.gammas.size(); for( int n = 0; n < N; n++ ) { this.weightedValues.get(n).setWeight( this.gammas.get(n).getElement( this.index ) ); } return this.distributionLearner.learn(this.weightedValues).getProbabilityFunction(); }
/** * Computes the conditional probability between two objects. * @param prior The object that's conditioning the posterior. If conditional probability is thought of as "A given B", this is the B. * @param posterior The object whose probability is based off the prior. This is the "A" in the conditional probability definition. * @param priorDistribution A distribution for the objects. * @param posteriorDistribution A distribution for all pairs of objects. * @return The double representing the conditional probability. */ public double computeConditionalProbability(DataType prior, DataType posterior, ComputableDistribution<DataType> priorDistribution, ComputableDistribution<Collection<DataType>> posteriorDistribution) { Collection<DataType> realPosterior = new ArrayList<DataType>(); realPosterior.add(prior); realPosterior.add(posterior); double numerator = posteriorDistribution.getProbabilityFunction().evaluate( realPosterior); double denominator = priorDistribution.getProbabilityFunction().evaluate(prior); if (denominator == 0) { throw new IllegalArgumentException("Prior does not appear in prior distribution."); } return numerator/denominator; }
/** * Computes the conditional probability between two objects. * @param prior The object that's conditioning the posterior. If conditional probability is thought of as "A given B", this is the B. * @param posterior The object whose probability is based off the prior. This is the "A" in the conditional probability definition. * @param priorDistribution A distribution for the objects. * @param posteriorDistribution A distribution for all pairs of objects. * @return The double representing the conditional probability. */ public double computeConditionalProbability(DataType prior, DataType posterior, ComputableDistribution<DataType> priorDistribution, ComputableDistribution<Collection<DataType>> posteriorDistribution) { Collection<DataType> realPosterior = new ArrayList<DataType>(); realPosterior.add(prior); realPosterior.add(posterior); double numerator = posteriorDistribution.getProbabilityFunction().evaluate( realPosterior); double denominator = priorDistribution.getProbabilityFunction().evaluate(prior); if (denominator == 0) { throw new IllegalArgumentException("Prior does not appear in prior distribution."); } return numerator/denominator; }
/** * Computes the conditional probability between two objects. * @param prior The object that's conditioning the posterior. If conditional probability is thought of as "A given B", this is the B. * @param posterior The object whose probability is based off the prior. This is the "A" in the conditional probability definition. * @param priorDistribution A distribution for the objects. * @param posteriorDistribution A distribution for all pairs of objects. * @return The double representing the conditional probability. */ public double computeConditionalProbability(DataType prior, DataType posterior, ComputableDistribution<DataType> priorDistribution, ComputableDistribution<Collection<DataType>> posteriorDistribution) { Collection<DataType> realPosterior = new ArrayList<DataType>(); realPosterior.add(prior); realPosterior.add(posterior); double numerator = posteriorDistribution.getProbabilityFunction().evaluate( realPosterior); double denominator = priorDistribution.getProbabilityFunction().evaluate(prior); if (denominator == 0) { throw new IllegalArgumentException("Prior does not appear in prior distribution."); } return numerator/denominator; }
/** * Computes the log likelihood of the i.i.d. data using the given * probability function. * @param <ObservationType> * Type of observations to consider * @param distribution * Computable distribution from which to get the probability function * (a pdf or pmf) used to compute the likelihood. * @param observations * Observations to compute the log likelihood of. * @return * Log likelihood of the i.i.d. data using the given probability function. */ public static <ObservationType> double logLikelihood( final ComputableDistribution<? super ObservationType> distribution, final Iterable<? extends ObservationType> observations ) { ProbabilityFunction<? super ObservationType> f = distribution.getProbabilityFunction(); double logSum = 0.0; for( ObservationType observation : observations ) { logSum += f.logEvaluate(observation); } return logSum; }
/** * Computes the log likelihood of the i.i.d. data using the given * probability function. * @param <ObservationType> * Type of observations to consider * @param distribution * Computable distribution from which to get the probability function * (a pdf or pmf) used to compute the likelihood. * @param observations * Observations to compute the log likelihood of. * @return * Log likelihood of the i.i.d. data using the given probability function. */ public static <ObservationType> double logLikelihood( final ComputableDistribution<? super ObservationType> distribution, final Iterable<? extends ObservationType> observations ) { ProbabilityFunction<? super ObservationType> f = distribution.getProbabilityFunction(); double logSum = 0.0; for( ObservationType observation : observations ) { logSum += f.logEvaluate(observation); } return logSum; }
public ProbabilityFunction<ObservationType> call() { final int N = this.gammas.size(); for( int n = 0; n < N; n++ ) { this.weightedValues.get(n).setWeight( this.gammas.get(n).getElement( this.index ) ); } return this.distributionLearner.learn(this.weightedValues).getProbabilityFunction(); }
public ProbabilityFunction<ObservationType> call() { final int N = this.gammas.size(); for( int n = 0; n < N; n++ ) { this.weightedValues.get(n).setWeight( this.gammas.get(n).getElement( this.index ) ); } return this.distributionLearner.learn(this.weightedValues).getProbabilityFunction(); }
public Double evaluate( ComputableDistribution<DataType> target) { ProbabilityFunction<DataType> f = target.getProbabilityFunction(); return evaluate(f, this.getCostParameters()); }
public Double evaluate( ComputableDistribution<DataType> target) { ProbabilityFunction<DataType> f = target.getProbabilityFunction(); return evaluate(f, this.getCostParameters()); }
public Double evaluate( ComputableDistribution<DataType> target) { ProbabilityFunction<DataType> f = target.getProbabilityFunction(); return evaluate(f, this.getCostParameters()); }
/** * Computes the conditionally independent likelihoods * for each state given the observation. * @param observation * Observation to consider * @param b * Likelihood of each state generating the given observation. This is where * the result of the computation is stored. */ protected void computeObservationLikelihoods( ObservationType observation, Vector b ) { int i = 0; for( ComputableDistribution<ObservationType> f : this.getEmissionFunctions() ) { b.setElement(i, f.getProbabilityFunction().evaluate(observation) ); i++; } }
/** * Computes the conditionally independent likelihoods * for each state given the observation. * @param observation * Observation to consider * @param b * Likelihood of each state generating the given observation. This is where * the result of the computation is stored. */ protected void computeObservationLikelihoods( ObservationType observation, Vector b ) { int i = 0; for( ComputableDistribution<ObservationType> f : this.getEmissionFunctions() ) { b.setElement(i, f.getProbabilityFunction().evaluate(observation) ); i++; } }
/** * Computes the conditionally independent likelihoods * for each state given the observation. * @param observation * Observation to consider * @param b * Likelihood of each state generating the given observation. This is where * the result of the computation is stored. */ protected void computeObservationLikelihoods( ObservationType observation, Vector b ) { int i = 0; for( ComputableDistribution<ObservationType> f : this.getEmissionFunctions() ) { b.setElement(i, f.getProbabilityFunction().evaluate(observation) ); i++; } }