當前位置: 首頁>>代碼示例>>C#>>正文


C# Beta.GetLogProb方法代碼示例

本文整理匯總了C#中Beta.GetLogProb方法的典型用法代碼示例。如果您正苦於以下問題:C# Beta.GetLogProb方法的具體用法?C# Beta.GetLogProb怎麽用?C# Beta.GetLogProb使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Beta的用法示例。


在下文中一共展示了Beta.GetLogProb方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: drawBetaDistribution

		private static void drawBetaDistribution(Rectangle rect, Beta dist)
		{
			GradientStopCollection gsc = new GradientStopCollection();
			int numStops = 21;
			double mean = dist.GetMean();
			double meanDensity = Math.Exp(dist.GetLogProb(mean));
			double inc = 1.0 / (numStops-1);
			double curr = 0.0;
			double maxLogProb = Double.MinValue;
			double minLogProb = -5.0;
			for (int i=0; i < numStops; i++)
			{
				double logProb = dist.GetLogProb(curr);
				if (logProb > maxLogProb) maxLogProb = logProb;
				curr += inc;
			}
			if (maxLogProb <= minLogProb)
				maxLogProb = minLogProb + 1.0;
			double diff = maxLogProb - minLogProb;
			double mult =  1.0 / (maxLogProb - minLogProb);
			curr = 0.0;
			double blueLeft = 0; double blueRight = 0;
			double redLeft = 255; double redRight = 255;
			double greenLeft = 255; double greenRight = 255;

			for (int i=0; i < numStops; i++)
			{
				double red, green, blue;
				double logProb = dist.GetLogProb(curr);
				if (logProb < minLogProb) logProb = minLogProb;
				double level = mult * (logProb - minLogProb);
				red = level * (mean * redRight + (1.0 - mean) * redLeft);
				green = level * (mean * greenRight + (1.0 - mean) * greenLeft);
				blue =level * (mean * blueRight + (1.0 - mean) * blueLeft);
				byte redb = red < 0.0 ? (byte)0 : red > 255.0 ? (byte)255 : (byte)red;
				byte greenb = green < 0.0 ? (byte)0 : green > 255.0 ? (byte)255 : (byte)green;
				byte blueb = blue < 0.0 ? (byte)0 : blue > 255.0 ? (byte)255 : (byte)blue;
				gsc.Add(new GradientStop { Color =new Color() { A = 255, R = redb, G = greenb, B = blueb } , Offset = curr});
    			curr += inc;
			}
			LinearGradientBrush brush = rect.Fill as LinearGradientBrush;
			brush.GradientStops = gsc;
		}
開發者ID:xornand,項目名稱:Infer.Net,代碼行數:43,代碼來源:ClinicalTrial.xaml.cs

示例2: LogAverageFactor

		/// <summary>
		/// Evidence message for EP.
		/// </summary>
		/// <param name="prob">Constant value for 'prob'.</param>
		/// <param name="mean">Constant value for 'mean'.</param>
		/// <param name="totalCount">Constant value for 'totalCount'.</param>
		/// <returns>Logarithm of the factor's average value across the given argument distributions.</returns>
		/// <remarks><para>
		/// The formula for the result is <c>log(sum_() p() factor(prob,mean,totalCount))</c>.
		/// </para></remarks>
		public static double LogAverageFactor(double prob, double mean, double totalCount)
		{
			var g = new Beta(mean * totalCount, (1 - mean) * totalCount);
			return g.GetLogProb(prob);
		}
開發者ID:dtrckd,項目名稱:Mixed-Membership-Stochastic-Blockmodel,代碼行數:15,代碼來源:BetaOp.cs

示例3: LogAverageFactor

		/// <summary>
		/// Evidence message for EP
		/// </summary>
		/// <param name="logistic">Incoming message from 'logistic'.</param>
		/// <param name="x">Constant value for 'x'.</param>
		/// <returns>Logarithm of the factor's average value across the given argument distributions</returns>
		/// <remarks><para>
		/// The formula for the result is <c>log(sum_(logistic) p(logistic) factor(logistic,x))</c>.
		/// </para></remarks>
		public static double LogAverageFactor(Beta logistic, double x)
		{
			return logistic.GetLogProb(MMath.Logistic(x));
		}
開發者ID:xornand,項目名稱:Infer.Net,代碼行數:13,代碼來源:Logistic.cs


注:本文中的Beta.GetLogProb方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。