Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by lionsav · May 19, 2011 at 05:05 PM · mathfunctionsstatistics

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.

Comment
Add comment · Show 18
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image lionsav · May 19, 2011 at 08:22 PM 0
Share

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

avatar image ckfinite · May 19, 2011 at 08:36 PM 0
Share

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.

avatar image ckfinite · May 19, 2011 at 08:49 PM 0
Share

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?

avatar image lionsav · May 19, 2011 at 09:03 PM 0
Share

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.

avatar image Bunny83 · May 19, 2011 at 10:12 PM 1
Share

@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.

Show more comments

4 Replies

· Add your reply
  • Sort: 
avatar image
3

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

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));
 }
Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

4 People are following this question.

avatar image avatar image avatar image avatar image

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


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges