Skip to content

Instantly share code, notes, and snippets.

@keijiro
Created January 7, 2020 06:15
Show Gist options
  • Save keijiro/3939dd6490272920b8856649c8cf8f76 to your computer and use it in GitHub Desktop.
Save keijiro/3939dd6490272920b8856649c8cf8f76 to your computer and use it in GitHub Desktop.
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