/// <summary>Computations that depend on the observed value of firstCoin and numberOfIterations</summary> /// <param name="numberOfIterations">The number of times to iterate each loop</param> private void Changed_firstCoin_numberOfIterations(int numberOfIterations) { if (this.Changed_firstCoin_numberOfIterations_isDone) { return; } bool[] secondCoin_uses_F; Bernoulli[] secondCoin_uses_B; // Create array for 'secondCoin_uses' Forwards messages. secondCoin_uses_F = new bool[1]; // Create array for 'secondCoin_uses' Backwards messages. secondCoin_uses_B = new Bernoulli[1]; secondCoin_uses_B[0] = Bernoulli.Uniform(); bool bothHeads_F = default(bool); for (int iteration = this.numberOfIterationsDone; iteration < numberOfIterations; iteration++) { // Message to 'secondCoin_marginal' from UsesEqualDef factor this.secondCoin_marginal_F = UsesEqualDefGibbsOp <bool> .MarginalGibbs <Bernoulli>(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 'bothHeads' from And factor bothHeads_F = Factor.And(this.FirstCoin, secondCoin_uses_F[0]); // Message to 'bothHeads_marginal' from ReplicateWithMarginal factor this.bothHeads_marginal_F = ReplicateGibbsOp <bool> .MarginalGibbs <Bernoulli>(bothHeads_F, this.bothHeads_marginal_F); this.OnProgressChanged(new ProgressChangedEventArgs(iteration)); } this.Changed_firstCoin_numberOfIterations_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; }