많은 수의 실행의 자세한 결과 (확률 트리)를 얻는 방법 : 시간베르누이 실험에게 다음과 같은 실험을 가정 할 시간
I의 N 번호를 (성공 P의 확률로) 같은 베르누이 시험을 실행 다음 정보가 필요합니다 : 성공/실패 가능성이있는 모든 가능한 순서.
예 :
FFF 0.216
: 성공 P의 확률로 베르누이 실험 = 40 %는 다음과 같은 결과를 얻을 것이다 3 배 (S 성공이고, F는 실패이다) 실행될 SFF 0.144
FSF 0.144
SSF 0.096
FFS 0.144
SFS 0.096
FSS 0.096
SSS 0.064
나는 결과를 얻을를 bruteforce하려고하지만 급속 초크 만 N = 25 , OutOfMemoryException이 발생합니다 ...
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;
namespace ConsoleApplication
{
class Program
{
static Dictionary<string, double> finalResultProbabilities = new Dictionary<string, double>();
static void Main(string[] args)
{
// OutOfMemoryException if I set it to 25 :(
//var nbGames = 25;
var nbGames = 3;
var probabilityToWin = 0.4d;
CalculateAverageWinningStreak(string.Empty, 1d, nbGames, probabilityToWin);
// Do something with the finalResultProbabilities data...
}
static void CalculateAverageWinningStreak(string currentResult, double currentProbability, int nbGamesRemaining, double probabilityToWin)
{
if (nbGamesRemaining == 0)
{
finalResultProbabilities.Add(currentResult, currentProbability);
return;
}
CalculateAverageWinningStreak(currentResult + "S", currentProbability * probabilityToWin, nbGamesRemaining - 1, probabilityToWin);
CalculateAverageWinningStreak(currentResult + "F", currentProbability * (1 - probabilityToWin), nbGamesRemaining - 1, probabilityToWin);
}
}
}
나는 최적이 할 수있는 수학적 방법이 있나요 (모든 P에 대한 3 초 미만에 결과를 얻을 수) 적시
에 = 3000 N을 지원할 수 있어야합니다?
왜 * 모든 * 결과를 저장 하시겠습니까? 'P (F ... S ... F ... S) == P (S) ** (S 수) * P (F) ** (F 수) ' –
@DmitryBychenko 가장 긴 우승의 평균 (0.216 * 0 + 0.144 * 1 + 0.144 * 1 + 0.096 * 2 + 0.144 * 1 + 0.096 * 1 + 0.096 * 2 + 0.064 * 3 = 1.104) – ibiza