math

Please explain History Monoid in Simpler Terms.

I tried to read the History monoid but couldn't wrap my head around it. Could somebody please explain it in simpler terms? Thank you Reference: http://en.wikipedia.org/wiki/History_monoid ...

getting an odd division error with PHP number_format()

my script calculates a number X by dividing two other numbers, A by B. X=A/B when i use number_format(A,2) on A before calculating X, i get a very odd number. Actual figures: 1,045.00 / 5 = 0.2 but if i don't use number_format on A before the division, i get the correct answer. Is number_format somehow making A into a non-number? ...

Partially re-create Risk-like game based on incomplete log files

I'm trying to re-create this conquerclub (Risk-like) game: http://conquerclub.barrycarter.info/ONEOFF/7460216.html In other words, I want to know who owned each territory at each point in time, and how many troops they had on that territory. My primary source of information is the Game Log. Notes: % It's not in the Game Log, but ...

combination of combination java

I need to find combination of combination in JAVA. I have for instance 6 students in class. Out of them, I need to create combination of 4 people in group, and for each group I can choose an intimate group of 2. I have to make sure that there are no doubles (order does not matter).! and need to print the 4 people group. However, this...

Source code needed for calculating quaternions

I have gyroscope + accelerometer data at each time period T. I want to calculate the rotation of the object at each time - it can rotate on its axises. So I've read that it is convenient to represent the rotation of the system in terms of quaternions (not in Euler angles). Is there any source code that can transform from angular veloci...

approaches to speed up scientific computations on server accessible by internet users

Hi Experts, I'm interested in any conventional wisdom how to approach the following problem. Note that I'm a hardware guy, so be careful using industry knowledge/terminology/acronyms. I'm providing an online application that includes very complex math computations, such as fast-Fourier transforms, that involve nested for-loops and very...

Check for closed path in numerical heightmap

Hi all, I'm working on a game, and I have the necessity to check a closed path in a given numerical heightmap: The server and the client use this heightmap to set the right coords to move etc... Now, when an user walks on a "special" tile, it lights... My problem is: When an user, walking on these tiles creates a closed path with empty t...

Find the closest tile along a path

I have a tile based game and I need to find the closest tile within a 32px radius. So say a user is at 400, 200 and the user clicks at 500, 400. I need to create a path or line from the player to the mouse position on click and the closest tile that is underneath the path within 32px (or 2 tiles) must be chosen. The map is tiled at 16px....

Is there a free (or cheap) Matlab equivalent for statistics work?

Hi, I am looking for an easy and not expensive solution to work on a large amount of records coming from sensors and save in a MYSQL database. I would like to do statistics calculation on these records and other heavy calculation. this tool that I am looking for will be used by researchers or engineers who are expert in math and stati...

How to make sure an float value is always a multiple of 0.25?

I have a float value that must be constrained to an multiple of 0.25. Examples of valid values: 1.0, 1.25, 2.0, 2.5, 20.25, 20.5, 21.0, 21.25, ... Examples of invalid values: 0.93, 3.31, 4.249, 5.02, ... Is there an mathematic function or something convenient to achieve this? When the value is invalid, I would round it up to the neare...

How can I safely average two unsigned ints in C++?

Using integer math alone, I'd like to "safely" average two unsigned ints in C++. What I mean by "safely" is avoiding overflows (and anything else that can be thought of). For instance, averaging 200 and 5000 is easy: unsigned int a = 200; unsigned int b = 5000; unsigned int average = (a + b) / 2; // Equals: 2600 as intended But in ...

Likert Rank ordering optimization heuristic possible?

I can't find the type of problem I have and I was wondering if someone knew the type of statistics it involves. I'm not sure it's even a type that can be optimized. I'd like to optimize three variables, or more precisely the combination of 2. The first is a likert scale average the other is the frequency of that item being rated on that...

drawing lines in 3D (DirectX)?

I'm adding lines to my 3D world like we see in 3D studio max. To draw lines I'm using a cylinder mesh and simply stretching/rotating it appropriately. That's all working fine but my problem is scale. Since it's 3D geometry rendering in perspective its size changes, from a distance it's small to invisible, up close it's huge. I want to m...

Check whether a point(lat/long) is within a circle(Centre lat/long known)

Hi..I am trying to see if a given pair of (lat,long) will fall within a circular region. The centre of the circle is known (lat,long values) as well as the radius. The approcah I have used is: Calculate the distance between the centre and the given lat/long using Haversines formula. Formula: a = ( sin(delta_lat/2) )^2 + cos (vp_Curr...

Java or C equivalent of MATLAB's robustfit

MATLAB has a magnificent robustfit function that solves the problem of excluding outliers with linear regression fitting. Is there anything similar written in Java or C (or in language X that could be adopted)? ...

Arrangement of n objects (Permutation with duplicates)

Hi everybody, I am looking for a fast implementation of the "arrangement" algorithm (permutation with duplicates). Given N objects (A in quantity a, B in quantity b, ...), generate all the possible combinations. Exemple: Arrangement("AAA", "B", "CC") would return : "AAABCC" "AABACC" "AABCAC" "AABCCA" "ABAACC" "ABACAC" "ABACCA" "A...

Geometrical progression with any number row

I can have any number row which consists from 2 to 10 numbers. And from this row, I have to get geometrical progression. For example: Given number row: 125 5 625 I have to get answer 5. Row: 128 8 512 I have to get answer 4. Can you give me a hand? I don't ask for a program, just a hint, I want to understand it by myself and write a co...

Determining even/odd numbers (integers)?

I feel stupid asking such a simple question, but is there an easy way to determine whether an Integer is even or odd? ...

Exponential Formula for negative direction?

Ive got a bit stuck figuring it out for the negative direction? it must be really simple, but just cant seem to get it! x = current x position dir = direction of motion on x axis if (tween == 'linear'){ if (dir == 1) { x += (x / 5); } else if (dir == -1){ //what here?? } } ...

Finding Whether A Point is Within a Right-Angle Triangle

I've always wondered the easiest way to figure out whether or not a point lies within a triangle, or in this instance, a rectangle cut into half diagonally. Let's say I have a rectangle that is 64x64 pixels. With this rectangle, I want to return a TRUE value if a passed point is within the upper-left corner of the rectangle, and FALSE ...