Created
January 7, 2020 06:15
-
-
Save keijiro/3939dd6490272920b8856649c8cf8f76 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 UnityEngine; | |
using Random = Unity.Mathematics.Random; | |
public class RandomTest : MonoBehaviour | |
{ | |
void Start() | |
{ | |
const uint iteration = 1000; | |
var sum = new float[5]; | |
for (var seed = 1u; seed <= iteration ; seed++) | |
{ | |
var r = new Random(seed); | |
for (var i = 0; i < sum.Length; i++) sum[i] += r.NextFloat(); | |
} | |
var text = "Average of n-th number in random number sequences\n"; | |
for (var i = 0; i < sum.Length; i++) | |
text += "[" + i + "]: " + (sum[i] / iteration) + "\n"; | |
Debug.Log(text); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment