/// <summary> /// Aggregate & normalize samples /// The samples are arranged in ascending order /// </summary> public static Samples <A> Enumerate <A, Key>(FiniteDist <A> dist, Func <A, Key> keyFunc) where A : IComparable <A> { return(Importance.Normalize(Compact(dist.Explicit, keyFunc))); }
/// <summary> /// Finite uniform distribution over list of items. /// Only composable with other finite distributions. /// </summary> public static FiniteDist <A> EnumUniformF <A>(IEnumerable <A> items) { var uniform = Samples(items.Select(i => new ItemProb <A>(i, Prob(1)))); return(new FiniteDist <A>(Importance.Normalize(uniform))); }
public static Samples <A> Normalize <A>(this Samples <A> self) { return(Importance.Normalize(self)); }