/// <summary> Constructor /// /// </summary> /// <param name="numSymbols">the number of possible symbols (remember to include 0) /// </param> /// <param name="numCondSymbols">the number of conditioning symbols /// </param> /// <param name="laplace">if true, sub-estimators will use laplace /// </param> public DDConditionalEstimator(int numSymbols, int numCondSymbols, bool laplace) { m_Estimators = new DiscreteEstimator[numCondSymbols]; for (int i = 0; i < numCondSymbols; i++) { m_Estimators[i] = new DiscreteEstimator(numSymbols, laplace); } }
/// <summary> Get a probability estimator for a value /// /// </summary> /// <param name="data">the value to estimate the probability of /// </param> /// <param name="given">the new value that data is conditional upon /// </param> /// <returns> the estimator for the supplied value given the condition /// </returns> public virtual Estimator getEstimator(double given) { Estimator result = new DiscreteEstimator(m_Estimators.Length, false); for (int i = 0; i < m_Estimators.Length; i++) { result.addValue(i, m_Weights.getProbability(i) * m_Estimators[i].getProbability(given)); } return result; }
/// <summary> Constructor /// /// </summary> /// <param name="numSymbols">the number of symbols /// </param> /// <param name="precision">the precision to which numeric values are given. For /// example, if the precision is stated to be 0.1, the values in the /// interval (0.25,0.35] are all treated as 0.3. /// </param> public DNConditionalEstimator(int numSymbols, double precision) { m_Estimators = new NormalEstimator[numSymbols]; for (int i = 0; i < numSymbols; i++) { m_Estimators[i] = new NormalEstimator(precision); } m_Weights = new DiscreteEstimator(numSymbols, true); }
/// <summary> Get a probability estimator for a value /// /// </summary> /// <param name="data">the value to estimate the probability of /// </param> /// <param name="given">the new value that data is conditional upon /// </param> /// <returns> the estimator for the supplied value given the condition /// </returns> public virtual Estimator getEstimator(double given) { Estimator result = new DiscreteEstimator(m_Estimators.Length, false); for (int i = 0; i < m_Estimators.Length; i++) { //System.out.println("Val " + i // + " Weight:" + m_Weights.getProbability(i) // +" EstProb(" + given + ")=" // + m_Estimators[i].getProbability(given)); result.addValue(i, m_Weights.getProbability(i) * m_Estimators[i].getProbability(given)); } return result; }