/// <summary>Computations that depend on the observed value of FeatureCount and FeatureValues and InstanceCount and Labels and numberOfIterations and WeightConstraints and WeightPriors</summary>
 /// <param name="numberOfIterations">The number of times to iterate each loop</param>
 private void Changed_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstraints_WeightP8(int numberOfIterations)
 {
     if (this.Changed_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstraints_WeightP8_isDone)
     {
         return;
     }
     for (int iteration = this.numberOfIterationsDone; iteration < numberOfIterations; iteration++)
     {
         for (int FeatureRange = 0; FeatureRange < this.featureCount; FeatureRange++)
         {
             this.Weights_depth1_rep_F_marginal[FeatureRange] = ReplicateOp_Divide.Marginal <Gaussian>(this.Weights_depth1_rep_B_toDef[FeatureRange], this.Weights_uses_F[1][FeatureRange], this.Weights_depth1_rep_F_marginal[FeatureRange]);
         }
         for (int InstanceRange = 0; InstanceRange < this.instanceCount; InstanceRange++)
         {
             for (int FeatureRange = 0; FeatureRange < this.featureCount; FeatureRange++)
             {
                 this.Weights_depth1_rep_F[FeatureRange][InstanceRange] = ReplicateOp_Divide.UsesAverageConditional <Gaussian>(this.Weights_depth1_rep_B[FeatureRange][InstanceRange], this.Weights_depth1_rep_F_marginal[FeatureRange], InstanceRange, this.Weights_depth1_rep_F[FeatureRange][InstanceRange]);
                 this.FeatureScores_F[InstanceRange][FeatureRange]      = GaussianProductOpBase.ProductAverageConditional(this.featureValues[InstanceRange][FeatureRange], this.Weights_depth1_rep_F[FeatureRange][InstanceRange]);
             }
             this.Score_F[InstanceRange]          = FastSumOp.SumAverageConditional(this.FeatureScores_F[InstanceRange]);
             this.NoisyScore_F[InstanceRange]     = GaussianFromMeanAndVarianceOp.SampleAverageConditional(this.Score_F[InstanceRange], 1.0);
             this.NoisyScore_use_B[InstanceRange] = IsPositiveOp_Proper.XAverageConditional(Bernoulli.PointMass(this.labels[InstanceRange]), this.NoisyScore_F[InstanceRange]);
             this.Score_B[InstanceRange]          = GaussianFromMeanAndVarianceOp.MeanAverageConditional(this.NoisyScore_use_B[InstanceRange], 1.0);
             this.FeatureScores_B[InstanceRange]  = FastSumOp.ArrayAverageConditional <DistributionStructArray <Gaussian, double> >(this.Score_B[InstanceRange], this.Score_F[InstanceRange], this.FeatureScores_F[InstanceRange], this.FeatureScores_B[InstanceRange]);
             for (int FeatureRange = 0; FeatureRange < this.featureCount; FeatureRange++)
             {
                 this.Weights_depth1_rep_B[FeatureRange][InstanceRange] = GaussianProductOpBase.BAverageConditional(this.FeatureScores_B[InstanceRange][FeatureRange], this.featureValues[InstanceRange][FeatureRange]);
                 this.Weights_depth1_rep_F_marginal[FeatureRange]       = ReplicateOp_Divide.MarginalIncrement <Gaussian>(this.Weights_depth1_rep_F_marginal[FeatureRange], this.Weights_depth1_rep_F[FeatureRange][InstanceRange], this.Weights_depth1_rep_B[FeatureRange][InstanceRange]);
             }
         }
         for (int FeatureRange = 0; FeatureRange < this.featureCount; FeatureRange++)
         {
             this.Weights_depth1_rep_B_toDef[FeatureRange] = ReplicateOp_Divide.ToDef <Gaussian>(this.Weights_depth1_rep_B[FeatureRange], this.Weights_depth1_rep_B_toDef[FeatureRange]);
         }
         this.OnProgressChanged(new ProgressChangedEventArgs(iteration));
     }
     for (int _iv = 0; _iv < this.featureCount; _iv++)
     {
         this.Weights_uses_B[1][_iv] = ArrayHelper.SetTo <Gaussian>(this.Weights_uses_B[1][_iv], this.Weights_depth1_rep_B_toDef[_iv]);
     }
     this.Weights_uses_F[0] = ReplicateOp_NoDivide.UsesAverageConditional <DistributionStructArray <Gaussian, double> >(this.Weights_uses_B, this.weightPriors, 0, this.Weights_uses_F[0]);
     this.ModelSelector_selector_cases_0_uses_B[6] = Bernoulli.FromLogOdds(ReplicateOp.LogEvidenceRatio <DistributionStructArray <Gaussian, double> >(this.Weights_uses_B, this.weightPriors, this.Weights_uses_F));
     this.ModelSelector_selector_cases_0_uses_B[7] = Bernoulli.FromLogOdds(ConstrainEqualRandomOp <double[]> .LogEvidenceRatio <DistributionStructArray <Gaussian, double> >(this.Weights_uses_F[0], this.weightConstraints));
     for (int FeatureRange = 0; FeatureRange < this.featureCount; FeatureRange++)
     {
         this.ModelSelector_selector_cases_0_rep3_uses_B[FeatureRange][1] = Bernoulli.FromLogOdds(ReplicateOp.LogEvidenceRatio <Gaussian>(this.Weights_depth1_rep_B[FeatureRange], this.Weights_uses_F[1][FeatureRange], this.Weights_depth1_rep_F[FeatureRange]));
         this.ModelSelector_selector_cases_0_rep3_B[FeatureRange]         = ReplicateOp_NoDivide.DefAverageConditional <Bernoulli>(this.ModelSelector_selector_cases_0_rep3_uses_B[FeatureRange], this.ModelSelector_selector_cases_0_rep3_B[FeatureRange]);
     }
     this.ModelSelector_selector_cases_0_uses_B[12] = ReplicateOp_NoDivide.DefAverageConditional <Bernoulli>(this.ModelSelector_selector_cases_0_rep3_B, this.ModelSelector_selector_cases_0_uses_B[12]);
     for (int InstanceRange = 0; InstanceRange < this.instanceCount; InstanceRange++)
     {
         this.ModelSelector_selector_cases_0_rep8_B[InstanceRange] = Bernoulli.FromLogOdds(IsPositiveOp.LogEvidenceRatio(this.labels[InstanceRange], this.NoisyScore_F[InstanceRange]));
     }
     this.ModelSelector_selector_cases_0_uses_B[17] = ReplicateOp_NoDivide.DefAverageConditional <Bernoulli>(this.ModelSelector_selector_cases_0_rep8_B, this.ModelSelector_selector_cases_0_uses_B[17]);
     this.ModelSelector_selector_cases_0_B          = ReplicateOp_NoDivide.DefAverageConditional <Bernoulli>(this.ModelSelector_selector_cases_0_uses_B, this.ModelSelector_selector_cases_0_B);
     this.ModelSelector_selector_cases_B[0]         = ArrayHelper.SetTo <Bernoulli>(this.ModelSelector_selector_cases_B[0], this.ModelSelector_selector_cases_0_B);
     this.ModelSelector_selector_B = CasesOp.BAverageConditional(this.ModelSelector_selector_cases_B);
     this.ModelSelector_marginal_F = VariableOp.MarginalAverageConditional <Bernoulli>(this.ModelSelector_selector_B, this.vBernoulli0, this.ModelSelector_marginal_F);
     this.Weights_use_B            = ReplicateOp_NoDivide.DefAverageConditional <DistributionStructArray <Gaussian, double> >(this.Weights_uses_B, this.Weights_use_B);
     this.Weights_marginal_F       = VariableOp.MarginalAverageConditional <DistributionStructArray <Gaussian, double> >(this.Weights_use_B, this.weightPriors, this.Weights_marginal_F);
     this.Changed_FeatureCount_FeatureValues_InstanceCount_Labels_numberOfIterations_WeightConstraints_WeightP8_isDone = true;
 }
        /// <summary>Computations that depend on the observed value of FeatureIndexes and FeatureValues and InstanceCount and InstanceFeatureCounts and Labels and numberOfIterations and WeightConstraints and WeightPriors</summary>
        /// <param name="numberOfIterations">The number of times to iterate each loop</param>
        private void Changed_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Labels_numberOfIterations_W7(int numberOfIterations)
        {
            if (this.Changed_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Labels_numberOfIterations_W7_isDone)
            {
                return;
            }
            for (int iteration = this.numberOfIterationsDone; iteration < numberOfIterations; iteration++)
            {
                for (int InstanceRange = 0; InstanceRange < this.instanceCount; InstanceRange++)
                {
                    this.Weights_FeatureIndexes_F[InstanceRange] = JaggedSubarrayWithMarginalOp <double> .ItemsAverageConditional <DistributionStructArray <Gaussian, double>, Gaussian, DistributionStructArray <Gaussian, double> >(this.IndexedWeights_B[InstanceRange], this.Weights_uses_F[1], this.Weights_marginal_F, this.featureIndexes, InstanceRange, this.Weights_FeatureIndexes_F[InstanceRange]);

                    for (int InstanceFeatureRanges = 0; InstanceFeatureRanges < this.instanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++)
                    {
                        this.FeatureScores_F[InstanceRange][InstanceFeatureRanges] = GaussianProductOpBase.ProductAverageConditional(this.featureValues[InstanceRange][InstanceFeatureRanges], this.Weights_FeatureIndexes_F[InstanceRange][InstanceFeatureRanges]);
                    }
                    this.Score_F[InstanceRange]          = FastSumOp.SumAverageConditional(this.FeatureScores_F[InstanceRange]);
                    this.NoisyScore_F[InstanceRange]     = GaussianFromMeanAndVarianceOp.SampleAverageConditional(this.Score_F[InstanceRange], 1.0);
                    this.NoisyScore_use_B[InstanceRange] = IsPositiveOp_Proper.XAverageConditional(Bernoulli.PointMass(this.labels[InstanceRange]), this.NoisyScore_F[InstanceRange]);
                    this.Score_B[InstanceRange]          = GaussianFromMeanAndVarianceOp.MeanAverageConditional(this.NoisyScore_use_B[InstanceRange], 1.0);
                    this.FeatureScores_B[InstanceRange]  = FastSumOp.ArrayAverageConditional <DistributionStructArray <Gaussian, double> >(this.Score_B[InstanceRange], this.Score_F[InstanceRange], this.FeatureScores_F[InstanceRange], this.FeatureScores_B[InstanceRange]);
                    for (int InstanceFeatureRanges = 0; InstanceFeatureRanges < this.instanceFeatureCounts[InstanceRange]; InstanceFeatureRanges++)
                    {
                        this.IndexedWeights_B[InstanceRange][InstanceFeatureRanges] = GaussianProductOpBase.BAverageConditional(this.FeatureScores_B[InstanceRange][InstanceFeatureRanges], this.featureValues[InstanceRange][InstanceFeatureRanges]);
                    }
                    this.Weights_marginal_F = JaggedSubarrayWithMarginalOp <double> .MarginalIncrementItems <DistributionStructArray <Gaussian, double>, Gaussian, DistributionStructArray <Gaussian, double> >(this.IndexedWeights_B[InstanceRange], this.Weights_FeatureIndexes_F[InstanceRange], this.featureIndexes, InstanceRange, this.Weights_marginal_F);
                }
                this.OnProgressChanged(new ProgressChangedEventArgs(iteration));
            }
            this.Weights_uses_B[1] = JaggedSubarrayWithMarginalOp <double> .ArrayAverageConditional <DistributionStructArray <Gaussian, double> >(this.Weights_uses_F[1], this.Weights_marginal_F, this.Weights_uses_B[1]);

            this.Weights_uses_F[0] = ReplicateOp_NoDivide.UsesAverageConditional <DistributionStructArray <Gaussian, double> >(this.Weights_uses_B, this.weightPriors, 0, this.Weights_uses_F[0]);
            this.ModelSelector_selector_cases_0_uses_B[3] = Bernoulli.FromLogOdds(ReplicateOp.LogEvidenceRatio <DistributionStructArray <Gaussian, double> >(this.Weights_uses_B, this.weightPriors, this.Weights_uses_F));
            this.ModelSelector_selector_cases_0_uses_B[4] = Bernoulli.FromLogOdds(ConstrainEqualRandomOp <double[]> .LogEvidenceRatio <DistributionStructArray <Gaussian, double> >(this.Weights_uses_F[0], this.weightConstraints));
            this.ModelSelector_selector_cases_0_uses_B[8] = Bernoulli.FromLogOdds(JaggedSubarrayWithMarginalOp <double> .LogEvidenceRatio <Gaussian, DistributionRefArray <DistributionStructArray <Gaussian, double>, double[]>, DistributionStructArray <Gaussian, double> >(this.IndexedWeights_B, this.Weights_uses_F[1], this.featureIndexes, this.Weights_FeatureIndexes_F));
            for (int InstanceRange = 0; InstanceRange < this.instanceCount; InstanceRange++)
            {
                this.ModelSelector_selector_cases_0_rep9_B[InstanceRange] = Bernoulli.FromLogOdds(IsPositiveOp.LogEvidenceRatio(this.labels[InstanceRange], this.NoisyScore_F[InstanceRange]));
            }
            this.ModelSelector_selector_cases_0_uses_B[16] = ReplicateOp_NoDivide.DefAverageConditional <Bernoulli>(this.ModelSelector_selector_cases_0_rep9_B, this.ModelSelector_selector_cases_0_uses_B[16]);
            this.ModelSelector_selector_cases_0_B          = ReplicateOp_NoDivide.DefAverageConditional <Bernoulli>(this.ModelSelector_selector_cases_0_uses_B, this.ModelSelector_selector_cases_0_B);
            this.ModelSelector_selector_cases_B[0]         = ArrayHelper.SetTo <Bernoulli>(this.ModelSelector_selector_cases_B[0], this.ModelSelector_selector_cases_0_B);
            this.ModelSelector_selector_B = CasesOp.BAverageConditional(this.ModelSelector_selector_cases_B);
            this.ModelSelector_marginal_F = VariableOp.MarginalAverageConditional <Bernoulli>(this.ModelSelector_selector_B, this.vBernoulli1, this.ModelSelector_marginal_F);
            this.Weights_B = ReplicateOp_NoDivide.DefAverageConditional <DistributionStructArray <Gaussian, double> >(this.Weights_uses_B, this.Weights_B);
            this.Changed_FeatureIndexes_FeatureValues_InstanceCount_InstanceFeatureCounts_Labels_numberOfIterations_W7_isDone = true;
        }