当前位置: 首页>>代码示例>>C#>>正文


C# Gaussian.Sample方法代码示例

本文整理汇总了C#中Gaussian.Sample方法的典型用法代码示例。如果您正苦于以下问题:C# Gaussian.Sample方法的具体用法?C# Gaussian.Sample怎么用?C# Gaussian.Sample使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Gaussian的用法示例。


在下文中一共展示了Gaussian.Sample方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Weights

		public static Vector Weights(Gaussian A, Gaussian B, Gaussian to_A, Gaussian to_B)
		{
			if (A.IsPointMass) return Weights(A.Point, B);
			if (B.IsPointMass) return Weights(A, B.Point);
			A *= to_A;
			B *= to_B;
			double ma, va, mb, vb;
			A.GetMeanAndVariance(out ma, out va);
			B.GetMeanAndVariance(out mb, out vb);
			double ma2 = va + ma*ma;
			double mb2 = vb + mb*mb;
			Vector w = Vector.Zero(3);
			w[0] = ma2*mb;
			w[1] = mb2*ma;
			w[2] = ma*mb;
			PositiveDefiniteMatrix M = new PositiveDefiniteMatrix(3, 3);
			M[0, 0] = ma2;
			M[0, 1] = ma*mb;
			M[0, 2] = ma;
			M[1, 0] = ma*mb;
			M[1, 1] = mb2;
			M[1, 2] = mb;
			M[2, 0] = ma;
			M[2, 1] = mb;
			M[2, 2] = 1;
			w = w.PredivideBy(M);
			Vector weights = Vector.Zero(4);
			weights[0] = w[0];
			weights[1] = w[1];
			weights[2] = w[2];
			weights[3] = ma2*mb2 - w[0]*ma2*mb - w[1]*mb2*ma - w[2]*ma*mb;
			if (weights[3] < 0) weights[3] = 0;
			if (false) {
				// debugging
				GaussianEstimator est = new GaussianEstimator();
				for (int i = 0; i < 10000; i++) {
					double sa = A.Sample();
					double sb = B.Sample();
					double f = sa*sb;
					double g = sa*weights[0] + sb*weights[1] + weights[2];
					est.Add(f-g);
				}
				Console.WriteLine(weights);
				Console.WriteLine(est.GetDistribution(new Gaussian()));
			}
			return weights;
		}
开发者ID:dtrckd,项目名称:Mixed-Membership-Stochastic-Blockmodel,代码行数:47,代码来源:Product.cs

示例2: Sample

		public int[][] Sample(int nSubjects, int nQuestions, int nChoices, Gaussian abilityPrior, Gaussian difficultyPrior, Gamma discriminationPrior,
			out double[] ability, out double[] difficulty, out double[] discrimination, out int[] trueAnswer)
		{
			ability = Util.ArrayInit(nSubjects, s => abilityPrior.Sample());
			difficulty = Util.ArrayInit(nQuestions, q => difficultyPrior.Sample());
			discrimination = Util.ArrayInit(nQuestions, q => discriminationPrior.Sample());
			trueAnswer = Util.ArrayInit(nQuestions, q => Rand.Int(nChoices));
			int[][] response = new int[nSubjects][];
			for (int s = 0; s < nSubjects; s++) {
				response[s] = new int[nQuestions];
				for (int q = 0; q < nQuestions; q++) {
					double advantage = ability[s] - difficulty[q];
					double noise = Gaussian.Sample(0, discrimination[q]);
					bool correct = (advantage > noise);
					if (correct) response[s][q] = trueAnswer[q];
					else response[s][q] = Rand.Int(nChoices);
				}
			}
			return response;
		}
开发者ID:prgoodwin,项目名称:HabilisX,代码行数:20,代码来源:DifficultyAbility.cs


注:本文中的Gaussian.Sample方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。