math

Fit a 3D line to 3D point data in Java?

久未见 提交于 2020-01-21 06:53:54
问题 I've spent a decent amount of time trying to hunt down a simple way of doing this - ideally, a magical library exists out there somewhere that will take my set of 3D data points and return 2 points on the best fit line using either orthogonal regression or least squares and also return the error of the fitted line. Does such a thing exist, and if so, where? 回答1: This is easy enough to do, but to write it yourself you will need an eigenvalue solver or a singular value decomposition. Create the

Have decimal amount, want to trim to 2 decimal places if present

╄→尐↘猪︶ㄣ 提交于 2020-01-21 06:41:01
问题 Have decimal amount, want to trim to 2 decimal places if present 回答1: Have you tried using value = Decimal.Round(value, 2) ? For example: using System; class Test { static void Main() { decimal d = 1234.5678m; Console.WriteLine("Before: {0}", d); // Prints 1234.5678 d = decimal.Round(d, 2); Console.WriteLine("After: {0}", d); // Prints 1234.57 } } Note that this is rounding rather than just trimming (so here it's rounded up)... what exactly do you need? Chances that the Decimal struct

Conversion euler to matrix and matrix to euler

断了今生、忘了曾经 提交于 2020-01-21 01:47:29
问题 I'm trying to convert a 3D rotation described in term of euler angles into a matrix and then back, using .NET/C#. My conventions are: left handed system (x right, y top, z forward) order of rotations: heading around y, pitch around x, bank around z rotations are positive using the left hand rule (thumb pointing to +infinity) My trial is: Euler to matrix (I've removed the x,y,z translation part for simplification) Matrix3D matrix = new Matrix3D() { M11 = cosH * cosB - sinH * sinP * sinB, M12 =

How are logarithms programmed? [closed]

独自空忆成欢 提交于 2020-01-20 22:07:18
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . Are they just figured out using the same mechanism as a linear search or is the range narrowed down somehow, similar to a binary search. 回答1: The implementation of a function such as the natural logarithm in any

How to use GPU for mathematics [closed]

落爺英雄遲暮 提交于 2020-01-20 13:32:25
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago . I am looking at utilising the GPU for crunching some equations but cannot figure out how I can access it from C#. I know that the XNA and DirectX frameworks allow you to use shaders in order to access the GPU, but how would I go about accessing it without these frameworks? 回答1: I

How to use GPU for mathematics [closed]

余生颓废 提交于 2020-01-20 13:31:34
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago . I am looking at utilising the GPU for crunching some equations but cannot figure out how I can access it from C#. I know that the XNA and DirectX frameworks allow you to use shaders in order to access the GPU, but how would I go about accessing it without these frameworks? 回答1: I

Can i calculate exp(1+2j) in python?

只愿长相守 提交于 2020-01-20 07:53:08
问题 Can i calculate exp(1+2j) in python? exp(1+2j) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: can't convert complex to float 回答1: You need a complex version of this function: cmath.exp(1+2j) See http://docs.python.org/library/cmath.html 回答2: You may want to import e from the math module to do this. For example: >>> from math import e >>> print e ** (1+2j) (-1.1312043837568135+2.4717266720048188j) 来源: https://stackoverflow.com/questions/8498310/can-i

How to calculate the scale's result?

和自甴很熟 提交于 2020-01-19 17:12:29
问题 I am new to d3.js library, and I am trying to understand the concept of domain and ranges. I read Scott Murray's book, but I don't know how to calculate it. I have this: var scale = d3.scale.linear() .domain([100, 500]) .range([10, 350]); scale(100); //Returns 10 scale(300); //Returns 180 scale(500); //Returns 350 I know that 100 units of my input represent 10 in my output, and the same with 500 and 350... but why 180 is returned for 300 as input? How can I calculate this value? I read this

How to calculate the scale's result?

拈花ヽ惹草 提交于 2020-01-19 17:12:11
问题 I am new to d3.js library, and I am trying to understand the concept of domain and ranges. I read Scott Murray's book, but I don't know how to calculate it. I have this: var scale = d3.scale.linear() .domain([100, 500]) .range([10, 350]); scale(100); //Returns 10 scale(300); //Returns 180 scale(500); //Returns 350 I know that 100 units of my input represent 10 in my output, and the same with 500 and 350... but why 180 is returned for 300 as input? How can I calculate this value? I read this

How can I use numpy.correlate to do autocorrelation?

北战南征 提交于 2020-01-18 05:47:05
问题 I need to do auto-correlation of a set of numbers, which as I understand it is just the correlation of the set with itself. I've tried it using numpy's correlate function, but I don't believe the result, as it almost always gives a vector where the first number is not the largest, as it ought to be. So, this question is really two questions: What exactly is numpy.correlate doing? How can I use it (or something else) to do auto-correlation? 回答1: To answer your first question, numpy.correlate(a