Multinomial Distribution in Unity?
Hi all,
I'm relatively new to Unity, but with a good deal of programming experience (though not in C#).
I was surprised to find that the Unity scripter only had a built in Uniform distribution, in the form of Random.Range. My question is regarding what the best way is to gain the use of other distributions. I've seen that some people have packaged up some in the Asset store; Gaussian, Exponential, but it's the Multinomial I really want to be able to use.
Surely there must be a way to import other general C# packages? A bit of google-sleuthing suggested something called NuGet might be the way to go?
Very appreciative of any help anyone can provide. Many thanks, Thom
P.S. I'm only doing a few draws at a time so I can't do a multivariate-normal approximation!
Answer by elenzil · Jul 29, 2021 at 08:40 PM
yep, NuGet is a popular package management system for Windows. It's a .zip file at core, and can package up source or binaries. I've used it in unity via NugetForUnity, I believe.
.
This project seems to have specific non-nuget instructions in the README for Unity.
.
That said, a little web-searching suggests the MultiNomial isn't that involved, and you might consider just implementing it yourself. That way you live to put off package management another day.
.
Another option, if you find a concise implementation in a git repository is to pull the repository in as a git submodule.
Thank you for the fab answer. Indeed, looking today on even just the multinomial wikipedia page, there are some very compact ways to impose a multinomial on the standard uniform.
If I could just ask a little more on your final suggestion, you mean a git repo already configured for Unity3D specifically?
Glad that's looking promising. I was thinking maybe just a general C# repo with a small amount of code, but I didn't find any likely candidates tbh.
Answer by Captain_Pineapple · Jul 29, 2021 at 06:52 AM
Not sure how the underlying distibution looks but Unity offers functions like Random.insideUnitCircle
and Random.insideUnitSphere
.
Other then that:
What exactly stops you from doing 2 consecutive drafts from a (for example) Gaussian Distribution to get a multidimensional value?
Random.insideUnitCircle
and Random.insideUnitSphere
are from co-opted Uniform distributions unfortunately.
It's not multi-dimensional I'm after, it's multinomial, i.e. the n-dimensional generalisation of the Binomial distribution.
Your answer
Follow this Question
Related Questions
Randomness based on time passed 2 Answers
Random colors? 0 Answers
Randomly display an asset from Selection of assets 0 Answers
Random colors? 0 Answers
Getting A Random Between Two Doubles 3 Answers