Skip to content

Instantly share code, notes, and snippets.

@Osinko
Last active August 15, 2019 11:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Osinko/9b8de6253201247932ec6cad9ea36f82 to your computer and use it in GitHub Desktop.
Save Osinko/9b8de6253201247932ec6cad9ea36f82 to your computer and use it in GitHub Desktop.
ポアソン分布と二項分布の関係の検証
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Case5 : MonoBehaviour
{
//二項分布との比較。コインを3回投げて表が2回以上出る確率は?
void Start()
{
for (int j = 0; j < 10000; j++)
{
float winCount = 0;
for (int i = 0; i < 3; i++) //3回投げるシミュレーション
{
if (TossDice()) winCount++;
}
print(winCount);
}
}
public bool TossDice()
{
if (Random.Range(1, 2 + 1) <= 1) return true; // コインを投げるベルヌーイ試行(ここはp(確率0.5)となるがポアソン分布で利用するとしては値が大きすぎる)
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment