- Home /
math and statistics functions
Does anybody have any math (non-linear regression) or statistics functions they would be willing to share. I have a project and I'm looking for some good math libraries. I've had no luck integrating some others.
I'm looking for T-Test Correlation Chi Square Anova Non-Linear Regression etc. kinds of things.
Thanks for any pointers.
I tried integrating it as a dll but I couldn't get unity3d to recognize it. I copied it into the assets folder then tried to use an import statement but it failed with some errors. Would you happen to know how to get this to work from the javascript side?
Thanks, Dan
CLR is an acronym for Common Language Runtime, the $$anonymous$$icrosoft system that $$anonymous$$ono (the scripting system in Unity) is based off of. $$anonymous$$ath.NET will not work like what you have been doing. It is a external library, so you will need to add it's DLLs into Unity (as assets) then add the line import $$anonymous$$athNet.Numerics; to a C# file. Then you can use the $$anonymous$$ath.NET functions in the file inside Unity.
No, JavaScript will not load the import. You need a C# file. What are the errors you are getting, what DLL did you use, and what does the C# file you are using look like?
Hi. I tried using the $$anonymous$$athNet.Iridium.dll dnAnalytics.dll and dotNumerics.dll. None of them worked as I was trying to put them in the assets folder then tried to use their "Namespace" to import them through javascript. So you're saying I need a C# file to import them? I would love to try this and get it working if you can point me to an example of 1. How to setup the c# file to import the dll. and 2. How to access the functions from a javascript file. By the way I have not been able to get an answer to this question on the scripting forum.
@macfanpro: sure it can. I just tried it :D. I think you did the same mistake like most people that are new to Unity: Unityscript has nithing to do with JScript. Web-based JS uses a prototype based object system but UnityScript is build on top of mono and therefore uses an inheritance-based class model. You can use the same namespaces like in C#. Either directly or with import $$anonymous$$athNet.Numerics;
at the top.
Answer by ckfinite · May 19, 2011 at 09:06 PM
Since the comments don't let me add code, here is a demo C# script I used to make sure Math.NET worked.
using UnityEngine;
using System.Collections;
using MathNet.Numerics;
public class MathNETTest : MonoBehaviour {
// Use this for initialization
void Start ()
{
Debug.Log(Trig.Cosine(Mathf.PI));
}
// Update is called once per frame
void Update () {
}
}
This needs to be inside a file called MathNETTest.cs, and it should log a number very close to -1.
Answer by ckfinite · May 19, 2011 at 08:18 PM
Have you seen Math.NET? It seems to have what you want. However, I think that is for the CLR. You will need to try it.
Answer by Bunny83 · May 19, 2011 at 10:15 PM
Just to complete macfanpro's answer, here's his example in Unityscript:
import MathNet.Numerics;
function Start ()
{
Debug.Log(Trig.Cosine(Mathf.PI));
// or
Debug.Log(MathNet.Numerics.Trig.Cosine(Mathf.PI));
}
Answer by TheD0ctor · Dec 02, 2016 at 04:47 PM
You could use Math.NET for Unity (see https://forum.unity3d.com/threads/coming-soon-math-net-for-unit.444045/#post-2871830) which is a port of the latest version of Math.NET Numerics.
Your answer
Follow this Question
Related Questions
How do I calculate the population variance and sample variance? 0 Answers
How do I make a particle system follow a function? 1 Answer
All Mathf functions 1 Answer
Function for returning x-length from vector made from given length and direction. 1 Answer
Movement behaves differently on X axis 0 Answers