/// <summary> /// returns a /// <c>double[]</c> /// array of length /// <c>depth+1</c> /// , containing the conditional counts on a /// <c>depth</c> /// -length list given each level of conditional /// distribution from 0 to /// <c>depth</c> /// . /// </summary> public virtual double[] GetCounts(IList <K> l) { if (l.Count != depth) { WrongDepth(); } //throws exception double[] counts = new double[depth + 1]; GeneralizedCounter <K> next = this; counts[0] = next.TotalCount(); IEnumerator <K> i = l.GetEnumerator(); int j = 1; K o = i.Current; while (i.MoveNext()) { next = next.ConditionalizeHelper(o); counts[j] = next.TotalCount(); o = i.Current; j++; } counts[depth] = next.GetCount(o); return(counts); }
/// <summary> /// A convenience method equivalent to <code> /// <see cref="GeneralizedCounter{K}.GetCounts(System.Collections.IList{E})"/> /// ({o1,o2,o3})</code>; works only for depth 3 /// GeneralizedCounters /// </summary> public virtual double GetCount(K o1, K o2, K o3) { if (depth != 3) { WrongDepth(); } GeneralizedCounter <K> gc1 = ErasureUtils.UncheckedCast <GeneralizedCounter <K> >(map[o1]); if (gc1 == null) { return(0.0); } else { return(gc1.GetCount(o2, o3)); } }