Last active
August 15, 2019 11:10
-
-
Save Osinko/e1f556ad9f10e82e3e3008d5286693da to your computer and use it in GitHub Desktop.
ポアソン分布と二項分布の関係の検証
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class Case1 : MonoBehaviour | |
{ | |
//国道100km辺りのガソリンスタンド数が17件であった時、あと5km走ってガソリンスタンドに出会う確率は? | |
void Start() | |
{ | |
for (int j = 0; j < 10000; j++) | |
{ | |
float winCount = 0; | |
for (int i = 0; i < 5; i++) //5km走るシミュレーション | |
{ | |
if (TossDice()) winCount++; | |
} | |
print(winCount); | |
} | |
} | |
public bool TossDice() | |
{ | |
if (Random.Range(1, 100 + 1) <= 17) return true; //17%のベルヌーイ試行 | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment