math

Finding the translation between points

I have a map of the US, and I've got a lot of pixel coordinates on that map which correspond to places of interest. These are dynamically drawn on the map at runtime according to various settings and statistics. I now need to switch over to a different map of the US which is differently sized, and the top left corner of the map is in a...

More simple math help in bash!

In the same thread as this question, I am giving this another shot and ask SO to help address how I should take care of this problem. I'm writing a bash script which needs to perform the following: I have a circle in x and y with radius r. I specify resolution which is the distance between points I'm checking. I need to loop over x and...

Generating sorted random ints without the sort?

Just been looking at a code golf question about generating a sorted list of 100 random integers. What popped into my head, however, was the idea that you could generate instead a list of positive deltas, and just keep adding them to a running total, thus: deltas: 1 3 2 7 2 ints: 1 4 6 13 15 In fact, you would use floats, then norm...

Simple Automatic Classification of the (R-->R) Functions

Given data values of some real-time physical process (e.g. network traffic) it is to find a name of the function which "at best" matches with the data. I have a set of functions of type y=f(t) where y and t are real: funcs = set([cos, tan, exp, log]) and a list of data values: vals = [59874.141, 192754.791, 342413.392, 1102604.284...

Modeling distribution of performance measurements

How would you mathematically model the distribution of repeated real life performance measurements - "Real life" meaning you are not just looping over the code in question, but it is just a short snippet within a large application running in a typical user scenario? My experience shows that you usually have a peak around the average exe...

Pagerank vs SVD

Pagerank works on the nodegraph of a series of pages and the directed edges formed by their respective inward and outward links. Thus the rank of a particular page is broadly a locally-induced effect in the nodegraph. SVD, on the other hand, works on a whole matrix of values, and has no directionality - a link between site A and site B ...

Calculating shortest path between 2 points on a flat map of the Earth

How do you draw the curve representing the shortest distance between 2 points on a flat map of the Earth? Of course, the line would not be a straight line because the Earth is curved. (For example, the shortest distance between 2 airports is curved.) EDIT: THanks for all the answers guys - sorry I was slow to choose solution :/ ...

Math on batch (win)

Hello, i am developing a CMD batch kind of thing. Now, i want to do some math in it. This formula: (x+1)100:y or for guys who are not so good in math: x+1, answer times 100, answer devided by y. So in batch, x = %x%, and y = %y%. So, i know how to set the variables. Now, how can batch calculate this? (WINDOWS CMD) Do i need some...

Principal component and Factor Analysis

Hi, I have some question regarding principal component and factor analysis. For PCA, does it matter whether the eigenvalues are computed from the covariance matrix or the correlation matrix É And what about FA, are the results of the eigenvalues the same if I use the covariance or the correlation matrix É ...

Resizing Columns Algorithm

I have a set of columns of varying widths and I need an algorithm to re-size them for some value y which is greater than the sum of all their widths. I would like the algorithm to prioritize equalizing the widths. So if I have a value that's absolutely huge the columns will end up with more or less the same width. If there isn't enough ...

Java: confirm method Binary division and find remainder is correct?

I am parsing binary files and have to implement a CRC algorithm to ensure the file is not corrupted. Problem is that I can't seem to get the binary math working when using larger numbers. The example I'm trying to get working: BigInteger G = new BigInteger("11001", 2); BigInteger M = new BigInteger("1110010000", 2); BigInteger R = M.r...

In what areas of programming is a knowledge of mathematics helpful?

For example, math theory, graph logic. Everyone around tell me that math is necessary for programmer. I saw a lot of threads where people say that they used linear algebra and some other math, but no one described concrete cases when they used it. I know that there are similar threads, but I couldn't see any description of such a case....

Chain of connected points and rotation matrices

Thanks for looking at this. I apologize for this rather lengthy build-up but I thought it is needed to clarify things. I have a chain of connected atoms, say a polymer which has rigid bonds and bond angles. With rigid bonds we get the condition that the distance between two immediate neighbours [eg. 2-3,3-4,etc.] is always fixed and the...

Calculate a bezier spline to get from point to point

I have 2 points in X,Y + Rotation and I need to calculate a bezier spline (a collection of quadratic beziers) that connects these 2 points smoothly. (see pic) The point represents a unit in a game which can only rotate slowly. So to get from point A to B, it has to take a long path. The attached picture shows quite an exaggeratedly curv...

Finding the closest number in a random set

Say I got a set of 10 random numbers between 0 and 100. An operator gives me also a random number between 0 and 100. Then I got to find the number in the set that is the closest from the number the operator gave me. example set = {1,10,34,39,69,89,94,96,98,100} operator number = 45 return = 39 And how do translate this into code? (...

Estimating/forecasting download completion time

We've all poked fun at the 'X minutes remaining' dialog which seems to be too simplistic, but how can we improve it? Effectively, the input is the set of download speeds up to the current time, and we need to use this to estimate the completion time, perhaps with an indication of certainty, like '20-25 mins remaining' using some Y% con...

Faster math algorithm sacrificing accuracy

Hi, I am developing a game that calls so many math functions for physics and rendering. "Fast inverse sqrt" used in Quake3 is known to be faster than sqrt() and its background is beautiful. Do you know any other algorithm that is faster than usual one with acceptable accuracy loss? ...

How can I implement a "Look At" behavior in 3D space

I am trying to implement a "Look At" behavior for planes moving around a sphere so they always face the camera. What I figured out so far, I know the normal that the plane should have and I know that its rotation around its local Z axis should always be 0. I thought it was a pretty trivial operation to figure out the missing rotation va...

Algorithm for assigning a unique series of bits for each user?

The problem seems simple at first: just assign an id and represent that in binary. The issue arises because the user is capable of changing as many 0 bits to a 1 bit. To clarify, the hash could go from 0011 to 0111 or 1111 but never 1010. Each bit has an equal chance of being changed and is independent of other changes. What would you...

Complex pathing route

L->| A -> B ^ | |__> C -> D-> G->X--| | K |_> T | |_>Z |___________| I hope this small drawing helps convey what I'm trying to do. I have a list of 7,000 locations, each with an undefined, but small number of doors. Each door is a bridge between both locations. Referencing t...