math

Statistical Summarization of records

Here is the real world issue that we are solving. We have some rather large data sets that need to be aggregated and summarized in real time with a number of filters and formulas applied to them. It works fine to apply these to each record in real time when the data set is less than 50,000 records but as we approach 100,000 and then 100+...

C: Math functions?

What include statement do I need to access the math functions in this C code? unsigned int fibonacci_closed(unsigned int n) { double term_number = (double) n; double golden_ratio = (1 + sqrt(5)) / 2; double numerator = pow(golden_ratio, term_number); return round(numerator/sqrt(5)); } I tried #include <math.h> but that didn't seem...

Generating a probability distribution

Given an array of size n I want to generate random probabilities for each index such that Sigma(a[0]..a[n-1])=1 One possible result might be: 0 1 2 3 4 0.15 0.2 0.18 0.22 0.25 Another perfectly legal result can be: 0 1 2 3 4 0.01 0.01 0.96 0.01 0.01 How can I generate these easily and quick...

How to get unrotated display object width/height of a rotated display object?

If I create a rectangle with 100px width and 100px height and then rotate it, the size of the element's "box" will have increased. With 45 rotation, the size becomes about 143x143 (from 100x100). Doing sometimes like cos(angleRad) * currentWidth seems to work for 45 rotation, but for other bigger angles it doesn't. At the moment I am ...

Drawing Collision on Screen

And here we are for another question. After the previous one, i finally completed the kDop system and everything related. (Hierarchycal tree of kDop, etc..) Everything works fine. Now i want to draw on screen the collision for debug purpose and to see the result of the work. (To see if the hierarchical choice i've done in a particular...

Where can one post nicely formatted code combined with LaTeX for mathematical expressions?

Hi there, Admittedly not a programming question, but I don't really know where else to ask this... I'm planning to start a blog to post the stuff I'm working on, which is mostly about Expression Trees & Mathematics. Hopefully this will help me focus on the problem at hand instead of going off every possible tangent that comes up. I wo...

AS3 Circling the stage

I am trying to have flash draw a line from the center of the stage out and increment around the stage. Not sure what math I would use to do this though. So far I have the line going out to a certain point but not sure how to change that point so that it circles around whatever the dimensions of my stage would be. So far I have this: va...

How can i extract rectangles from a rectangle intersection.

Having a rectangle (A) and intersecting it with another rectangle (B), how could I extract the other rectangles created through that intersection (C,D,E & F)? AAAAAAAAAAAAAA CCCFFFFDDDDDDD AAABBBBAAAAAAA CCCBBBBDDDDDDD AAABBBBAAAAAAA -> CCCBBBBDDDDDDD AAAAAAAAAAAAAA CCCEEEEDDDDDDD AAAAAAAAAAAAAA CCCEEEEDDDDDDD And could th...

How to calculate modulus of large numbers?

How to calculate modulus of 5^55 modulus 221 without much use of calculator. I guess there is some simple principles in number theory in cryptography to calculate such things. Thanks ...

PHP, Prevent from removing leading zeros

I have an array of numbers from 5 to 6.4 but the numbers are relating to feet and inches and I am using them for calculation. When I come to use 5.10 it removes the zero and I have the same output as though it was 5.1. Is there anyway to prevent PHP removing the 0. I presume it does some sort of default casting. Thanks in advance ...

How do I reverse my sound volume math for my volume slider?

Hi Stackers, I'm building a video player and am kinda stuck at the volume slider part. It's a YouTube style vertical slider, meaning if the slider is in the top position volume should be 100% and if the slider is dragged to the bottom position sound should be 0. Currently it's doing the opposite of what I want :( Dragging the slider dow...

Web UI for inputting a function from the reals to the reals, such as a probability distribution.

I would like a web interface for a user to describe a one-dimensional real-valued function. I'm imagining the user being presented with a blank pair of axes and they can click anywhere to create points that are thick and draggable. Double-clicking a point, let's say, makes it disappear. The actual function should be shown in real time...

Computing the null space of a matrix as fast as possible

I need to compute the nullspace of several thousand small matrices (8x9, not 4x3 as I wrote previously) in parallel (CUDA). All references point to SVD but the algorithm in numerical recipes seems very expensive, and gives me lots of things other than the null space that I don't really need. Is Gaussian elimination really not an option...

Is there a fast way to calculate the smallest delta between two rotation values?

There are two views: viewA and viewB. Both are rotated. The coordinate system for rotation is weird: It goes from 0 to 179,999999 or -179,99999 degrees. So essentially 179,99999 and -179,99999 are very close together! I want to calculate how much degrees or radians are between these rotations. For example: viewA is rotated at 20 de...

Neural Network 0 vs -1

I have seen a few times people using -1 as opposed to 0 when working with neural networks for the input data. How is this better and does it effect any of the mathematics to implement it? Edit: Using feedforward and back prop Edit 2: I gave it a go but the network stopped learning so I assume the maths would have to change somewhere? ...

How can I convert a function of input size defined recursively into a direct function of problem input size?

Say I have an algorithm which operates on an input of size n and I know that the time it takes for n is twice the time it takes for n-1. I can observe in this simple case (assuming it takes, say, 1 second for n = 0) that the algorithm takes 2n seconds. Is there a general method for converting between recursively-defined definitions to ...

Max product of the three numbers for a given array of size N.

I need to write a program to find the Max product of three numbers for a given array of size N. Is there any effective algorithm for this? I just need to know the algorithm steps. Non of algorithms that i thought works for all the test cases. Thanks! FYI Array may contains +ve, -ve, or zero elements) ...

Calculate second point knowing the starting point and distance

Hi, using a Latitude and Longitude value (Point A), I am trying to calculate another Point B, X meters away bearing 0 radians from point A. Then display the point B Latitude and Longitude values. Example (Pseudo code): PointA_Lat = x.xxxx; PointA_Lng = x.xxxx; Distance = 3; //Meters bearing = 0; //radians new_PointB = PointA-Distance;...

3D Correspondences from fundamental matrix

In MATLAB I have calculated the Fundamental matrix (of two images) using the normalized Eight point algorithm. From that I need to triangulate the corresponding image points in 3D space. From what I understand, to do this I would need the rotation and translation of the image's cameras. The easiest way of course would be calibrate the ca...

how do you calculate co-ordinates of point based on constraints relative to other points?

Let me know if this is mathoverflow material, and I'll wend my way over there. I'm hoping someone will recognise this and point me in the right direction... I'm trying to map out related nodes. I've figured out how to calculate the minimum distances between all the points, and now I need to know how to turn those into actual co-ordinate...