text
stringlengths
0
27.6k
python
int64
0
1
DeepLearning or NLP
int64
0
1
Other
int64
0
1
Machine Learning
int64
0
1
Mathematics
int64
0
1
Trash
int64
0
1
I am trying to fit a transformation from one set of coordinates to another. x' = R + Px + Qy y' = S - Qx + Py Where P,Q,R,S are constants, P = scale*cos(rotation). Q=scale*sin(rotation) There is a well known 'by hand' formula for fitting P,Q,R,S to a set of corresponding points. But I need to have an error estimate on the fit - so I need a least squares solution. Read 'Numerical Recipes' but I'm having trouble working out how to do this for data sets with x and y in them. Can anyone point to an example/tutorial/code sample of how to do this ? Not too bothered about the language. But - just use built in feature of Matlab/Lapack/numpy/R probably not helpful ! edit: I have a large set of old(x,y) new(x,y) to fit to. The problem is overdetermined (more data points than unknowns) so simple matrix inversion isn't enough - and as I said I really need the error on the fit.
0
0
0
0
1
0
How can I invert a binary equation, such that I can find which inputs will produce a given output. Example: Inputs: i0 through i8 Outputs: o0 through o8 Operators: ^ = XOR, & = AND Binary equations: (1&i0) ^ (1&i1) ^ (0&i2) ^ (1&i3) ^ (0&i4) ^ (0&i5) ^ (0&i6) ^ (0&i7) ^ (0&i8) = o0 (0&i0) ^ (1&i1) ^ (0&i2) ^ (1&i3) ^ (1&i4) ^ (0&i5) ^ (0&i6) ^ (0&i7) ^ (0&i8) = o1 (0&i0) ^ (1&i1) ^ (1&i2) ^ (0&i3) ^ (0&i4) ^ (1&i5) ^ (0&i6) ^ (0&i7) ^ (0&i8) = o2 (1&i0) ^ (0&i1) ^ (0&i2) ^ (1&i3) ^ (0&i4) ^ (0&i5) ^ (0&i6) ^ (0&i7) ^ (0&i8) = o3 (0&i0) ^ (1&i1) ^ (0&i2) ^ (1&i3) ^ (1&i4) ^ (0&i5) ^ (0&i6) ^ (0&i7) ^ (0&i8) = o4 (0&i0) ^ (0&i1) ^ (0&i2) ^ (0&i3) ^ (0&i4) ^ (1&i5) ^ (0&i6) ^ (0&i7) ^ (0&i8) = o5 (0&i0) ^ (0&i1) ^ (0&i2) ^ (1&i3) ^ (0&i4) ^ (0&i5) ^ (1&i6) ^ (0&i7) ^ (0&i8) = o6 (0&i0) ^ (0&i1) ^ (0&i2) ^ (1&i3) ^ (1&i4) ^ (0&i5) ^ (1&i6) ^ (1&i7) ^ (0&i8) = o7 (0&i0) ^ (0&i1) ^ (0&i2) ^ (0&i3) ^ (0&i4) ^ (1&i5) ^ (0&i6) ^ (0&i7) ^ (1&i8) = o8 In matrix form: 1,1,0,1,0,0,0,0,0,1 0,1,0,1,1,0,0,0,0,1 0,1,1,0,0,1,0,0,0,1 1,0,0,1,0,0,0,0,0,1 0,1,0,1,1,0,0,0,0,1 0,0,0,0,0,1,0,0,0,1 0,0,0,1,0,0,1,0,0,1 0,0,0,1,1,0,1,1,0,1 0,0,0,0,0,1,0,0,1,1 Additional limitations: The prime diagonal is always 1 I am interested if there is a solution or not, more then the solution itself How can I, algorithmically find inputs i0 -i8 such that outputs o0 - o8 are 1? What I really want to find is if there is such a solution or not. I need an algorithm which is scalable to larger networks, at least up to 100 inputs/outputs.
0
0
0
0
1
0
Although it is not very programming related but I think SO could be of some assistance: A zeroless pandigital number of base 10 is a number with all the distinct digits 1,2,3,4,5,6,7,8,9. For example, the first zeroless pandigital number of base 10 is 123456789. Find a zeroless pandigital number of base 10 such that the numbers up to the nth digit is divisible by n i.e. the number formed by 1st, 2nd and 3rd digit is divisible by 3, the number formed by 1 to 6 digits is divisible by 6 and so on. I started with thinking as assuming the no. to be "abcdefghi" and stating that a can be any number between "1-9" b can be only the even ones, e is surely 5 and so on. But I am not able to find how to go from here. Any help/or better method will be appreciated
0
0
0
0
1
0
I'm trying to write a program that will help someone study for the GRE math. As many of you may know, fractions are a big part of the test, and calculators aren't allowed. Basically what I want to do is generate four random numbers (say, 1-50) and either +-/* them and then accept an answer in fraction format. The random number thing is easy. The problem is, how can I 1) accept a fractional answer and 2) ensure that the answer is reduced all the way? I am writing in ASP.NET (or jQuery, if that will suffice). I was pretty much wondering if there's some library or something that handles this kind of thing... Thanks!
0
0
0
0
1
0
I'm interested in calculating permutations for parameters for something like this: public class Movie() { @Selection(minimum=1,maximum=10) public Integer setLength() {} @Selection(minimum=1.1,maximum=5.5) public Double setCost() {} } So I can write something like List getPermutations(); so that I could get a list of every movie possible. I'm interested in supporting multiple data types. Can anyone point me in the correct direction to take on building the annotation and List getPermutations() method?
0
0
0
0
1
0
Considering I have a continuous joint distribution of two independent normal random variables (let's assume the independent vars are on the X and Z axis, and the dependent - the joint probability - is on the Y axis), and I have a line anywhere on the XZ plane, how would I compute the probability of a point falling on one side or the other of that line?
0
0
0
0
1
0
I have a system that requires a unique 6-digit code to represent an object, and I'm trying to think of a good algorithm for generating them. Here are the pre-reqs: I'm using a base-20 system (no caps, numbers, vowels, or l to prevent confusion and naughty words) The base-20 allows 64 million combinations I'll be inserting potentially 5-10 thousand entries at once, so in theory I'd use bulk inserts, which means using a unique key probably won't be efficient or pretty (especially if there starts being lots of collisions) It's not out of the question to fill up 10% of the combinations so there's a high potential for lots of collisions I want to make sure the codes are non-consecutive I had an idea that sounded like it would work, but I'm not good enough at math to figure out how to implement it: if I start at 0 and increment by N, then convert to base-20, it seems like there should be some value for N that lets me count each value from 0-63,999,999 before repeating any. For example, going from 0 through 9 using N=3 (so 10 mod 3): 0, 3, 6, 9, 2, 5, 8, 1, 4, 7. Is there some magic math method for figuring out values of N for some larger number that is able to count through the whole range without repeating? Ideally, the number I choose would sort of jump around the set such that it wasn't obvious that there was a pattern, but I'm not sure how possible that is. Alternatively, a hashing algorithm that guaranteed uniqueness for values 0-64 million would work, but I'm way too dumb to know if that's possible.
0
0
0
0
1
0
Was just wondering how I would go about creating a planar shadow from a 4x3 matrix, all online demos I've seen use 4x4 matrices instead.
0
0
0
0
1
0
This is a question only to those who already used the LingPipe. My question is how to load up the GENIA corpus for Part of Speech tagging. When I start parsing it I get an error saying that I got out of memory heap. Thnx.
0
1
0
0
0
0
Ok I have two functions the first of which looks like so: let dlth x = float (x.ToString().Length) which takes a float and returns the number of digits, that part works fine. The second function looks like this: let droot x = ((x ** (1./(dlth x))) % 1.) which takes a float and raises it to a power equal to 1.0/(number of digits), then takes the result and does modulus 1.0. Which should be zero for a whole number. so for droot 36. it takes (36.0 ** (1.0/2.0)) which is 6.0 then 6.0 mod 1.0 equals 0.0; Now, that works fine right up to where I try the number 81.0. (and all numbers higher than 81 that should work) which returns 1.0 for some reason, throwing off my pattern matching. Can anybody tell me why this is happening? PostScript: this is part of a Project Euler solution. If you know which problem, please DO NOT post the Project Euler solution. I just need help figuring out why the modulus is returning funny results
0
0
0
0
1
0
I have a rather mathematical problem I need to solve: The task is to cut a predefined number of tubes out of fixed length tubes with a minimum amount of waste material. So let's say I want to cut 10 1m tubes and 20 2,5m tubes out of tubes with a standardized length of 6m. I'm not sure what an algorithm for this kind of problem would look like? I was thinking to create a list of variations of the different sized tubes, fit them into the standard sized tubes and then choose the variation with the minimal waste. First I'm not sure if there are not other and better ways to attack the problem. Second I did not find a solution HOW I would create such a variations list. Any help is greatly appreciated, thanks!
0
0
0
0
1
0
I want to design a URL shortener for a particular use case and type of end-user that I have targetted. I have decided that I want the URLs to be stored internally according to an auto-incrementing integer key. However, it is also required that a key be represented to users in the url as six-digit base 26 (a-z * 6) AND it's not possible to predict what the base 26 url key is based on the incrementing integer key. In other words, the first url key should not be aaaaaa then the next time someone creates a url it shouldn't be aaaaab, etc, and no loop generating a random one and fishing into the database to see if it already exists repeatedly. The second part of the requirements (urls in base 26 difficult for an outsider to predict) is the more interesting part. Ideally I would like some kind of algorithmic 1-1 mapping of all of the numbers in the 26^6 range to another number in the same range that I can just then print in base 26, and that I can undo algorithmically and don't need to store in a separate table when I want to look up the url. How can I accomplish this?
0
0
0
0
1
0
I searched the site but did not find exactly what I was looking for... I wanted to generate a discrete random number from normal distribution. For example, if I have a range from a minimum of 4 and a maximum of 10 and an average of 7. What code or function call ( Objective C preferred ) would I need to return a number in that range. Naturally, due to normal distribution more numbers returned would center round the average of 7. As a second example, can the bell curve/distribution be skewed toward one end of the other? Lets say I need to generate a random number with a range of minimum of 4 and maximum of 10, and I want the majority of the numbers returned to center around the number 8 with a natural fall of based on a skewed bell curve. Any help is greatly appreciated.... Anthony
0
0
0
0
1
0
Why is "greater than" comparisons for number values in JavaScript not working. The example below keeps returning true even when the mini number is less than the maxi. mini and maxi are form input values. This example is using jQuery to get the values, but could easily be stripped. var mini = $('form#filterPrice input.min').val(); //eg. 500 var maxi = $('form#filterPrice input.max').val(); //eg. 1500 if( mini.valueOf() > maxi.valueOf() ) { //also used: mini > maxi alert('test'); //alerts "test" even when mini is less than maxi $('form#filterPrice input.min').val( maxi ); //should switch values if mini > maxi $('form#filterPrice input.max').val( mini ); } Replacing "mini > maxi" with "Math.max(mini, maxi) == mini" works fine. So, the following does work: var mini = $('form#filterPrice input.min').val(); //eg. 500 var maxi = $('form#filterPrice input.max').val(); //eg. 1500 if( Math.max(mini, maxi) == mini ) { alert('test'); $('form#filterPrice input.min').val( maxi ); $('form#filterPrice input.max').val( mini ); }
0
0
0
0
1
0
I need to interpret relative date string like: last Friday this Tuesday next Wednesday The "Last Friday" form is easy (take the most recent Friday that is not today) but what about "this" vs. "next"? Could "this Wednesday" be yesterday on a Thursday? Could "this" and "next" Friday be the same day in some cases and a week apart in others? p.s. Given that my target audience is American, I'm primarily interested in the US English vernacular use of the term and slightly less interested in other non-US English (for instance en-gb) usages so if you are non-US please say where you are from. My current thinking: Last X: the most recent X not including today. This X: the immediate next X not including today. Next X: the X in the next week (with the start of the week being a bit arbitrary). Try it out here (be sure to check allow relative)
0
1
0
0
0
0
I'm trying to build a scientific calculator with vb .net, except it is vista glass :-p I basically want the user to be able to enter an equation like SQRT(5 * 6) / (2 ^ 4) and then I want vb to use system.math to solve it. If I write this in my code, vb is able to do it, so how could I do this at runtime. Thanks
0
0
0
0
1
0
I'm working on a 2D game that has a huge amount of dynamic entities. For fun's sake, let's call them soldiers, and let's say there are 50000 of them (which I just randomly thought up, it might be much more or much less :)). All these soldiers are moving every frame according to rules - think boids / flocking / steering behaviour. For each soldier, to update it's movement I need the X soldiers that are closest to the one I'm processing. What would be the best spatial hierarchy to store them to facilitate calculations like this without too much overhead ? (All entities are updated/moved every frame, so it has to handle dynamic entities very well)
0
1
0
0
0
0
Upon reaching a brick wall with the .Net framework's lack of a BigInteger class (yet), I've decided I'd like to develop my own as an exercise (I realize open source alternatives exist). What hoops do I need to jump through to be able to develop this? Is there any particuliar knowledge pieces that I probably wouldn't have? edit: side question. Which data type would you use to represent the numbers inside of your new big integer class?
0
0
0
0
1
0
I am creating a bouncing object that can bounce around a 2D rectangular room. I have read through the answer of the other question about using velocityX and velocityY instead of normal direction angle. OK, it sounds easier so I implement the following mathematical methods below. However, there is one difference. I required that I input an angle and which (horizontal/vertical) wall the object is hit. +(double) getDirection:(double) x1:(double) y1: (double) x2: (double) y2{ return (atan2(y2-y1,x2-x1) * 180) / 3.14; } +(double) getLengthDir_X:(double) dis: (double) dir{ return (dis*cos(dir)); } +(double) getLengthDir_Y:(double) dis: (double) dir{ return (dis*sin(dir)); } + (float) getBouncedAngle: (float) dir: (int) HVVar{ if (dir < 0)dir+=360; else if (dir >= 360)dir-=360; NSLog(@"in dir %f", dir); float initialVX = [self getLengthDir_X:100 :dir], initialVY = [self getLengthDir_Y:100 :dir]; NSLog(@"x,y %f %f", initialVX, initialVY); if (HVVar == 0){//horizontal wall initialVX = -initialVX; }else if (HVVar == 1){//vertical wall initialVY = -initialVY; } NSLog(@"x,y %f %f", initialVX, initialVY); float newDir = [self getDirection:0 :0 :initialVX :initialVY]; NSLog(@"dir : %f ---> dir : %f", dir, newDir); return newDir; } But I get very strange results. I get wrong angles sometimes. Am I missing something? 2009-08-13 23:31:19.854 X[2936:20b] in dir -0.049634 2009-08-13 23:31:19.854 X[2936:20b] x,y 99.876846 -4.961388 2009-08-13 23:31:19.855 X[2936:20b] x,y -99.876846 -4.961388 2009-08-13 23:31:19.857 X[2936:20b] dir : -0.049634 ---> dir : -177.246017 2009-08-13 23:31:21.220 X[2936:20b] in dir -177.246017 2009-08-13 23:31:21.220 X[2936:20b] x,y 25.124613 -96.792320 2009-08-13 23:31:21.221 X[2936:20b] x,y -25.124613 -96.792320 2009-08-13 23:31:21.222 X[2936:20b] dir : -177.246017 ---> dir : -104.604294 2009-08-13 23:31:21.253 X[2936:20b] in dir -104.604294 2009-08-13 23:31:21.253 X[2936:20b] x,y -59.644127 80.265671 2009-08-13 23:31:21.255 X[2936:20b] x,y 59.644127 80.265671 2009-08-13 23:31:21.256 X[2936:20b] dir : -104.604294 ---> dir : 53.411633
0
0
0
0
1
0
Does anybody knows of a software package where you can type a formula and it verifies sintactically (it doesn't need to check semantics). Thanks.
0
0
0
0
1
0
This is the approach John Carmack uses to calculate the determinant of a 4x4 matrix. From my investigations i have determined that it starts out like the laplace expansion theorem but then goes on to calculate 3x3 determinants which doesn't seem to agree with any papers i've read. // 2x2 sub-determinants float det2_01_01 = mat[0][0] * mat[1][1] - mat[0][1] * mat[1][0]; float det2_01_02 = mat[0][0] * mat[1][2] - mat[0][2] * mat[1][0]; float det2_01_03 = mat[0][0] * mat[1][3] - mat[0][3] * mat[1][0]; float det2_01_12 = mat[0][1] * mat[1][2] - mat[0][2] * mat[1][1]; float det2_01_13 = mat[0][1] * mat[1][3] - mat[0][3] * mat[1][1]; float det2_01_23 = mat[0][2] * mat[1][3] - mat[0][3] * mat[1][2]; // 3x3 sub-determinants float det3_201_012 = mat[2][0] * det2_01_12 - mat[2][1] * det2_01_02 + mat[2][2] * det2_01_01; float det3_201_013 = mat[2][0] * det2_01_13 - mat[2][1] * det2_01_03 + mat[2][3] * det2_01_01; float det3_201_023 = mat[2][0] * det2_01_23 - mat[2][2] * det2_01_03 + mat[2][3] * det2_01_02; float det3_201_123 = mat[2][1] * det2_01_23 - mat[2][2] * det2_01_13 + mat[2][3] * det2_01_12; return ( - det3_201_123 * mat[3][0] + det3_201_023 * mat[3][1] - det3_201_013 * mat[3][2] + det3_201_012 * mat[3][3] ); Could someone explain to me how this approach works or point me to a good write up which uses the same approach? NOTE If it matters this matrix is row major.
0
0
0
0
1
0
I have a Unix timestamp that I need to get the individual year, month, day, hour, minute and second values from. I never was very good in math class so I was wondering if you guys could help me out a little :) I have to do everything myself (no time.h functions). The language is C.
0
0
0
0
1
0
Is there a method for determining the base 10 log of any number in the iPhone language? Any help with the math for this would be appreciated by a newbie budding iPhone developer. Thanks in advance. M
0
0
0
0
1
0
In HLSL there's a lot of matrix multiplication and while I understand how and where to use them I'm not sure about how they are derived or what their actual goals are. So I was wondering if there was a resource online that explains this, I'm particularly curious about what is the purpose behind multiplying a world matrix by a view matrix and a world+view matrix by a projection matrix.
0
0
0
0
1
0
I have two unsigned long longs X and Y, where X < Y, but both may be very large. I want to compute the first digit past the decimal point of X / Y. For example, if X is 11 and Y is 14, then 11 / 14 is .785…, so the result should be 7. (X * 10) / Y would work, except it produces the wrong result if X * 10 overflows. Conversion to double would work if I had reason to believe it is precise enough to compute the right result. This is in C. Thanks for any help!
0
0
0
0
1
0
Imagine I write a simple calculator application, that just calculates simple stuff like 1.5 + 30 + 9755 - 30 - 20000 + 999900.54 I remember slightly that there were some precision problems when using floating point numbers. At which point would my calculator app start to create wrong results? Most of the time, I would just calculate integers like 1 + 2 - 963422, but sometimes I may enter a floating point number. I have no big clue about where the precision problems would start to take effect. just the very last numbers of that double? like -963419.0000000000003655? Or how would that look like? And any idea how to catch those?
0
0
0
0
1
0
I decided to do a project for fun where I want to take as input the image of a playing card and return its rank and suit. I figure that I only need look at the upper-left corner, since that has all the information. It should be robust - if I have a large image of an Ace of Diamonds, I should be able to scale it anywhere from 20 to 200% and still get the right answer. First question - is there anything already written that does this? If so I'll find something else to OCR so I don't duplicate the efforts. Second - what's the best way to go about doing this? Neural network? Something hand-coded? Can anyone give any pointers? (0xCAAF9452 is not an acceptable answer).
0
1
0
0
0
0
I'm starting out my expedition into Project Euler. And as many others I've figured I need to make a prime number generator. Problem is: PHP doesn't like big numbers. If I use the standard Sieve of Eratosthenes function, and set the limit to 2 million, it will crash. It doesn't like creating arrays of that size. Understandable. So now I'm trying to optimize it. One way, I found, was to instead of creating an array with 2 million variable, I only need 1 million (only odd numbers can be prime numbers). But now it's crashing because it exceeds the maximum execution time... function getPrimes($limit) { $count = 0; for ($i = 3; $i < $limit; $i += 2) { $primes[$count++] = $i; } for ($n = 3; $n < $limit; $n += 2) { //array will be half the size of $limit for ($i = 1; $i < $limit/2; $i++) { if ($primes[$i] % $n === 0 && $primes[$i] !== $n) { $primes[$i] = 0; } } } return $primes; } The function works, but as I said, it's a bit slow...any suggestions? One thing I've found to make it a bit faster is to switch the loop around. foreach ($primes as $value) { //$limitSq is the sqrt of the limit, as that is as high as I have to go for ($n = 3; $n = $limitSq; $n += 2) { if ($value !== $n && $value % $n === 0) { $primes[$count] = 0; $n = $limitSq; //breaking the inner loop } } $count++; } And in addition setting the time and memory limit (thanks Greg), I've finally managed to get an answer. phjew.
0
0
0
0
1
0
I'm in a very performance-sensitive portion of my code (C#/WPF), and I need to perform a modulus operation between two System.TimeSpan values in the quickest way possible. This code will be running thousands of times per second, and I would very much prefer to avoid using a manual loop calculation - at all costs. The idea of a modulus between two TimeSpans may seem a little weird, so allow me to explain - Say we have TimeSpan A = 1 Minute 30 Seconds TimeSpan B = 20 Seconds Here would be a list of common operations and their reasonable results: A + B = (TimeSpan)1 Minute 50 Seconds A - B = (TimeSpan)1 Minute 10 Seconds A * B = No Reasonable Way to Compute We should be able to multiply a TimeSpan by an integer. A * 5 = (TimeSpan) 7 Minutes 30 Seconds Microsoft has not implemented multiplication between TimeSpans and integers. A / B = (int)4 or (double)4.5 This operation is not implemented directly in the .NET framework, but it makes perfect sense. There are 4.5 B's in A. (4.5 * 20 = 90) A % B = (TimeSpan) 10 Seconds Given reasonable TimeSpan division, TimeSpan modulus should be pretty straight-forward. A / B really equals (int)4 remainder (TimeSpan)10 Seconds. The quotient and remainder are different data types, which may in fact be why Microsoft hasn't implemented this directly. I need to find an efficient way to compute this without looping. Normally I wouldn't be opposed to a short loop, but these TimeSpans could differ greatly. The larger the exponential difference between the TimeSpans, the larger the quotient. The larger the quotient, the more iterations a "divide-loop" will have to execute. This is a dependency that I cannot allow in this part of my app. Does SO have any ideas?
0
0
0
0
1
0
Does boost have one? Where A, y and x is a matrix (sparse and can be very large) and vectors respectively. Either y or x can be unknown. I can't seem to find it here: http://www.boost.org/doc/libs/1_39_0/libs/numeric/ublas/doc/index.htm
0
0
0
0
1
0
I have a Probablistic Neural Network classification experiment set up in MATLAB. I can get the classes for unseen data using the sim command. Is there any way I can get the probabilities for the classes that the classifier calculates? Also, is there any direct way to plot the Reciever Operating Characterstic curve and calculate the Area Under the ROC for my classifier?
0
0
0
1
0
0
I saw this text while reading wikipedia(http://en.wikipedia.org/wiki/K-means%2B%2B) The authors tested their method with real and synthetic datasets and obtained typically 2-fold improvements in speed, and for certain datasets close to 1000-fold improvements in error. and I'm curious about the meaning of -fold, like 1000-fold, 2-fold. Is this a kind of unit? or something? Can anyone give me some references about this term?
0
0
0
1
0
0
I'm trying to solve what seems to be a simple math problem. I can write the problem as a for loop, but I'm not sure how to translate it into an equation. Can anyone help? x = 10; for(int i=0; i<3000; i++) { x = x^2 }
0
0
0
0
1
0
I am presently trying to construct an OBB (Oriented Bounding Box) using the source and math contained in the book "Real Time Collision Detection". One problem with the code contained in this book is that it does very little to explain what the parameters mean for the methods. I am trying to figure out what I need to feed my setOBB() method (I wrote this one). It goes like this: void PhysicalObject::setOBB( Ogre::Vector3 centrePoint, Ogre::Vector3 localAxes[3], Ogre::Vector3 positiveHalfwidthExtents ) { // Ogre::Vector3 c; // OBB center point // Ogre::Vector3 u[3]; // Local x-, y-, and z-axes (rotation matrix) // Ogre::Vector3 e; // Positive halfwidth extents of OBB along each axis m_obb.c = centrePoint; m_obb.u[0] = localAxes[0]; m_obb.u[1] = localAxes[1]; m_obb.u[2] = localAxes[2]; m_obb.e = positiveHalfwidthExtents; } Looking at the parameters it wants above, the first and third parameters I believe I understand. Pass in the centre position of the object. This is my problem. I believe it wants a matrix represented using an array of 3 vectors? but how? A Vector which contains magnitude for the distance between the centre point and the edge of the OBB in each x,y,z direction. Here is what I'm doing currently: // Build the OBB Ogre::Vector3 rotation[3]; Ogre::Vector3 centrePoint = sphere->getPosition(); rotation[0] = ? rotation[1] = ? rotation[2] = ? Ogre::Vector3 halfEdgeLengths = Ogre::Vector3( 1,1,1 ); myObject->setOBB( centrepoint, rotation, halfEdgeLengths ); How can i represent a matrix using three vectors (which I cannot avoid doing this way). Thanks.
0
0
0
0
1
0
I am getting OverflowException's thrown at me when I don't want them (or so I think). I am performing some odd calculations where I expect the values to overflow, discarding overflowed bits. It seems I can't get this to work properly though. Basically this is one pair of i and j which happens as I iterate over huge sets (int.MinValue to int.MaxValue). // i and j are ints // i is -2147483648 // j is -1 var x = i / j; // I also tried using unchecked keyword, but it doesn't help var x = unchecked(i / j); Update: The expected mathematic value of -2147483648 / -1 is 2147483648. However, this certain code doesn't really attempt to find the number. This is part of a series of bit manipulation things gone a bit hard to understand. To be honest, I don't even know myself what the intention was because I didn't really document the method, and all it took was one day away from it to raise serious WTF-bubbles over my head. All I know it works as intended with special code designed to handle the case. About the expected value: Since int can only hold 2147483647 at it's max, I expect to discard the overflow yielding value 0. If I've learned anything about this at all, it's probably the importance of documentation for obscure methods.
0
0
0
0
1
0
why is 24 * 60 * 60 * 1000 * 1000 divided by 24 * 60 * 60 * 1000 not equal to 1000 in Java?
0
0
0
0
1
0
I have a difficult mathematical question that is breaking my brain, my whiteboard, and all my pens. I am working with a file that expresses 2 values, a multiplicand and a percentage. Both of those values must be integers. These two values are multiplied together to produce a range. Range is a float value. My users edit the range, and I have to calculate a new percentage and multiplicand value. Confused yet? Here's an example: Multiplicand: 25000 Apples Percentage: 400 (This works out to .4% or .004) Range: 100.0 Apples (Calculated by Multiplicand * Percentage) To complicate things, the allowable values for Percentage are 0-100000. (Meaning 0-100%) Multiplicand is a value between 1 and 32bit int max (presumably unsigned). I need to allow for users to input a range, like so: Range: .04 Apples And calculate the appropriate Percentage and Multiplicand. Using the first example: OriginalMultiplicand: 25000 Apples OriginalPercentage: 400 (This works out to .4% or .004) OriginalRange: 100.0 Apples (Calculated by Multiplicand * Percentage) NewRange: .01 Apples NewPercentage: 40 NewMultiplicand: 25 Apples The example calculation is easy, all that was required was adjusting down the multiplicand and percentage down by the scale factor of the new and old range. The problem arises when the user changes the value to something like 1400.00555. Suddenly I don't have a clean way to adjust the two values. I need an algorithmic approach to getting values for M & P that produce the closest possible value to the desired range. Any suggestions?
0
0
0
0
1
0
I have got an undirected weighted connected graph. If I select one vertex I automatically select all the vertices connected directly with it. What will be the algorithm so that I am able to select all the vertices of the graph using minimum number of tries? In each try I select one vertex. For example for adjacency matrix a[][]={1,1,0,0,0, 1,1,1,1,0 ,0,1,1,0,0 0,1,0,1,1 0,0,0,1,1} I have to either select vertex 2 and 4 or vertex 2 and 5.
0
0
0
0
1
0
First of all, the title is very bad, due to my lack of a concise vocabulary. I'll try to describe what I'm doing and then ask my question again. Background Info Let's say I have 2 matrices of size n x m, where n is the number of experimental observation vectors, each of length m (the time series over which the observations were collected). One of these matrices is the original matrix, called S, the other which is a reconstructed version of S, called Y. Let's assume that Y properly reconstructs S. However due to the limitations of the reconstruction algorithm, Y can't determine the true amplitude of the vectors in S, nor is it guaranteed to provide the proper sign for those vectors (the vectors might be flipped). Also, the order of the observation vectors in Y might not match the original ordering of the corresponding vectors in S. My Question Is there an algorithm or technique to generate a new matrix which is a 'realignment' of Y to S, so that when Y and S are normalized, the algorithm can (1) find the vectors in Y that match the vectors in S and restore the original ordering of the vectors and (2) likewise match the signs of the vectors? As always, I really appreciate all help given. Thanks!
0
0
0
0
1
0
Say I'm inserting a 64 bit floating point double into a DECIMAL(17,5) field. Does the value get rounded or truncated?
0
0
0
0
1
0
How can I simplify a basic arithmetic expression? e.g. module ExprOps where simplify :: Expr -> Expr simplify (Plus(Var"x") (Const 0)) = Var "x" What do I have to do? module Expr where -- Variables are named by strings, assumed to be identifiers. type Variable = String -- Representation of expressions. data Expr = Const Integer | Var Variable | Plus Expr Expr | Minus Expr Expr | Mult Expr Expr deriving (Eq, Show) The simplifications I have in mind are: 0*e = e*0 = 0 1*e = e*1 = 0+e = e+0 = e-0 = e and simplifying constant subexpressions, e.g. Plus (Const 1) (Const 2) would become Const 3. I would not expect variables (or variables and constants) to be concatenated: Var "st" is a distinct variable from Var "s". What I want to achieve is to create a module like the one above that uses a function called simplify :: Expr->Expr
0
0
0
0
1
0
How many possible words of length 6 can I generate from the English lower case alphabet, if each word starts with a random consonant, and after that vowels and consonants alternate? What if I add digits to my alphabet? See also this question.
0
0
0
0
1
0
I am doing a Monte Carlo experiment to calculate an approximation of PI. From SICP: The Monte Carlo method consists of choosing sample experiments at random from a large set and then making deductions on the basis of the probabilities estimated from tabulating the results of those experiments. For example, we can approximate using the fact that 6/pi^2 is the probability that two integers chosen at random will have no factors in common; that is, that their greatest common divisor will be 1. To obtain the approximation to , we perform a large number of experiments. In each experiment we choose two integers at random and perform a test to see if their GCD is 1. The fraction of times that the test is passed gives us our estimate of 6/pi^2, and from this we obtain our approximation to pi. But when I run my program I obtain values like 3.9... Here is my program: (define (calculate-pi trials) (define (this-time-have-common-factors?) (define (get-rand) (+ (random 9999999999999999999999999999999) 1)) (= (gcd (get-rand) (get-rand)) 1)) (define (execute-experiment n-times acc) (if (> n-times 0) (if (this-time-have-common-factors?) (execute-experiment (- n-times 1) acc) (execute-experiment (- n-times 1) (+ acc 1))) acc)) (define n-success (execute-experiment trials 0)) (define prob (/ n-success trials)) (sqrt (/ 6 prob))) My interpreter is MIT/GNU 7.7.90 Thanks for any help.
0
0
0
0
1
0
I,m developing a debt calculation program 'my problem is when i have to calculate the months to pay back the debt it comes to 28.04 and i have to get it to 29 can some one pls help me out. Thank you in advance my code looks like this: Dim b, SubMtP As Integer Dim outsUm, si outsUm = TextBox1.Text SubMtP = Format(Val(TextBox1.Text) / Val(TextBox2.Text), "0.00") Math.Round(SubMtP + 1) TextBox5.Text = Format(Val(TextBox4.Text) / 12, "0.00") For i As Integer = 1 To SubMtP
0
0
0
0
1
0
I am trying to translate this statement into Actionscript: "Sally is 5 years old. Jenny is 4 years old. The combined age of Sally and Jenny is 9 years." This is what I have so far: function getAges (sallyAge:Number,jennyAge:Number,combinedAge:Strin g) { trace("Sally's Age:" + sallyAge); trace("Jenny's Age:" + jennyAge); trace("Combined Age:" + combinedAge); } getAges (5,4,"9"); It works - but I would like to have it so that the Actionscript is actually doing the math. Would I declare a variable like var combinedAge = sallyAge + jennyAge; ? And where would I put it? Thanks in advance for any assistance, I am really new to this.
0
0
0
0
1
0
I have a friend that needs to compute the following: In the complete graph Kn (k<=13), there are k*(k-1)/2 edges. Each edge can be directed in 2 ways, hence 2^[(k*(k-1))/2] different cases. She needs to compute P[A !-> B && C !-> D] - P[A !-> B]*P[C !-> D] X !-> Y means "there is no path from X to Y", and P[ ] is the probability. So the bruteforce algorithm is to examine every one of the 2^[(k*(k-1))/2] different graphes, and since they are complete, in each graph one only needs to consider one set of A,B,C,D because of symmetry. P[A !-> B] is then computed as "number of graphs with no path between node 1 and 2" divided by total number of graphs, i.e 2^[(k*(k-1))/2]. The bruteforce method works in mathematica up to K8, but she needs K9,K10... up to K13. We obviously don't need to find the shortest path in the cases, just want to find if there is one. Anyone have optimization suggestions? (This sound like a typical Project Euler problem). Example: The minimal graph K4 have 4 vertices, giving 6 edges. Hence there are 2^6 = 64 possible ways to assign directions to the edges, if we label the 4 vertices A,B,C and D. In some graphs, there is NOT a path from A to B, (lets say X of them) and in some others, there are no path from C to D (lets say Y). But in some graphs, there is no path from A to B, and at the same time no path from C to D. These are W. So P[A !-> B]=X/64, P[C !-> D]=Y/64 and P[A !-> B && C !-> D] = W/64. Update: A, B,C and D are 4 different vertives, hence we need at least K4. Observe that we are dealing with DIRECTED graphs, so normal representation with UT-matrices won't suffice. There is a function in mathematica that finds the distance between nodes in a directed graph, (if it returns infinity, there is no path), but this is a little bit overkill since we dont need the distance, just if there is a path or not.
0
0
0
0
1
0
I plan on having to split up the Geometry object into a series of simpler shapes, and combine their centroids using this formula: Mathematical details of this formula can be found in this Wikipedia article. NOTICE: Don't be suprised if my view of the mathematics is incorrect. I haven't done any complex math past trigonometry, and I've never had to deal with Greek letters. I think I understand this one pretty well, but please just let me know if I've got it wrong. An informational note: the centroid of a gometric shape or prism is not just the middle of the shape. It is the center of gravity, or center of mass. I assume that Geometry objects can encapsulate 3D prisms as well, so I may have to take this into account in the future, but for now I'm focusing on 2D Geometries only. For a 2D shape you have to imagine it being a stiff piece of paper with a given shape, and the centroid would be the point at which this piece of paper would balance on a needle. The first problem I'm faced with is that I need to find a way to accurately split any given Geometry object into simple-enough shapes, so this formula can work correctly. Does anyone have any ideas how this might be accomplished? Or is there a better procedure that will still work universally? The second problem I'm faced with is that after the geometry is split up, how do I go about finding the centroid of each piece? Each type of simple shape (triangle, quadrilateral, semicircle, etc) has its own centroid formula. Is there a way for me to figure which type of shape each piece is?
0
0
0
0
1
0
I need to implement sentiment analysis. Can anyone point me to examples/reference implementations?
0
1
0
0
0
0
I'm writing iPhone code that fuzzily recognizes whether a swiped line is straight-ish. I get the bearing of the two end points and compare it to 0, 90, 180 and 270 degrees with a tolerance of 10 degrees plus or minus. Right now I do it with a bunch of if blocks, which seems super clunky. How to write a function that, given the bearing 0..360, the tolerance percentage (say 20% = (-10° to +10°)) and a straight angle like 90 degrees, returns whether the bearing is within the tolerance? Update: I am, perhaps, being too specific. I think a nice, general function that determines whether a number is within a percentage of another number has utility in many areas. For instance: Is the number swipeLength within 10% of maxSwipe? That would be useful. BOOL isNumberWithinPercentOfNumber(float firstN, float percent, float secondN) { // dunno how to calculate } BOOL result; float swipeLength1 = 303; float swipeLength2 = 310; float tolerance = 10.0; // from -5% to 5% float maxSwipe = 320.0; result = isNumberWithinPercentOfNumber(swipeLength1, tolerance, maxSwipe); // result = NO result = isNumberWithinPercentOfNumber(swipeLength2, tolerance, maxSwipe); // result = YES Do you see what I'm getting at?
0
0
0
0
1
0
Duplicate Best algorithm for evaluating a mathematical expression? mathematical expression parser in Delphi? I need a program in Delphi that get one variable equation from Edit1 such as "F(x)=4*X+2*log(x)+4*power(X,2)"and get X value variable from Edit2 then show the result F(X) in Edit3. Please help me. Thanks.
0
0
0
0
1
0
I am new to Ruby on Rails and have been using Scaffolding. On one of the forms I want to be able to have two fields and then have the difference between the two submitted to the database. Instead of :pickupamount, I want (Ending Amount - Starting Amount) to be calculated and entered into the pickupamount column of my database. Thanks in advance!
0
0
0
0
1
0
Ok well heres what I would like to do in PHP: http://www.wordle.net/ I know how to do all of the GD (writing to the canvas), my issue is the logic of actually keeping track of different sized word boxes and correctly placing them on a blank canvas. If anyone knows of a good site that has some resources that could lead me in the right direction I would love you forever!
0
0
0
0
1
0
So, i recently found this term related somehow to neural networks, but I don't find anymore info on this topic, and it seems interesting. Does anybody know where I can find more info for starters on this? thanks in advance
0
1
0
0
0
0
The basic table schema looks something like this (I'm using MySQL BTW): integer unsigned vector-id integer unsigned fk-attribute-id float attribute-value primary key (vector-id,fk-attribute-id) The vector is represented as multiple records in the table with the same vector-id I need to build a separate table with the dot product (also euclidean distance) of all vectors that exist in this table. So, I need a result table that looks like this: integer unsigned fk-vector-id-a integer unsigned fk-vector-id-b float dot-product ...and one like this... integer unsigned fk-vector-id-a integer unsigned fk-vector-id-b float euclidean-distance What is the best query structure to produce my result? With very large vectors, is a relational database the best approach to solve this problem, or should I internalize the vectors in an application and do the calculation there?
0
0
0
0
1
0
I have two 2d circles in 3d space (defined by a center, normal, and radius) and I'm trying to come up with a pair of points that is one of the set of closest pairs of points. I know that there are anywhere from 1 to an infinite number of point pairs, I just need a single matching pair. Is there a simple way to do that? Precision is not essential. The radius of both circles are the same, non-zero value. In case the background is helpful, my overall algorithm takes in a NURBS curve in space and extrudes a 2d polygon along the curve, yielding a deformed cylinder. I just sample several points along the curve. The normal of each circle is the NURBS curve tangent, and I'm trying to figure out how to align adjacent samples, so I don't get weird twisting. It seems that the closest points on adjacent samples should be aligned. Thanks for all the responses here.. this part of the project got a little delayed, which is why I haven't tested all the answers yet. I'll be sure to toss up some images here and mark an answer when I get to work on this again.
0
0
0
0
1
0
I'm trying to implement application that can determine meaning of sentence, by dividing it to smaller pieces. So I need to know what words are subject, object etc. so that my program can know how to handle this sentence.
0
1
0
0
0
0
I am trying to determine the volatility of a rank. More specifically, the rank can be from 1 to 16 over X data points (the number of data points varies with a maximum of 30). I'd like to be able to measure this volatility and then map it to a percentage somehow. I'm not a math geek so please don't spit out complex formulas at me :) I just want to code this in the simplest manner possible.
0
0
0
0
1
0
Given a square (described by x, y, width, height) and an angle (in radians) I need to calculate a vector that originates at the squares centre and terminates at the point that collides with the edge of the square at the given angle. I'm really most interested in the point it collides at so if that would make calculation more efficient let me know. Can this be generalized to Rectangles? How about polygons in general?
0
0
0
0
1
0
How do I parse sentence case phrases from a passage. For example from this passage Conan Doyle said that the character of Holmes was inspired by Dr. Joseph Bell, for whom Doyle had worked as a clerk at the Edinburgh Royal Infirmary. Like Holmes, Bell was noted for drawing large conclusions from the smallest observations.[1] Michael Harrison argued in a 1971 article in Ellery Queen's Mystery Magazine that the character was inspired by Wendell Scherer, a "consulting detective" in a murder case that allegedly received a great deal of newspaper attention in England in 1882. We need to generate stuff like Conan Doyle, Holmes, Dr Joseph Bell, Wendell Scherr etc. I would prefer a Pythonic Solution if possible
0
1
0
0
0
0
We are looking to do display some mathematical data in a Flex GUI chart. We need to do plot for two array of data the following. cross-correlation of both auto-correaltion of each and correlation coefficient It looks like Flex does not support scientific formula like cross-correlation,auto-correlation and co-relation co-efficient natively. Please correct me if I am wrong or if there are reasonable alternatives at this point. While looking for alternatives I did come across the article at actionscript.org [--not allowed--] and I am presently trying to see whether I can invoke excel formulas from the actionscript. It looks like there might be some complexity involved in passing the data between flex and vbscript. Will this be the right approach? This is for a POC and as such we are looking for a quick hack only.
0
0
0
0
1
0
So I'm currently working on some FPS game programming in OpenGL (JOGL, more specifically) just for fun and I wanted to know what would be the recommended way to create an FPS-like camera? At the moment I basically have a vector for the direction the player is facing, which will be added to the current player position upon pressing the "w" or forward key. The negative of that vector is of course used for the "s" or backward key. For "a", left, and "d", right I use the normal of the direction vector. (I am aware that this would let the player fly, but that is not a problem at the moment) Upon moving the mouse, the direction vector will be rotated using trigonometry and matrices. All vectors are, of course, normalized for easy speed control. Is this the common and/or good way or is there an easier/better way?
0
0
0
0
1
0
I need topic ideas related to AI on which I will base my thesis. I am mostly interested in Genetic Algorithm and Neural Networks techniques. I already got the some ideas, but non of them seems to hit me! Any help will be really appreciated!! :)
0
1
0
0
0
0
I was wondering, which are the most commonly used algorithms applied to finding patterns in puzzle games conformed by grids of cells. I know that depends of many factors, like the kind of patterns You want to detect, or the rules of the game...but I wanted to know which are the most commonly used algorithms in that kind of problems... For example, games like columns, bejeweled, even tetris. I also want to know if detecting patterns by "brute force" ( like , scanning all the grid trying to find three adyacent cells of the same color ) is significantly worst that using particular algorithms in very small grids, like 4 X 4 for example ( and again, I know that depends of the kind of game and rules ...) Which structures are commonly used in this kind of games ?
0
1
0
0
0
0
Given two planes positioned and rotated arbitrary to each other, I'm trying to determine which vertices should be connected. The image below (planes in black, connecting edges in red) illustrates two examples on how the planes might look: Comparing the distances between vertices won't work as the planes are not (necessarily) positioned directly above each other, and comparing the xyz components won't work either since they are not (necessarily) parallel and therefore might be twisted. I can't really think of any other solutions so I'm wondering if I need to go back and approach the problem in another way?
0
0
0
0
1
0
For the fun of it, I would like to see someone use and abuse LINQ to solve this money problem. I really have no idea how you would do it - I suppose Populating some set and then selecting off of it. If given a total number of coins and give the total amount of all coins added together: Show every possible combination of coins. Coins are Quarters(.25), Dimes(.10) Nickels(.05) and Pennies(.01) Include the option so that there can be zero of a type of coin or there must be at least 1 of each. Sample Problem: If I have 19 coins and the coins add up to $1.56 and there must be at least 1 of every type of coin. The answer would be: 1 Quarters, 9 Dimes, 8 Nickels, 1 Pennies 2 Quarters, 5 Dimes, 11 Nickels, 1 Pennies 2 Quarters, 9 Dimes, 2 Nickels, 6 Pennies 3 Quarters, 1 Dimes, 14 Nickels, 1 Pennies 3 Quarters, 5 Dimes, 5 Nickels, 6 Pennies 4 Quarters, 1 Dimes, 8 Nickels, 6 Pennies 5 Quarters, 1 Dimes, 2 Nickels, 11 Pennies And if we allowed zero for a coint we allowed get an additional 0 Quarters, 13 Dimes, 5 Nickels, 1 Pennies Here is some sample C# code using a brute force method to solve the problem. Don't bother improving the sample, let's just see a solution using Linq. //Try not to use any regualar c# looping code if possible. private void SolveCoinProblem(int totalNumberOfCoins, double totalAmount, int minimumNumberOfEachCoin) { int foundCount = 0; long numberOfTries = 0; Console.WriteLine(String.Format("Solving Coin Problem:TotalNumberOfCoins={0}TotalAmount={1}MinimumNumberOfEachCoin{2}", totalNumberOfCoins, totalAmount, minimumNumberOfEachCoin)); for (int totalQuarters = minimumNumberOfEachCoin; totalQuarters < totalNumberOfCoins; totalQuarters++) { for (int totalDimes = minimumNumberOfEachCoin; totalDimes < totalNumberOfCoins; totalDimes++) { for (int totalNickels = minimumNumberOfEachCoin; totalNickels < totalNumberOfCoins; totalNickels++) { for (int totalPennies = minimumNumberOfEachCoin; totalPennies < totalNumberOfCoins; totalPennies++) { numberOfTries++; if (totalQuarters + totalDimes + totalNickels + totalPennies == totalNumberOfCoins) { if (Math.Round((totalQuarters * .25) + (totalDimes * .10) + (totalNickels * .05) + (totalPennies * .01),2) == totalAmount) { Console.WriteLine(String.Format("{0} Quarters, {1} Dimes, {2} Nickels, {3} Pennies", totalQuarters, totalDimes, totalNickels, totalPennies)); foundCount++; } } } } } } Console.WriteLine(String.Format("{0} Combinations Found. We tried {1} combinations.", foundCount, numberOfTries)); }
0
0
0
0
1
0
I know that if I have the following group of numbers { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 } I can have 5040 different 4-digit numbers, using 10! / (10 - 4)! But if I repeat one number on the initial group, like { 1, 1, 2, 3, 4, 5, 6, 7, 8, 9 } How many different 4-digit numbers can we build ? I know the answer is 3360, just don't know how to implement it. Important: In this case, numbers like "1123" or "1213" should be valid combinations, but not "1113", as there are only two ones on the initial group. Also, for the group { 1, 1, 2, 2, 3, 4, 5, 6, 7, 8 } There should be 2190 4-digit numbers. Any ideas on how to calculate these answers ? This is not homework, I'll get this numbers from a specific hardware and depending on the number of combinations, will return some data.
0
0
0
0
1
0
On the Wikipedia page about summation it says that the equivalent operation in Haskell is to use foldl. My question is: Is there any reason why it says to use this instead of sum? Is one more 'purist' than the other, or is there no real difference?
0
0
0
0
1
0
My ASP.NET page has following query string parameter: …?IDs=1000000012,1000000021,1000000013,1000000022&... Here IDs parameter will always have numbers separated by something, in this case ,. Currently there are 4 numbers but normally they would be in between 3 and 7. Now, I am looking for method to convert each big number from above into smallest possible value; specifically compressing value of IDs query string parameter. Both, compressing each number algorithm or compressing whole value of IDs query string parameter are welcome. Encode or decode is not an issue; just compressing the value IDs query string parameter. Creating some unique small value for IDs and then retrieving its value from some data source is out of scope. Is there an algorithm to compress such big numbers to small values or to compress value of the IDs query string parameter all together?
0
0
0
0
1
0
i'm trying to find an efficient way to find a subportion of a large grid. Currently I'm looping through rows to define a FROM-TO selection of ids in that row, but this doesn't feel right... Let's say I have a grid of 200x200 fields (x between 1 and 200, y between 1 and 200). Every field also has it's unique ID, starting at X1,Y1 (fieldid = 1) to X200,Y200 (fieldid = 40000). I have a subportion of the grid that I need to select from the database (based on XY-ranges or unique id's, where uniqueids are much faster so preferred). The subportion is defined by the upperleft field (again based on XY value or a unique id) and then 16 fields wide and 9 fields high. So, how can I efficiently select a subgrid of 144 fields (16x9) of a large grid of 40000 fields (200x200) based on the unique-id or XY-value of the upperleft field in the 16x9 subgrid?
0
0
0
0
1
0
I have two questions 1- what is the "11pt average precision metric"? 2- and how to use it in information retrieval? Thanks
0
1
0
1
0
0
I need to parse & process a big set of semi-structured text (basically, legal documents - law texts, addendums to them, treaties, judge's decisions, ...). The most fundamental thing I'm trying to do is extract information on how subparts are structured - chapters, articles, subheadings, ... plus some metadata. My question is if anyone can point me to starting points for this type of text processing, because I'm sure there has been a lot of research into this but what I find is mostly on either parsing something with a strict grammar (like code) or completely free-form text (like google tries to do on webpages). I think if I get hold of the right keywords, I would have more success in google and my journal databases. Thanks.
0
1
0
0
0
0
I know I should do my homework on my own but I simply can't get my homework to work the way I want it to: from __future__ import division import turtle import math def triangle(c,a,b,beta,gamma): turtle.forward(c) turtle.right(180+beta) turtle.forward(a) turtle.right(beta) turtle.left(beta+gamma) turtle.forward(b) turtle.left(beta+gamma) def general_abc(a,b,c): alpha = math.degrees(math.acos(a/c)) print alpha beta = math.degrees(math.asin(b/c)) print beta general_abc(50,60,90) The function general_abc() is supposed to calculate the degrees of the angles when knowing all 3 sides. I am mainly searching for the math behind it. With lots of googling I just don't seem to find the right keywords to use. Please tell me the formulas I have to look into.
0
0
0
0
1
0
I have the following requirement: - I have many (say 1 million) values (names). The user will type a search string. I don't expect the user to spell the names correctly. So, I want to make kind of Google "Did you mean". This will list all the possible values from my datastore. There is a similar but not same question here. This did not answer my question. My question: - 1) I think it is not advisable to store those data in RDBMS. Because then I won't have filter on the SQL queries. And I have to do full table scan. So, in this situation how the data should be stored? 2) The second question is the same as this. But, just for the completeness of my question: how do I search through the large data set? Suppose, there is a name Franky in the dataset. If a user types as Phranky, how do I match the Franky? Do I have to loop through all the names? I came across Levenshtein Distance, which will be a good technique to find the possible strings. But again, my question is do I have to operate on all 1 million values from my data store? 3) I know, Google does it by watching users behavior. But I want to do it without watching user behavior, i.e. by using, I don't know yet, say distance algorithms. Because the former method will require large volume of searches to start with! 4) As Kirk Broadhurst pointed out in an answer below, there are two possible scenarios: - Users mistyping a word (an edit distance algorithm) Users not knowing a word and guessing (a phonetic match algorithm) I am interested in both of these. They are really two separate things; e.g. Sean and Shawn sound the same but have an edit distance of 3 - too high to be considered a typo.
0
1
0
0
0
0
The problem here is I have a display window of size x by y, and I need to display an image inside the window without any scrolling, and to maintain the aspect ratio of 4:3. I have the following snippet of code: // Lock the current height, calculate new width of the canvas and scale the viewport. // get width of the movie canvas qreal width = canvas_->width(); // Find the height of the video qreal height = (width/4.0) * 3; // find original width and height for video to calculate scaling factor qreal videoWidth = movieData_->GetWidth(); qreal videoHeight = movieData_->GetHeight(); // calculate scaling factor qreal scaleFactorWidth = width/videoWidth; qreal scaleFactorHeight = height/videoHeight; Of course, by using either the height, or the width as the 'anchor', one way or other the new image will cause scrolling (assuming the original image is larger than the window in the first place). How do I find a dimension of aspect ratio 4:3 which fits within a predetermined size? Edit I would need to pass in a scale factor for both x and y to do the scaling canvas_->scale(scaleFactorWidth, scaleFactorHeight);
0
0
0
0
1
0
I'm trying to train an ANN (I use this library: http://leenissen.dk/fann/ ) and the results are somewhat puzzling - basically if I run the trained network on the same data used for training, the output is not what specified in the training set, but some random number. For example, the first entry in the training file is something like 88.757004 88.757004 104.487999 138.156006 100.556000 86.309998 86.788002 1 with the first line being the input values and the second line is the desired output neuron's value. But when I feed the exact same data to the trained network, I get different results on each train attempt, and they are quite different from 1, e.g.: Max epochs 500000. Desired error: 0.0010000000. Epochs 1. Current error: 0.0686412785. Bit fail 24. Epochs 842. Current error: 0.0008697828. Bit fail 0. my test result -4052122560819626000.000000 and then on another attempt: Max epochs 500000. Desired error: 0.0010000000. Epochs 1. Current error: 0.0610717005. Bit fail 24. Epochs 472. Current error: 0.0009952184. Bit fail 0. my test result -0.001642 I realize that the training set size may be inadequate (I only have about a 100 input/output pairs so far), but shouldn't at least the training data trigger the right output value? The same code works fine for the "getting started" XOR function described at the FANN's website (I've already used up my 1 link limit)
0
1
0
0
0
0
TL;dr: "I am not sure how to calculate a smooth transition of thrust between one vector and another." I am programming a simple game where an enemy chases after the player in an open space (no walls). I was calculating the enemy's x & y velocities independently, accelerating them if they were taking them in the direction of the player and quickly slowing them if they were going the wrong way (e.g. EnemyVelocity.x > 0 & player.x < enemy.x, then EnemyVelocity.x - 2.) While the gameplay is decently fun trying to dodge the enemy, it is my desire to have the enemy behave using proper physics. What I am currently doing is have the enemy set their thrust (think a spaceship) based on the angle between them and the player, and have their thrust accelerate up to a max speed (calculating side c of the EnemyVelocity triangle). Once that happens, I'm not sure the best way to have the thrust adjust itself. If I leave no max speed, the enemy accelerates nicely but will easily overshoot the player, and then take a long time to get enough momentum heading back in the player's direction. What I'd like to happen is have the enemy constantly adjust their velocity on the way to the player, targeting wherever they are at (I don't want them to predict where you will be). Then, when they miss the player, I'd like for the same thrust & acceleration formulas to readjust their velocity and send them back at the player. I'm thinking this will involve two vectors: one where the enemy is currently traveling, and one where the enemy wants to travel (the vector that will take them straight to the player). I am not sure how to calculate a smooth transition of thrust between one vector and another. Any tips, formulas or questions will be much appreciated! Thank you Stack Overflow.
0
0
0
0
1
0
Would it be an polynomial time algorithm to a specific NP-complete problem, or just abstract reasonings that demonstrate solutions to NP-complete problems exist? It seems that the a specific algoithm is much more helpful. With it, all we'll have to do to polynomially solve an NP problem is to convert it into the specific NP-complete problem for which the proof has a solution, and we are done.
0
0
0
0
1
0
This following is a snippet of Python code I found that solves a mathematical problem. What exactly is it doing? I wasn't too sure what to Google for. x, y = x + 3 * y, 4 * x + 1 * y Is this a special Python syntax?
0
0
0
0
1
0
I have a coordinate from Core Location and want to calculate the co-ordinate given a bearing and a distance, say in km. I think this is the formula from here. http://www.movable-type.co.uk/scripts/latlong.html Formula: lat2 = asin(sin(lat1)*cos(d/R) + cos(lat1)*sin(d/R)*cos(θ)) lon2 = lon1 + atan2(sin(θ)*sin(d/R)*cos(lat1), cos(d/R)−sin(lat1)*sin(lat2)) d/R is the angular distance (in radians), where d is the distance travelled and R is the earth’s radius I have the following code. CLLocationCoordinate2D linecoordstart; linecoordstart = [[existingpoints objectAtIndex:i] coordinate]; NSString *bearing = [[existingpoints objectAtIndex:i] heading]; NSString *distance = [[existingpoints objectAtIndex:i] distance]; CLLocationCoordinate2D sourceCoordinate; sourceCoordinate = [[existingpoints objectAtIndex:i] coordinate]; NSLog(@"%f,%f",sourceCoordinate.latitude,sourceCoordinate.longitude); float lat2; int d = 5; int R = 6371; lat2 = asin(sin(sourceCoordinate.latitude)cos(d/R) + cos(sourceCoordinate.latitude)sin(d/R)cos(180)); NSLog(@"%f",lat2); I want to be able to pass it a bearing which is currently an NSString and the distance. I cannot work out how to use the Math.h functions for the life of me!
0
0
0
0
1
0
I have a application which needs to raise a number to a fractional power. The target platform is an FPGA and I can get estimates on an FPU size for it, but I need an algorithm for raising a number to a fractional power just for a feasibility study. I'm assuming floating point as a worst case, I expect in practice we will be able to use short cuts, but for now I want to show that worst case can be implemented on our part. Thought I'd ask here and see if there were any common methods that I could checkout. I know there are software methods of doing this, I want just a reasonably efficient algorithm to start with. I'll worry about the FPGA implementation.
0
0
0
0
1
0
I would like to test if a point is within a particular distance of a sphere. So you have these variables... Point3F spherePnt; F32 sphereRadius; Point3F testPnt; I could do... F32 dist = ( spherePnt - testPnt ).len() - sphereRadius; If dist is positive it is outside the radius, if dist is negative it is inside the radius. Or as an optimization to avoid the square-root inside the len() function you might try this... F32 dist = ( spherePnt - testPnt ).lenSquared() - ( sphereRadius * sphereRadius ); Ok this looks like it makes since at first glance, but apparently its actually giving me incorrect results. For example, given variables are setup like this... SpherePnt( 0, 0, 0 ) SphereRadius( 1 ) testPnt( 1, 1, 1 ) Take the result of... F32 dist = ( spherePnt - testPnt ).len() - sphereRadius; F32 dist2 = mSqrt( ( spherePnt - testPnt ).lenSquared() - ( sphereRadius * sphereRadius ) ); dist = 0.7320508075688772935274463415059; dist2 = 0.4142135623730950488016887242097; It is pretty obvious that this is in fact, wrong, mathematically. It reduces to expecting the square root of 2 to be the same as the square root of 3... so the question is, I guess... Given that I DO want to perform this test, "is point p within range r of a sphere", is there a way to do this while avoiding the square root?
0
0
0
0
1
0
Given some (English) word that we shall assume is a plural, is it possible to derive the singular form? I'd like to avoid lookup/dictionary tables if possible. Some examples: Examples -> Example a simple 's' suffix Glitch -> Glitches 'es' suffix, as opposed to above Countries -> Country 'ies' suffix. Sheep -> Sheep no change: possible fallback for indeterminate values Or, this seems to be a fairly exhaustive list. Suggestions of libraries in language x are fine, as long as they are open-source (ie, so that someone can examine them to determine how to do it in language y)
0
1
0
0
0
0
Okay, so this is a straight math question and I read up on meta that those need to be written to sound like programming questions. I'll do my best... So I have graph made in flot that shows the network usage (in bytes/sec) for the user. The data is 4 minutes apart when there is activity, and otherwise set at the start of the usage range (let's say day 1) and the end of the range (day 7). The data is coming from a CGI script I have no control over, so I'm fairly limited in what I can provide the user. I never took trig or calculus, so I'm pretty much in over my head. What I want is for the user to have the option to click any point on the graph and see their bandwidth usage for that moment. Since the lines between real data points are drawn straight, this can be done by getting the points before and after where the user has clicked and finding the y-interval. It took me weeks to finally get a helpful math person to explain this to me. Everyone else has insisted on trying to teach me Riemann sum techniques and all sorts of other heavy stuff that not only is confusing to me, doesn't seem necessary for the problem. But I also want the user to be able to highlight the graph from two arbitrary points on the y-axis (time) to get the amount of network usage total during that range. I know this would be inaccurate, but I need it to be the right inaccurate using a solid equation. I thought this was the area under the line, but experiments with much simpler graphs makes this seem just far too high. I figured out I could take the distance from y2 - y1 and multiply it by x2 - x1 and then divide by two to get the area of the graph below the line like a triangle, but again, the numbers seemed to high. (maybe they are just big numbers and I don't get this math stuff at all). So what I need, if anyone would be really awesome enough to provide it before this question is closed down for being too pure-math, is either the name of the concept I should be researching or the equation itself. Or the bad news that I do need advanced math to get an accurate result. I am not bad at math, just as a last note, I just am not familiar with math beyond 10th grade and so I need some place to start. All the math sites seem to keep it too simple or way over my paygrade.
0
0
0
0
1
0
When I try to get the sum of a column from a table I get the error Arithmetic overflow error converting expression to data type int because the resulting number is to big for an INT. So I tried to CAST to a BIGINT using the following SELECT CAST(SUM(columnname) AS BIGINT) FROM tablename This gives me the same error. Any ideas what i'm doing wrong?
0
0
0
0
1
0
I have some code where, if a user has referred X number of people, he will get X number of credits. For example, referring 2 people = 1 credit. 4 people = 2 credits, and so on. However where this gets tricky is, the numbers can be changed so he gets 1 credit per person, or 1 credit per 3 people, 1 credit for 5 people, etc. If he gets 1 credits for 3 people, and he has referred 5 people, then I would like him to receive 1 credit, and have it stored that he still has 2 people for whom he didn't get any credits. So the next time he refers someone, it is 2 + 1 = 3, and he gets a credit. My question is, Given X = Number of people he needs to refer for 1 credit, and Y = Number of people a user has refered, (So X might be 3, as in 3 people per credit, and Y might be 6, in which case he should get 2 credits) 1) What's a straightforward formula or function which will X and Y, and return the number of credits which should be given to that person, and 2) Which will also give a remainder for the credits which can't be awarded yet. E.g if X is 3 and Y is 5, the credits would be 1, and remainder would be 2, so with the next referer Y will become 3 again and the user would get 1 credit?
0
0
0
0
1
0
I'm having an issue with a query I wrote where for some reason the variable that I'm using to store a decimal value in returns 6 values after the decimal place (they're mostly 0). I have tried the following (and different combinations using Math.Round) with no luck. Sales = (from invhed in INVHEAD ... // Joins here orderby cust.State ascending select new Sale { InvoiceLine = inv.InvoiceLine, InvoiceNum = inv.InvoiceNum, ... NetPrice = Math.Round((inv.ExtPrice - inv.Discount) * (Decimal) (qsales.RepSplit / 100.0), 2, MidpointRounding.ToEven), }).ToList<Sale>(); The NetPrice member has values like 300.000000, 5000.500000, 3245.250000, etc. Any clues? I can't seem to find anything on this issue online. EDIT: Decimal.Round did the trick (I forgot to mention that the NetPrice member was a Decimal type). See my answer below.
0
0
0
0
1
0
I know this isn't strictly a programming question, but it is a computer science question so I'm hoping someone can help me. I've been working on my Algorithms homework and figuring out the Big-Oh, Big-Omega, Theta, etc, of several algorithms. I'm proving them by finding their C and N0 values and all is going well. However, I've come across my last two problems in the set and I'm struggling figuring out how to do them (and google isn't helping much). I haven't had to figure out the Big-Oh/Omega of summations before. My last two problems are: Show that Σ (i=1 to n) of i2 is O(N3) and Show that Σ (i=1 to n) of [log2i] is Ω(n log n) My question is, How do I show that? For example, in the first one, intuitively I can't see how that summation of i2 is O(N3). The second one confuses me even more. Can someone explain how to show the Big-Oh and and Big-Omega of these summations?
0
0
0
0
1
0
I'm trying to compute 100! and there doesn't seem to be a built-in factorial function. So, I've written: Protected Sub ComputeFactorial(ByVal n As ULong) Dim factorial As ULong = 1 Dim i As Integer For i = 1 To n factorial = factorial * i Next lblAnswer.Text = factorial End Sub Unfortunately, running this with the value of 100 for n rseults in Value was either too large or too small for a UInt64. So, is there a larger data type for holding numbers? Am i mistaken in my methods? Am I helpless?
0
0
0
0
1
0
I am looking at developing an AI player for a simple game I have created in C#. I will be creating a population of the bots and evolving them over generations. What I was wondering is there any frameworks out there that could be good for this sort of testing / development. Ideally I would like something that I could plug any / some type of games into and say, OK so have a population of X run it over Y generations and chart the results for me. I was having a think about how I would create something that would do this for me and allow me to reuse this later for different AI projects and all I could think of was to have some sort of core code and some interface contracts that the game and AI would use so that the server can script it. What are your thoughts, does anyone have any practical experience of this sort of thing?
0
1
0
0
0
0
Possible Duplicate: Round a double to 2 significant figures after decimal point I have a value var i = 0.69999980926513672. I need to round this value to 0.7 is there a built-in method that will do this?
0
0
0
0
1
0
I need an algorithm which calculates something similar to the Levenshtein distance. It should calculate the minimal possible number of transformations to get from one sequence to another. The allowed transformations are deletion, insertion and move: Deletion of 3: before {1, 2, 3, 4}, after {1, 2, 4} Insertion of 5: before {1, 2, 3, 4}, after {1, 2, 5, 3, 4} Move of 4: before {1, 2, 3, 4}, after {4, 1, 2, 3} So the algorithm should calculate the minimal number of such transformations given the starting and ending sequence of numbers and, ideally, give the list of the transformations needed. One important trait of the sequences is that number are never duplicated. I have an idea that I can modify the Levenshtein algorithm so it only counts the number of deletions and insertions and ignore substitutions. And the number of moves would be number of deletions plus number of insertions divided by 2. But I'm not sure if it's correct. Does anybody know such an algorithm? EDIT: I probably should have said, that this algorithm will work on a sequence of sequences. For example: { {1, 2, 3}, {4}, {5, 6, 7} } where the numbers are not duplicated. The total number of the inner elements in the sequence is not changed. Elements can migrate from one inner sequence to another inner sequence. The number of inner sequences is also constant. So it could be { {1, 2, 3, 4, 5, 6, 7}, {}, {} } { {}, {1, 2, 3, 4, 5, 6, 7}, {} } { {}, {}, {1, 2, 3, 4, 5, 6, 7} } The idea is to calculate the distance for each corresponding inner sequence and then sum them to get a distance for the outer sequence. So the elements can be deleted or inserted to the inner sequence, but they never disappear from the outer sequence. The most important aspect of this algorithm is that it should find MINIMAL number of transformations. Not just some number of transofrmations.
0
0
0
0
1
0
Does anyone know where I could get a rundown of the vector math I'd need in order to program a raytracer? I could use a refresher of linear algebra and multivar calc since it's been a few years since I've taken those classes.
0
0
0
0
1
0
If you go to the following link you'll see a really cool Javascript simulation of a cube that rotates based on your mouse position. Simulation: here. If you view the source of the cube rotating script you'll see: <script type="text/javascript"> /* I wrote this script in a few minutes just for fun. It's not made to win any competition. */ var dimension = 1, a = 0, b = 0, i = 27; while (i--) document.write('<b id="l' + i + '">+</b>'); function f() { i = 0; for (x = -dimension; x <= dimension; x += dimension) for (y = -dimension; y <= dimension; y += dimension) for (z = -dimension; z <= dimension; z += dimension) { u = x; v = y; w = z; u2 = u * Math.cos(a) - v * Math.sin(a); v2 = u * Math.sin(a) + v * Math.cos(a); w2 = w; u = u2; v = v2; w = w2; u2 = u; v2 = v * Math.cos(b) - w * Math.sin(b); w2 = v * Math.sin(b) + w * Math.cos(b); u = u2; v = v2; w = w2; var c = Math.round((w + 2) * 70); if (c < 0) c = 0; if (c > 255) c = 255; s = document.getElementById('l' + i).style; s.left = 300 + u * (w + 2) * 50; s.top = 300 + v * (w + 2) * 50; s.color = 'rgb(' + c + ', ' + c + ', 0)'; s.fontSize = (w + 2) * 16 + 'px'; /* The Digg users missed depth sort, so here it is. */ s.zIndex = Math.round((w + 2) * 10); i++; } } /* Using a timer instead of the onmousemove handler wastes CPU time but makes the animation much smoother. */ setInterval('f()', 17); </script> I've looked over it several times, and I still don't understand how the points for the cube are calculated. Is this using "Euler Rotations"? One of the big problems I've had is the use of single letter variable names that mean nothing to me. Would anyone with the requisite math knowledge help explain how the math works behind rotating the cube in this simulation? I'd like to make similar things but when it comes to calculating the points positions, I'm a little lost.
0
0
0
0
1
0
I am trying to use GLSMultipleLinearRegression (from apache commons-math package) for multiple linear regression. It is expecting a covariance matrix as input -- I am not sure how to compute them. I have one array of dependent variables and 3 arrays of independent variables. Any idea how to compute the covariance matrix? Note: I have 200 items for each of the 3 independent variables Thanks Bharani
0
0
0
0
1
0
Is it possible to use the Google Wave Context-Aware Spell Checker via web services? If yes, can anyone please be kind enough to post a simple example?
0
1
0
0
0
0
Anyone know of a good Math Expression builder for an online WYSIWIG. Ideally the user would be able to easily create common math symbols/notations like summation, integrals, radicals, etc... online, ideally in an existing editor. I also need to be able host it (and ideally integrate it) in a .NET stack (IIS/Windows). Thanks in advance!
0
0
0
0
1
0
I'm trying to understand a paper on lossless compression of floating point numbers and get stuck on one particular step where the authors map a signed integer from a certain range into a range of half the size, losing information that I would think is required. I have a feeling that the authors are using some standard technique which is so obvious to their audience that they don't bother to explain, but which is completely opaque to me. The value that's being "folded" is the difference between two 23-bit positive integers (the mantissas of a predicted and an actual floating point value) which lies between 1 - 223 and 223 - 1. The authors move the numbers with the highest values (negative and positive) "inwards", so the resulting range is half the size and each number (except 0) maps to two possible values from the original range. This makes me wonder how the process should ever be reversed to determine the original value. In the authors` own words: We compute the signed corrector that is the shortest modulo 223 and the number k that specifies the tightest interval (1-2k , 2k) into which this corrector falls. Next, this number k, which ranges between 0 to 22 is compressed [...]. Finally the k + 1 significant bits of the corrector are compressed. The pseudocode for this is given as: void comp mantissa(int expo, int a, int p) { // c will be within [1-2^23 ... 2^23 -1] int c = a - p; // wrap c into [1-2^22 ... 2^22 ] if (c <= -(1<<22)) c += 1<<23; else if (c > (1<<22)) c -= 1<<23; // find tightest [1-2^k ... 2^k ] containing c int k = 0; // loop could be replaced with faster code int c1 = (c < 0 ? -c : c); while (c1) { c1 = c1 >> 1; k++ } // adjust k for case that c is exactly 2k if (k && (c == 1<<(k-1))) k--; // .. further code omitted for brevity } Ignoring the actual compression method, the output consists of c and k. What I don't get is: How can I restore the original c from c and k when the "wrap c into" part above just maps half of the potential range onto the other half? I tried this on paper with 4 instead of 23 bits and I just don't get it.
0
0
0
0
1
0
I am seeing something odd with storing doubles in a dictionary, and am confused as to why. Here's the code: Dictionary<string, double> a = new Dictionary<string, double>(); a.Add("a", 1e-3); if (1.0 < a["a"] * 1e3) Console.WriteLine("Wrong"); if (1.0 < 1e-3 * 1e3) Console.WriteLine("Wrong"); The second if statement works as expected; 1.0 is not less than 1.0. Now, the first if statement evaluates as true. The very odd thing is that when I hover over the if, the intellisense tells me false, yet the code happily moves to the Console.WriteLine. This is for C# 3.5 in Visual Studio 2008. Is this a floating point accuracy problem? Then why does the second if statement work? I feel I am missing something very fundamental here. Any insight is appreciated. Edit2 (Re-purposing question a little bit): I can accept the math precision problem, but my question now is: why does the hover over evaluate properly? This is also true of the immediate window. I paste the code from the first if statement into the immediate window and it evaluates false. Update First of all, thanks very much for all the great answers. I am also having problems recreating this in another project on the same machine. Looking at the project settings, I see no differences. Looking at the IL between the projects, I see no differences. Looking at the disassembly, I see no apparent differences (besides memory addresses). Yet when I debug the original project, I see: The immediate window tells me the if is false, yet the code falls into the conditional. At any rate, the best answer, I think, is to prepare for floating point arithmetic in these situations. The reason I couldn't let this go has more to do with the debugger's calculations differing from the runtime. So thanks very much to Brian Gideon and stephentyrone for some very insightful comments.
0
0
0
0
1
0
I'm trying to draw a vertical scrollbar for my G15 applet, but am having difficulty positioning it properly (if you haven't done anything for the G15 LCD screen, think of it as drawing on a 160x43 pixel image). This is my current code for positioning: perc = (float)Math.Round( range / Items.Count+1 ); y = ( perc * SelectedID+1 ); The upper edge of the scrollbar is at 5px from the top, the bottom edge is at 32px. Y in this case would be the upper end of the scrollbar, and I'm using a length of 2 pixels; I did try to impliment a variable length bar, it went about as well as the code above. SelectionID is 0 based. All I need is the math to figure out the position, no need for code for drawing it. Thanks.
0
0
0
0
1
0
Consider the following code snippet: $beat = date('B'); // 1 beat = 86.4 seconds, 1000 beats = 1 day $total = 'SELECT COUNT(id) FROM ads WHERE featured = 1;'; // number of featured ads $current = 'SELECT * FROM ads WHERE featured = 1 ORDER BY id ASC LIMIT 1 OFFSET ' . ($beat % $total) . ';'; // current featured ad Basically this cycles trough all the featured ads giving each one of them a beat (86.4 seconds) window where they will be given special highlight, example: $beat $total $current 0 3 0 1 3 1 2 3 2 3 3 0 4 3 1 5 3 2 6 3 0 7 3 1 This works just fine, however I was wondering if somehow it would be possible to eliminate the need for the $total query and accomplish the same using just one query. I don't see anyway to do this without using sub-queries but still, I'd like to hear your opinion on this.
0
0
0
0
1
0