/// <summary> /// Clones this sparse Beta list. /// </summary> public object Clone() { return(new SparseBetaList((SparseVector)TrueCounts.Clone(), (SparseVector)FalseCounts.Clone())); }
/// <summary> /// Sets this Beta list to a copy of another Beta list. /// </summary> /// <param name="value">The list to copy</param> public void SetTo(SparseBetaList value) { TrueCounts.SetTo(value.TrueCounts); FalseCounts.SetTo(value.FalseCounts); }
/// <summary> /// Sets the parameters to represent the list of sparse Betas raised to some power. /// </summary> /// <param name="betaList">The list of Betas</param> /// <param name="exponent">The exponent</param> public void SetToPower(SparseBetaList betaList, double exponent) { // TODO: handle point masses TrueCounts.SetToFunction(betaList.TrueCounts, x => exponent * (x - 1) + 1); FalseCounts.SetToFunction(betaList.FalseCounts, x => exponent * (x - 1) + 1); }
/// <summary> /// Sets to the product of two sparse lists of Betas. /// </summary> /// <param name="a">The first sparse list of Betas</param> /// <param name="b">The second sparse list of Betas</param> /// <remarks> /// The result may not be proper, i.e. its parameters may be negative. /// For example, if you multiply Beta(0.1,0.1) by itself you get Beta(-0.8, -0.8). /// No error is thrown in this case. /// </remarks> public void SetToProduct(SparseBetaList a, SparseBetaList b) { // TODO: handle point masses TrueCounts.SetToFunction(a.TrueCounts, b.TrueCounts, (x, y) => x + y - 1); FalseCounts.SetToFunction(a.FalseCounts, b.FalseCounts, (x, y) => x + y - 1); }
/// <summary> /// Tests if all Bernoulli elements are uniform. /// </summary> /// <returns></returns> public bool IsUniform() { return(TrueCounts.EqualsAll(1) && FalseCounts.EqualsAll(1)); }
/// <summary> /// Sets all Beta elements to uniform. /// </summary> public void SetToUniform() { TrueCounts.SetAllElementsTo(1); FalseCounts.SetAllElementsTo(1); }