/// <summary>Computations that depend on the observed value of vbool2</summary> public void Changed_vbool2() { if (this.Changed_vbool2_iterationsDone == 1) { return; } this.vbool2_marginal = Bernoulli.Uniform(); this.vbool2_marginal = Distribution.SetPoint <Bernoulli, bool>(this.vbool2_marginal, this.Vbool2); // The constant 'vBernoulli0' Bernoulli vBernoulli0 = Bernoulli.Uniform(); this.vbool0_marginal_F = Bernoulli.Uniform(); // Message from use of 'vbool0' Bernoulli vbool0_use_B = Bernoulli.Uniform(); // Message to 'vbool0_use' from And factor vbool0_use_B = BooleanAndOp.AAverageConditional(this.Vbool2, vBernoulli0); // Message to 'vbool0_marginal' from Variable factor this.vbool0_marginal_F = VariableOp.MarginalAverageConditional <Bernoulli>(vbool0_use_B, vBernoulli0, this.vbool0_marginal_F); this.vbool1_marginal_F = Bernoulli.Uniform(); // Message from use of 'vbool1' Bernoulli vbool1_use_B = Bernoulli.Uniform(); // Message to 'vbool1_use' from And factor vbool1_use_B = BooleanAndOp.BAverageConditional(this.Vbool2, vBernoulli0); // Message to 'vbool1_marginal' from Variable factor this.vbool1_marginal_F = VariableOp.MarginalAverageConditional <Bernoulli>(vbool1_use_B, vBernoulli0, this.vbool1_marginal_F); this.Changed_vbool2_iterationsDone = 1; }
/// <summary>Computations that depend on the observed value of bothHeads</summary> private void Changed_bothHeads() { if (this.Changed_bothHeads_isDone) { return; } this.bothHeads_marginal = Bernoulli.Uniform(); this.bothHeads_marginal = Distribution.SetPoint <Bernoulli, bool>(this.bothHeads_marginal, this.BothHeads); Bernoulli vBernoulli0 = Bernoulli.Uniform(); this.firstCoin_marginal_F = Bernoulli.Uniform(); Bernoulli firstCoin_use_B = default(Bernoulli); // Message to 'firstCoin_use' from And factor firstCoin_use_B = BooleanAndOp.AAverageConditional(this.BothHeads, vBernoulli0); // Message to 'firstCoin_marginal' from Variable factor this.firstCoin_marginal_F = VariableOp.MarginalAverageConditional <Bernoulli>(firstCoin_use_B, vBernoulli0, this.firstCoin_marginal_F); this.secondCoin_marginal_F = Bernoulli.Uniform(); Bernoulli secondCoin_use_B = default(Bernoulli); // Message to 'secondCoin_use' from And factor secondCoin_use_B = BooleanAndOp.BAverageConditional(this.BothHeads, vBernoulli0); // Message to 'secondCoin_marginal' from Variable factor this.secondCoin_marginal_F = VariableOp.MarginalAverageConditional <Bernoulli>(secondCoin_use_B, vBernoulli0, this.secondCoin_marginal_F); this.Changed_bothHeads_isDone = true; }
/// <summary>Computations that depend on the observed value of bothHeads and numberOfIterations</summary> /// <param name="numberOfIterations">The number of times to iterate each loop</param> private void Changed_bothHeads_numberOfIterations(int numberOfIterations) { if (this.Changed_bothHeads_numberOfIterations_isDone) { return; } bool[] firstCoin_uses_F; Bernoulli[] firstCoin_uses_B; // Create array for 'firstCoin_uses' Forwards messages. firstCoin_uses_F = new bool[1]; // Create array for 'firstCoin_uses' Backwards messages. firstCoin_uses_B = new Bernoulli[1]; firstCoin_uses_B[0] = Bernoulli.Uniform(); bool[] secondCoin_uses_F; // Create array for 'secondCoin_uses' Forwards messages. secondCoin_uses_F = new bool[1]; for (int iteration = this.numberOfIterationsDone; iteration < numberOfIterations; iteration++) { // Message to 'secondCoin_marginal' from UsesEqualDef factor this.secondCoin_marginal_F = UsesEqualDefGibbsOp <bool> .MarginalGibbs <Bernoulli>(this.secondCoin_uses_B, this.vBernoulli0, this.secondCoin_marginal_F); // Message to 'secondCoin_uses' from UsesEqualDef factor secondCoin_uses_F[0] = UsesEqualDefGibbsOp <bool> .UsesGibbs <Bernoulli>(this.secondCoin_marginal_F, 0, secondCoin_uses_F[0]); // Message to 'firstCoin_uses' from And factor firstCoin_uses_B[0] = BooleanAndOp.AAverageConditional(this.BothHeads, secondCoin_uses_F[0]); // Message to 'firstCoin_marginal' from UsesEqualDef factor this.firstCoin_marginal_F = UsesEqualDefGibbsOp <bool> .MarginalGibbs <Bernoulli>(firstCoin_uses_B, this.vBernoulli0, this.firstCoin_marginal_F); // Message to 'firstCoin_uses' from UsesEqualDef factor firstCoin_uses_F[0] = UsesEqualDefGibbsOp <bool> .UsesGibbs <Bernoulli>(this.firstCoin_marginal_F, 0, firstCoin_uses_F[0]); // Message to 'secondCoin_uses' from And factor this.secondCoin_uses_B[0] = BooleanAndOp.BAverageConditional(this.BothHeads, firstCoin_uses_F[0]); this.OnProgressChanged(new ProgressChangedEventArgs(iteration)); } this.Changed_bothHeads_numberOfIterations_isDone = true; }