Exemplo n.º 1
0
 public virtual double ProbabilityOf(E @object)
 {
     if (@object == null)
     {
         throw new Exception("You cannot ask for the probability of null.");
     }
     if (sampled.KeySet().Contains(@object))
     {
         return(sampled.GetCount(@object) / sampled.TotalCount());
     }
     else
     {
         return(0.0);
     }
 }
        // it's empty, get rid of it!
        public virtual void Remove(K1 key)
        {
            ClassicCounter <K2> counter = map[key];

            if (counter != null)
            {
                total -= counter.TotalCount();
            }
            Sharpen.Collections.Remove(map, key);
        }
        public virtual double GetCount(K1 o1, K2 o2)
        {
            ClassicCounter <K2> c = GetCounter(o1);

            if (c.TotalCount() == 0.0 && !c.KeySet().Contains(o2))
            {
                return(DefaultReturnValue());
            }
            return(c.GetCount(o2));
        }
        /// <summary>replace the counter for K1-index o by new counter c</summary>
        public virtual ClassicCounter <K2> SetCounter(K1 o, ICounter <K2> c)
        {
            ClassicCounter <K2> old = GetCounter(o);

            total -= old.TotalCount();
            if (c is ClassicCounter)
            {
                map[o] = (ClassicCounter <K2>)c;
            }
            else
            {
                map[o] = new ClassicCounter <K2>(c);
            }
            total += c.TotalCount();
            return(old);
        }
        public virtual double TotalCount(K1 k1)
        {
            ClassicCounter <K2> c = GetCounter(k1);

            return(c.TotalCount());
        }