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'm representing a shape as a set of coordinates in 3D, I'm trying to rotate the whole object around an axis (In this case the Z axis, but I'd like to rotate around all three once I get it working). I've written some code to do this using a rotation matrix: //Coord is a 3D vector of floats //pos is a coordinate //angles is a 3d vector, each component is the angle of rotation around the component axis //in radians Coord<float> Polymers::rotateByMatrix(Coord<float> pos, const Coord<float> &angles) { float xrot = angles[0]; float yrot = angles[1]; float zrot = angles[2]; //z axis rotation pos[0] = (cosf(zrot) * pos[0] - (sinf(zrot) * pos[1])); pos[1] = (sinf(zrot) * pos[0] + cosf(zrot) * pos[1]); return pos; } The image below shows the object I'm trying to rotate (looking down the Z axis) before the rotation is attempted, each small sphere indicates one of the coordinates I'm trying to rotate alt text http://www.cs.nott.ac.uk/~jqs/notsquashed.png The rotation is performed for the object by the following code: //loop over each coordinate in the object for (int k=start; k<finish; ++k) { Coord<float> pos = mp[k-start]; //move object away from origin to test rotation around origin pos += Coord<float>(5.0,5.0,5.0); pos = rotateByMatrix(pos, rots); //wrap particle position //these bits of code just wrap the coordinates around if the are //outside of the volume, and write the results to the positions //array and so shouldn't affect the rotation. for (int l=0; l<3; ++l) { //wrap to ensure torroidal space if (pos[l] < origin[l]) pos[l] += dims[l]; if (pos[l] >= (origin[l] + dims[l])) pos[l] -= dims[l]; parts->m_hPos[k * 4 + l] = pos[l]; } } The problem is that when I perform the rotation in this way, with the angles parameter set to (0.0,0.0,1.0) it works (sort of), but the object gets deformed, like so: alt text http://www.cs.nott.ac.uk/~jqs/squashed.png which is not what I want. Can anyone tell me what I'm doing wrong and how I can rotate the entire object around the axis without deforming it? Thanks nodlams
0
0
0
0
1
0
Let's say that we have two boxes of pencils (in first box just blue and in second just red pencils). So the question now is, in how many ways can we put x red and y blue pencils in the line? Example: we have 3 Red pencils, and 1 Blue. Then we have 4 different ways. Combinations: BRRR, RBRR, RRBR, RRRB. So with 10 Red and 10 Blue pencils we have 184756 different ways of putting them in line. So guys, how to write this in a recursive way? Thank you very much for your help.
0
0
0
0
1
0
Is there an easy way to display math in the Safari web browser? My main target is the iPhone safari.
0
0
0
0
1
0
I two concentric circles on the screen and I want the circle on the inside to move around while the user drags their finger around the outside of the larger circle. This means that I have two point, center of the larger circle and the point at which the user touched. How do I calculate where the center of the smaller circle should be?
0
0
0
0
1
0
I have 2 tables   1. Client   2. Operations Operations can result in: Credits or Debits ('C' or 'D' in a char field) along with date and ammount fields. I must calculate the balance for each client's account using linQ... The result should also show balance 0 for clients whom didn't make operations yet I have the following function with linQ statement, but I know it could be done in a better and quicker, shorter way, right? Which will be? public static double getBalance(ref ClasesDeDatosDataContext xDC, string SSN, int xidClient) { var cDebits = from ops in xDC.Operations where (ops.idClient == xidClient) && (ops.OperationCode == 'D') select ops.Ammount; var cCredits = from ops in xDC.Operations where (ops.idClient == xidClient) && (ops.OperationCode == 'C') select ops.Ammount; return (double)(cCredits.Sum() - cDebits.Sum()); } Thanks !!!
0
0
0
0
1
0
I have two rows of numbers ... 1) 2 2 1 0 0 1 2) 1.5 1 0 .5 1 2 Each column is compared to each other. Lower values are better. For example Column 1, row 2's value (1.5) is more accurate than row 1 (2) In normal comparison I would take to the sum of each row and compare to the other row to find the lowest sum (most accurate). In this case both would be equal. I want to create two other comparison methods When values ascend from column 1 they should be weighted more (col 2 should hold more weight than 1, 3 than 2 and so on) Also the opposite Originally I thought it would be best to divide the value by its position but that doesn't work correctly. What would be the best way to do this for a row? Thanks!
0
0
0
0
1
0
I have a system of (first order) ODEs with fairly expensive to compute derivatives. However, the derivatives can be computed considerably cheaper to within given error bounds, either because the derivatives are computed from a convergent series and bounds can be placed on the maximum contribution from dropped terms, or through use of precomputed range information stored in kd-tree/octree lookup tables. Unfortunately, I haven't been able to find any general ODE solvers which can benefit from this; they all seem to just give you coordinates and want an exact result back. (Mind you, I'm no expert on ODEs; I'm familiar with Runge-Kutta, the material in the Numerical Recipies book, LSODE and the Gnu Scientific Library's solver). ie for all the solvers I've seen, you provide a derivs callback function accepting a t and an array of x, and returning an array of dx/dt back; but ideally I'm looking for one which gives the callback t, xs, and an array of acceptable errors, and receives dx/dt_min and dx/dt_max arrays back, with the derivative range guaranteed to be within the required precision. (There are probably numerous equally useful variations possible). Any pointers to solvers which are designed with this sort of thing in mind, or alternative approaches to the problem (I can't believe I'm the first person wanting something like this) would be greatly appreciated.
0
0
0
0
1
0
While trying to evaulate polynomials using Horner's Rule I have a sample code segment like so: int Horner( int a[], int n, int x ) { int result = a[n]; for(int i=n-1; i >= 0 ; --i) result = result * x + a[i]; return result; } I understand that a is an array of coefficients and that x is the value that I would like to evaluate at. My question is what is the n for?
0
0
0
0
1
0
I am trying to parse some text and diagram it, like you would a sentence. I am new to NLTK and am trying to find something in NLTK that will help me accomplish this. So far, I have seen nltk.ne_chunk and nltk.pos_tag. I find them to be not very helpful and I am not able to find any good online documentation. I have also tried to use the LancasterStemmer, but I don't fully understand what it does or how it should be used or why it even exists. Can somebody please help me out with this? I'm really at a loss and getting quite frustrated without any guiding lights. Thanks in advance
0
1
0
0
0
0
I have two arrays (a and b) with n integer elements in the range (0,N). typo: arrays with 2^n integers where the largest integer takes the value N = 3^n I want to calculate the sum of every combination of elements in a and b (sum_ij_ = a_i_ + b_j_ for all i,j). Then take modulus N (sum_ij_ = sum_ij_ % N), and finally calculate the frequency of the different sums. In order to do this fast with numpy, without any loops, I tried to use the meshgrid and the bincount function. A,B = numpy.meshgrid(a,b) A = A + B A = A % N A = numpy.reshape(A,A.size) result = numpy.bincount(A) Now, the problem is that my input arrays are long. And meshgrid gives me MemoryError when I use inputs with 2^13 elements. I would like to calculate this for arrays with 2^15-2^20 elements. that is n in the range 15 to 20 Is there any clever tricks to do this with numpy? Any help will be highly appreciated. -- jon
0
0
0
0
1
0
I am writing a script to reverse all genders in a piece of text, so all gendered words are swapped - "man" is swapped with "woman", "she" is swapped with "he", etc. But there is an ambiguity as to whether "her" should be replaced with "him" or "his".
0
1
0
0
0
0
How can I modify the Smith-Waterman algorithm using a substitution matrix to align proteins in Perl? [citations needed]
0
0
0
0
1
0
This is a bit of a longshot. Suppose I am sampling signal at a fixed rate (say once per second). Is there mathematical Java Library I can use to calculate/extract the following metrics from the sampled data? 1) The rate of change of the signal 2) An extrapolation/prediction of what the signal value will be in X seconds/minutes time Thanks
0
0
0
0
1
0
I am looking for a fast way to calculate the line segment of two given rectangles in 3D. For instance, each 3D rectangle is defined by its four vertices. A solution in any reasonable programming language will do.
0
0
0
0
1
0
I've got a database filled up with doubles like the following one: 1.60000000000000000000000000000000000e+01 Does anybody know how to convert a number like that to a double in C++? Is there a "standard" way to do this type of things? Or do I have to roll my own function? Right now I'm doing sth like this: #include <string> #include <sstream> int main() { std::string s("1.60000000000000000000000000000000000e+01"); std::istringstream iss(s); double d; iss >> d; d += 10.303030; std::cout << d << std::endl; } Thanks!
0
0
0
0
1
0
Here is some math code that adds A to B: Sub math() A = 23 B = 2 ABSumTotal = A + B strMsg = "The answer is " & "$" & ABSumTotal & "." MsgBox strMsg End Sub But how can I calculate a square root of ABSumTotal? Is it possible in PowerPoint VBA?
0
0
0
0
1
0
Here is my perceptron implementation in ANSI C: #include <stdio.h> #include <stdlib.h> #include <math.h> float randomFloat() { srand(time(NULL)); float r = (float)rand() / (float)RAND_MAX; return r; } int calculateOutput(float weights[], float x, float y) { float sum = x * weights[0] + y * weights[1]; return (sum >= 0) ? 1 : -1; } int main(int argc, char *argv[]) { // X, Y coordinates of the training set. float x[208], y[208]; // Training set outputs. int outputs[208]; int i = 0; // iterator FILE *fp; if ((fp = fopen("test1.txt", "r")) == NULL) { printf("Cannot open file. "); } else { while (fscanf(fp, "%f %f %d", &x[i], &y[i], &outputs[i]) != EOF) { if (outputs[i] == 0) { outputs[i] = -1; } printf("%f %f %d ", x[i], y[i], outputs[i]); i++; } } system("PAUSE"); int patternCount = sizeof(x) / sizeof(int); float weights[2]; weights[0] = randomFloat(); weights[1] = randomFloat(); float learningRate = 0.1; int iteration = 0; float globalError; do { globalError = 0; int p = 0; // iterator for (p = 0; p < patternCount; p++) { // Calculate output. int output = calculateOutput(weights, x[p], y[p]); // Calculate error. float localError = outputs[p] - output; if (localError != 0) { // Update weights. for (i = 0; i < 2; i++) { float add = learningRate * localError; if (i == 0) { add *= x[p]; } else if (i == 1) { add *= y[p]; } weights[i] += add; } } // Convert error to absolute value. globalError += fabs(localError); printf("Iteration %d Error %.2f %.2f ", iteration, globalError, localError); iteration++; } system("PAUSE"); } while (globalError != 0); system("PAUSE"); return 0; } The training set I'm using: Data Set I have removed all irrelevant code. Basically what it does now it reads test1.txt file and loads values from it to three arrays: x, y, outputs. Then there is a perceptron learning algorithm which, for some reason, is not converging to 0 (globalError should converge to 0) and therefore I get an infinite do while loop. When I use a smaller training set (like 5 points), it works pretty well. Any ideas where could be the problem? I wrote this algorithm very similar to this C# Perceptron algorithm: EDIT: Here is an example with a smaller training set: #include <stdio.h> #include <stdlib.h> #include <math.h> float randomFloat() { float r = (float)rand() / (float)RAND_MAX; return r; } int calculateOutput(float weights[], float x, float y) { float sum = x * weights[0] + y * weights[1]; return (sum >= 0) ? 1 : -1; } int main(int argc, char *argv[]) { srand(time(NULL)); // X coordinates of the training set. float x[] = { -3.2, 1.1, 2.7, -1 }; // Y coordinates of the training set. float y[] = { 1.5, 3.3, 5.12, 2.1 }; // The training set outputs. int outputs[] = { 1, -1, -1, 1 }; int i = 0; // iterator FILE *fp; system("PAUSE"); int patternCount = sizeof(x) / sizeof(int); float weights[2]; weights[0] = randomFloat(); weights[1] = randomFloat(); float learningRate = 0.1; int iteration = 0; float globalError; do { globalError = 0; int p = 0; // iterator for (p = 0; p < patternCount; p++) { // Calculate output. int output = calculateOutput(weights, x[p], y[p]); // Calculate error. float localError = outputs[p] - output; if (localError != 0) { // Update weights. for (i = 0; i < 2; i++) { float add = learningRate * localError; if (i == 0) { add *= x[p]; } else if (i == 1) { add *= y[p]; } weights[i] += add; } } // Convert error to absolute value. globalError += fabs(localError); printf("Iteration %d Error %.2f ", iteration, globalError); } iteration++; } while (globalError != 0); // Display network generalisation. printf("X Y Output "); float j, k; for (j = -1; j <= 1; j += .5) { for (j = -1; j <= 1; j += .5) { // Calculate output. int output = calculateOutput(weights, j, k); printf("%.2f %.2f %s ", j, k, (output == 1) ? "Blue" : "Red"); } } // Display modified weights. printf("Modified weights: %.2f %.2f ", weights[0], weights[1]); system("PAUSE"); return 0; }
0
0
0
1
0
0
Wikipedia says on A* complexity the following (link here): More problematic than its time complexity is A*’s memory usage. In the worst case, it must also remember an exponential number of nodes. I fail to see this is correct because: Say we explore node A, with successors B, C, and D. Then we add B, C, and D to the list of open nodes, each accompanied by a reference to A, and we move A from the open nodes to the closed nodes. If at some time we find another path to B (say, via Q), that is better than the path through A, then all that is needed is to change B's reference to A to point to Q and update its actual cost, g (and logically f). Therefore, if we store in a node its name, its referring node name, and its g, h, and f scores, then the maximum amount of nodes stored is the actual amount of nodes in the graph, isn't it? I really cannot see why at any time the algorithm would need to store an amount of nodes in memory that is exponential to the length of the optimal (shortest) path. Could someone please explain? edit As I understand now reading your answers, I was reasoning from the wrong viewpoint of the problem. I took for granted a given graph, whereas the exponential complexity refers to a an conceptual graph that is defined solely by a "branching factor".
0
1
0
0
0
0
I am using an NLP library (Stanford NER) that throws java.lang.OutOfMemoryError errors for rare input documents. I plan to eventually isolate these documents and figure out what about them causes the errors, but this is hard to do (I'm running in Hadoop, so I just know the error occurs 17% through split 379/500 or something like that). As an interim solution, I'd like to be able to apply a CPU and memory limit to this particular call. I'm not sure what the best way to do this would be. My first thought is to create a fixed thread pool of one thread and use the timed get() on Future. This would at least give me a wall clock limit which would likely help somewhat. My question is whether there is any way to do better than this with a reasonable amount of effort.
0
1
0
0
0
0
I'd like to find good way to find some (let it be two) sentences in some text. What will be better - use regexp or split-method? Your ideas? As requested by Jeremy Stein - there are some examples Examples: Input: The first thing to do is to create the Comment model. We’ll create this in the normal way, but with one small difference. If we were just creating comments for an Article we’d have an integer field called article_id in the model to store the foreign key, but in this case we’re going to need something more abstract. First two sentences: The first thing to do is to create the Comment model. We’ll create this in the normal way, but with one small difference. Input: Mr. T is one mean dude. I'd hate to get in a fight with him. First two sentences: Mr. T is one mean dude. I'd hate to get in a fight with him. Input: The D.C. Sniper was executed was executed by lethal injection at a Virginia prison. Death was pronounced at 9:11 p.m. ET. First two sentences: The D.C. Sniper was executed was executed by lethal injection at a Virginia prison. Death was pronounced at 9:11 p.m. ET. Input: In her concluding remarks, the opposing attorney said that "...in this and so many other instances, two wrongs won’t make a right." The jury seemed to agree. First two sentences: In her concluding remarks, the opposing attorney said that "...in this and so many other instances, two wrongs won’t make a right." The jury seemed to agree. Guys, as you can see - it's not so easy to determine two sentences from text. :(
0
1
0
0
0
0
I found by chance that int a = (h/2)*w+ ( (h+1)/2-h/2 ) * (w+1)/2 ; is equal to int b = (w * h + 1) / 2 ; when w and h are positive integers (assume no overflow). Can you show me why these 2 are the same? edit : integer -> positive integer.
0
0
0
0
1
0
I am new to dealing with 3D, and even simple stuff makes my head spin around. Sorry for the newbie question. Lets say I have 2 vectors: a(2,5,1) b(1,-1,3) These vectors "generate" a plane. How can I get a third vector perpendicular to both a and b? I can do this in 2D using a vector c(A,B) and turning it into c'(-B,A). Thanks for the help.
0
0
0
0
1
0
I have recently been reading about the general use of prime factors within cryptography. Everywhere i read, it states that there is no 'PUBLISHED' algorithm which operates in polynomial time (as opposed to exponential time), to find the prime factors of a key. If an algorithm was discovered or published which did operate in polynomial time, then how would this impact in the real world computing environment as opposed to the world of theory and computer science. Considering the extent we depend on cryptography would the would suddenly come to halt. With this in mind if P = NP is true, what might happen, how much do we depend on the fact that it is yet uproved. I'm a beginner so please forgive any mistakes in my question, but i think you'll get my general gist.
0
0
0
0
1
0
I am IT student and I have to make a project in VB6, I was thinking to make a 3D Software Renderer but I don't really know where to start, I found a few tutorials but I want something that goes in depth with the maths and algorithms, I will like something that shows how to make 3D transformations, Camera, lights, shading ... It does not matter the programing language used, I just need some resources that shows me exactly how to make this. So I just want to know where to find some resources, or you can show me some source code and tell me where to start from. Or if any of you have a better idea for a VB6 project. Thanks.
0
0
0
0
1
0
I have an Image with the Value X width and Y height. Now I want to set the height ever to 60px. With which calculation I can calculate the height that the image is correct resized?
0
0
0
0
1
0
In an experimental project I am playing with I want to be able to look at textual data and detect whether it contains data in a tabular format. Of course there are a lot of cases that could look like tabular data, so I was wondering what sort of algorithm I'd need to research to look for common features. My first thought was to write a long switch/case statement that checked for data seperated by tabs, and then another case for data separated by pipe symbols and then yet another case for data separated in another way etc etc. Now of course I realize that I would have to come up with a list of different things to detect - but I wondered if there was a more intelligent way of detecting these features than doing a relatively slow search for each type. I realize this question isn't especially eloquently put so I hope it makes some sense! Any ideas? (no idea how to tag this either - so help there is welcomed!)
0
0
0
1
0
0
Does MySQL (5.0.45) like to do strange internal typecasts with unsigned maths? I am storing integers unsigned but when selecting basic arithmetic I get outrageous numbers: mysql> create table tt ( a integer unsigned , b integer unsigned , c float ); Query OK, 0 rows affected (0.41 sec) mysql> insert into tt values (215731,216774,1.58085); Query OK, 1 row affected (0.00 sec) mysql> select a,b,c from tt; +--------+--------+---------+ | a | b | c | +--------+--------+---------+ | 215731 | 216774 | 1.58085 | +--------+--------+---------+ 1 row in set (0.02 sec) mysql> select (a-b)/c from tt; +---------------------+ | (a-b)/c | +---------------------+ | 1.1668876878652e+19 | +---------------------+ 1 row in set (0.00 sec) mysql> -- WHAT? mysql> select a-b from tt; +----------------------+ | a-b | +----------------------+ | 18446744073709550573 | +----------------------+ 1 row in set (0.02 sec) I assume this has to do with the fact that the subtraction is negative and thus it is trying to map the results into an unsigned and overflowing? I can solve this apparently by changing everything to signed, but I'd prefer to have a little more positive space with my 32-bit integers. I have not run into this before on MySQL and I'm pretty certain I've done lots with unsigned MySQL arithmetic; is this a common problem?
0
0
0
0
1
0
I want to generate a permutation of an array a and I don't want to use utility functions such as java.util.Collections(). The permutations should be randomized and every permutation should be possible to occur - but there is no need for an equally distributed probability. The following code achieves this - but at poor performance : // array holding 1,...,n // initialized somewhere else int[] a = new int[N]; for (int i = 0; i < a.length ; i++) { int r = (int) (Math.random() * (i+1)); swap(r,i,a); } private static void swap(int j, int k, int[] array){ int temp = array[k]; array[k] = array[j]; array[j] = temp; } Question: Is there any chance of reducing the total number of random numbers used for the generation of a permutation?
0
0
0
0
1
0
I have to write an algorithm in AS3.0 that plots the location of points radially. I'd like to input a radius and an angle at which the point should be placed. Obviously I remember from geometry coursework that 2(pi)r will give me an x on the point at the radius distance. The problem is I need to produce the x, y and the calculation is a bit more complicated. A small push (or answer) would be wonderful. Thanks.
0
0
0
0
1
0
I am using net = newfit(in,out,lag(j),{'tansig','tansig'}); to generate a new neural network. The default value of the number of validation checks is 6. I am training a lot of networks and this is taking a lot of time. I guess it doesn't matter if my results are a bit less accurate if they can be made considerably faster. How can I train faster? I believe one of the ways might be to reduce the value of the number of validation checks. How can I do that (in code, not using GUI) Is there some other way to increase speed. As I said, the increase in speed may be at a little loss of accuracy.
0
0
0
1
0
0
Awhile ago I read the novel Prey. Even though it is definitely in the realm of fun science fiction, it piqued my interest in swarm/flock AI. I've been seeing some examples of these demos recently on reddit such as the Nvidia plane flocking video and Chris Benjaminsen's flocking sandbox (source). I'm interested in writing some simulation demos involving swarm or flocking AI. I've taken Artificial Intelligence in college but we never approached the subject of simulating swarming/flocking behaviors and a quick flip through my textbook reveals that it isn't dicussed. Flocking Sandbox What are some solid resources for learning some of the finer points around flock/swarm algorithms? Does anyone have any experience in this field so they could point me in the right direction concerning a well suited AI book or published papers?
0
1
0
0
0
0
I'm using Electro in Lua for some 3D simulations, and I'm running in to something of a mathematical/algorithmic/physics snag. I'm trying to figure out how I would find the "spin" of a sphere of a sphere that is spinning on some axis. By "spin" I mean a vector along the axis that the sphere is spinning on with a magnitude relative to the speed at which it is spinning. The reason I need this information is to be able to slow down the spin of the sphere by applying reverse torque to the sphere until it stops spinning. The only information I have access to is the X, Y, and Z unit vectors relative to the sphere. That is, each frame, I can call three different functions, each of which returns a unit vector pointing in the direction of the sphere model's local X, Y and Z axes, respectively. I can keep track of how each of these change by essentially keeping the "previous" value of each vector and comparing it to the "new" value each frame. The question, then, is how would I use this information to determine the sphere's spin? I'm stumped. Any help would be great. Thanks!
0
0
0
0
1
0
I am trying to add a table of contents for my LaTex document. The issue I am having is that this line: \subsubsection{The expectation of \(X^2\)} Causes an error in the file that contains the table of contents \contentsline {subsubsection}{ umberline {1.2.3} The expectation of \relax $X^2\relax \GenericError { }{ LaTeX Error: Bad math environment delimiter}{ See the LaTeX manual or LaTeX Companion for explanation.} {Your command was ignored.\MessageBreak Type I <command> <return> to replace it with another command,\MessageBreak or <return> to continue without it.}}{5} Which causes the document not to be generated. Does anyone have a solution to having maths in sections while still having the table of contents
0
0
0
0
1
0
Can anyone suggest resources that take a mathematical approach to relational databases? Essentially relational algebra I'd guess. I have a mathematics background and now work a great deal with databases and would like to close the gap.
0
0
0
0
1
0
A question in my university homework is why use the one's complement instead of just the sum of bits in a TCP checksum. I can't find it in my book and Google isn't helping. Any chance someone can point me in the right direction? Thanks, Mike
0
0
0
0
1
0
I have a variable that holds an angle, in degrees, which can be both positive and negative. I now need to make sure that this number is between 0 and 360 only. The number is a double. What would a nice algorithm for doing that be? Simply doing angle % 360 does not work, because negative numbers end up still being negative. Bonus points to the smallest algorithm (aka, Code Golf). EDIT Apparently this is different in different languages. In ActionScript and JavaScript, modulo will return a number between +m and -m: (-5) % 360 = -5
0
0
0
0
1
0
I have the following available: last reported lat,lon w/timestamp target lat,lon estimated time to target heading How can I interpolate an estimated position over time? I know that's enough to calculate the required average velocity for the remainder of the trip. Given a straight-line distance, it's pretty trivial. I know it has to do with vectors but I'm a bit rusty and thought it better to consult some experts. The reason I need this update rate is limited, so to show smooth animation I need to guess at the current position between updates. The target platform is a Google Maps application so I have available some basic functionality like a Geo-correct function for distance between two coordinates. Language is unimportant as I know many and can port or adapt any examples if needed. General solutions would be preferred however. Is this simply two independent vector calculations? latestimate = latstart + (Δlat * P) lonestimate = lonstart + (Δlon * P) Where: testimated = the reported estimated time to target telapsed = time since last time estimate P = telapsed / testimated Δlat = latreported - lattarget Δlon = lonreported - lontarget
0
0
0
0
1
0
Do you know any frameworks that implement natural language rendering concept ? I've found several NLP oriented frameworks like Anthelope or Open NLP but they have only parsers but not renderers or builders. For example I want to render a question about smth. I'm constructing sentence object, setting it's properties, specify it's language and then render as a plain text. Please advice. Thanks !
0
1
0
0
0
0
I am playing with some neural network simulations. I'd like to get two neural networks sharing the input and output nodes (with other nodes being distinct and part of two different routes) to compete. Are there any examples/standard algorithms I should look at? Is this an appropriate question for this site? Right now I'm using a threshold to distinguish between two routes, but I want to activate them simultaneously and let them decide ('this simulation isn't big enough for the two of us') by using time taken to traverse each route as the factor. Update: Thanks Gacek and Amro, Gacek - I am not a machine learning student.../and this is my first experience with implementing neural networks...so what do you mean by 'quality coefficients'? Amro - sorry...I shouldn't have ujsed 'competitive learning' in the question...will try to change that and maybe add some data. What I am trying to do is set up two networks which share inputs and produce the same output (not qualitatively)...they are literally connected to the same output neuron. Maybe you could look at it as a single network with two routes or pathways, and I am trying to make the thing make a choice based on the time it takes information to travel from stimulus node to response neuron along the two routes.
0
1
0
1
0
0
I've written two simple calculations with Ruby which match the way that Microsoft Excel calculates the upper and lower quartiles for a given set of data - which is not the same as the generally accepted method (surprise). My question is - how much and how best can these methods be refactored for maximum DRYness? # Return an upper quartile value on the same basis as Microsoft Excel (Freund+Perles method) def excel_upper_quartile(array) return nil if array.empty? sorted_array = array.sort u = (0.25*(3*sorted_array.length+1)) if (u-u.truncate).is_a?(Integer) return sorted_array[(u-u.truncate)-1] else sample = sorted_array[u.truncate.abs-1] sample1 = sorted_array[(u.truncate.abs)] return sample+((sample1-sample)*(u-u.truncate)) end end # Return a lower quartile value on the same basis as Microsoft Excel (Freund+Perles method) def excel_lower_quartile(array) return nil if array.empty? sorted_array = array.sort u = (0.25*(sorted_array.length+3)) if (u-u.truncate).is_a?(Integer) return sorted_array[(u-u.truncate)-1] else sample = sorted_array[u.truncate.abs-1] sample1 = sorted_array[(u.truncate.abs)] return sample+((sample1-sample)*(u-u.truncate)) end end
0
0
0
0
1
0
PHP has many builtin trig math functions, but the inverse cotangent does not seem to be available as one of them. This is also referred to as arccot. Does anyone have the function equivalent in PHP to compute this?
0
0
0
0
1
0
I have got a variable amount of items, and a variable date range that I need to distribute them over. Lets say I have 3 items and I need to distribute them over 6 days. What I would want is to have every second day have an item, and it does not matter if the first day has an item or not. If I had 7 items over 6 days, one of the days would get 2 items, it does not matter which day that is either. Sadly, it turns out I really suck at maths, so I have no real idea on how to do this in a relatively nice and pretty way, or if it is even possible. I could probably figure it out in a hacky way, but I'm hoping to learn something from it as well :P The language used is PHP.
0
0
0
0
1
0
I'm trying to implement a geometry templating engine. One of the parts is taking a prototypical polygonal mesh and aligning an instantiation with some points in the larger object. So, the problem is this: given 3d point positions for some (perhaps all) of the verts in a polygonal mesh, find a scaled rotation that minimizes the difference between the transformed verts and the given point positions. I also have a centerpoint that can remain fixed, if that helps. The correspondence between the verts and the 3d locations is fixed. I'm thinking this could be done by solving for the coefficients of a transformation matrix, but I'm a little unsure how to build the system to solve. An example of this is a cube. The prototype would be the unit cube, centered at the origin, with vert indices: 4----5 |\ \ | 6----7 | | | 0 | 1 | \| | 2----3 An example of the vert locations to fit: v0: 1.243,2.163,-3.426 v1: 4.190,-0.408,-0.485 v2: -1.974,-1.525,-3.426 v3: 0.974,-4.096,-0.485 v5: 1.974,1.525,3.426 v7: -1.243,-2.163,3.426 So, given that prototype and those points, how do I find the single scale factor, and the rotation about x, y, and z that will minimize the distance between the verts and those positions? It would be best for the method to be generalizable to an arbitrary mesh, not just a cube.
0
0
0
0
1
0
I thought I'd write a simple script to animate my webpage a little. The basic idea was to make a div grow bigger and smaller, when I push a button. I handled the growing part well, but I can't get it to shrink again. It would seem, after long debugging, that the subtraction in JavaScript just isn't working. Basically, it seems, that this line isn't working: i = height - 4;, the value i stays the same. I'm including a complete example, could you help me fix it? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Test</title> <meta http-equiv="Content-Language" content="Estonian" /> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-15" /> </head> <body> <script type="text/javascript"> var i; var increasing = new Boolean("true"); var height; function testFunction() { height = parseInt(document.getElementById("testDiv").offsetHeight); if( increasing == true ) { i = height + 4; document.getElementById("testDiv").style.height = i + "px"; if( height >= 304 ) { increasing = false; } else { pause(30); } } else { i = height - 4; document.getElementById("testDiv").style.height = i + "px"; if( height <= 104 ) { increasing = true; } else { pause(30); } } } function pause(ms) { setTimeout("testFunction()", ms); } </script> <button id="button" type="button" onclick="testFunction();">Do it!</button. <div id="testDiv" style="border: 2px solid black; width: 400px; height: 100px; text-align: center;"> Hello! </div> </body> </html> EDIT: tags were producing HTML, had to change > to .
0
0
0
0
1
0
According to this FAQ the model format in libsvm should be straightforward. And in fact it is, when I call just svm-train. As an example, the first SV for the a1a dataset is 1 3:1 11:1 14:1 19:1 39:1 42:1 55:1 64:1 67:1 73:1 75:1 76:1 80:1 83:1 On the other hand, if I use the easy.py script, my first SV ends up being: 512 1:-1 2:-1 3:1 4:-1 5:-1 6:-1 7:-1 8:-1 9:-1 10:-1 11:1 13:-1 14:1 15:-1 16:-1 17:-1 18:-1 19:1 20:-1 21:-1 22:-1 23:-1 24:-1 25:-1 26:-1 27:-1 28:-1 29:-1 30:-1 31:-1 32:-1 33:-1 34:-1 35:-1 36:-1 37:-1 38:-1 39:1 40:-1 41:-1 42:1 43:-1 44:-1 45:-1 46:-1 47:-1 48:-1 49:-1 50:-1 51:-1 52:-1 53:-1 54:-1 55:1 56:-1 57:-1 58:-1 59:-1 61:-1 62:-1 63:-1 64:1 65:-1 66:-1 67:1 68:-1 69:-1 70:-1 71:-1 72:-1 73:1 74:-1 75:1 76:1 77:-1 78:-1 79:-1 80:1 81:-1 82:-1 83:1 84:-1 85:-1 86:-1 87:-1 88:-1 90:-1 91:-1 92:-1 93:-1 94:-1 95:-1 97:-1 98:-1 99:-1 100:-1 101:-1 102:-1 103:-1 104:-1 105:-1 106:-1 107:-1 108:-1 109:-1 110:-1 112:-1 113:-1 114:-1 115:-1 117:-1 118:-1 119:-1 which is an instance that doesn't exist at all in my training set! In fact if I do: $ grep "119:" a1a -1 1:1 6:1 18:1 22:1 36:1 42:1 49:1 66:1 67:1 73:1 74:1 76:1 80:1 119:1 -1 1:1 6:1 18:1 26:1 35:1 43:1 53:1 65:1 67:1 73:1 74:1 76:1 80:1 119:1 -1 2:1 6:1 15:1 19:1 39:1 42:1 55:1 62:1 67:1 72:1 74:1 76:1 78:1 119:1 -1 4:1 6:1 16:1 21:1 35:1 44:1 49:1 64:1 67:1 72:1 74:1 76:1 78:1 119:1 -1 2:1 6:1 14:1 30:1 35:1 42:1 49:1 65:1 67:1 72:1 74:1 76:1 78:1 119:1 -1 2:1 6:1 17:1 20:1 37:1 40:1 57:1 63:1 67:1 73:1 74:1 76:1 80:1 119:1 -1 5:1 6:1 18:1 22:1 36:1 40:1 54:1 61:1 67:1 72:1 75:1 76:1 80:1 119:1 -1 5:1 6:1 17:1 26:1 35:1 42:1 53:1 62:1 67:1 73:1 74:1 76:1 80:1 119:1 There isn't any instance with 119:-1 (and even if it's just swapping +1 with -1, there isn't any instance with 119:1 and 118:1 either - missing attributes are zeros) If I do this source code modification, I clearly see that in the former case (only svm-train involved) the first SV is also the first instance. But in the latter case (i.e. with easy.py script), the output which should give me which instance is the SV is eaten by grid.py What's going on, here?
0
0
0
1
0
0
<% @pid = item.producto_id %> <br/> Producto: <%= Producto.find_by_id(@pid) %><br/> Costo de Compra: <%= @costo_de_compra = Producto.find(:all, :conditions => "id = '#{@pid}'").*.costo_de_compra %><br/> Precio de venta: <%= @precio_de_venta = item.precio_de_venta %><br/> Utilidad de este producto: <%= @precio_de_venta - @costo_de_compra %><br/><br/> <% end %> and in my controller i have= @ventas_ocurridas_en_este_periodo = Venta.find(:all, :conditions => ['created_at >= ? and created_at <= ?', Date.today.beginning_of_month, Date.tomorrow]) As i am looping and getting values from the items that aren't available originally how can i sum all the values that come off from this loop into a concentred total? also i can't make the operation of @precio_de_venta - @costo_de_compra... something about arrays.
0
0
0
0
1
0
I've implemented this method in Javascript and I'm roughly 2.5% out and I'd like to understand why. My input data is an array of points represented as latitude, longitude and the height above the WGS84 ellipsoid. These points are taken from data collected from a wrist-mounted GPS device during a marathon race. My algorithm was to convert each point to cartesian geocentric co-ordinates and then compute the Euclidean distance (c.f Pythagoras). Cartesian geocentric is also known as Earth Centred Earth Fixed. i.e. it's an X, Y, Z co-ordinate system which rotates with the earth. My test data was the data from a marathon and so the distance should be very close to 42.26km. However, the distance comes to about 43.4km. I've tried various approaches and nothing changes the result by more than a metre. e.g. I replaced the height data with data from the NASA SRTM mission, I've set the height to zero, etc. Using Google, I found two points in the literature where lat, lon, height had been transformed and my transformation algorithm is matching. What could explain this? Am I expecting too much from Javascript's double representation? (The X, Y, Z numbers are very big but the differences between two points is very small). My alternative is to move to computing the geodesic across the WGS84 ellipsoid using Vincenty's algorithm (or similar) and then calculating the Euclidean distance with the two heights but this seems inaccurate. Thanks in advance for your help!
0
0
0
0
1
0
As an extension question my lecturer for my maths in computer science module asked us to find examples of when a surjective function is vital to the operation of a system, he said he can't think of any! I've been doing some googling and have only found a single outdated paper about non surjective rounding functions creating some flaws in some cryptographic systems.
0
0
0
0
1
0
I'm doing a research which involves "unsupervised classification". Basically I have a trainSet and I want to cluster data in X number of classes in unsupervised way. Idea is similar to what k-means does. Let's say Step1) featureSet is a [1057x10] matrice and I want to cluster them into 88 clusters. Step2) Use previously calculated classes to compute how does the testData is classified Question -Is it possible to do it with SVM or N-N ? Anything else ? -Any other recommendations ?
0
0
0
1
0
0
I'm trying to understand some flash animation, and am having difficulty working out the following. Can anyone help? I want to convert a degree range of 0 to 90, to a value between 0 and 1 These is an existing function to convert from the range 0 to 1 to degrees, eg: function convertToDegrees(Int:Pos) { var rot = (45 * pos); var degrees = (90 - ( rot * 2 )); return degrees; } Now to convert backwards, from degrees to 0 to 1 value, I am trying: (WHICH IS WRONG) function convertFromDegrees(Int:currentDegreeValue ) { var rot = (currentDegreeValue / 2) + 90; var Pos = rot / 45; return Pos; } Can anyone help me as to where I am going wrong?
0
0
0
0
1
0
So I'm just working on some simple arithmetic code. Here's what I got: echo "The number should be 2"; declare -i input added input= date +%w let added="input/2" echo "$added" when I run it the output is 4 0 I'm trying to just get 2. What the heck am I doing wrong?
0
0
0
0
1
0
Does there exist something like Canadian to US English e-dictionary which I can use in my application?
0
1
0
0
0
0
I assume a natural language processor would need to be used to parse the text itself, but what suggestions do you have for an algorithm to detect a user's mood based on text that they have written? I doubt it would be very accurate, but I'm still interested nonetheless. EDIT: I am by no means an expert on linguistics or natural language processing, so I apologize if this question is too general or stupid.
0
1
0
0
0
0
Suppose you have several functions y1 = f1(x), y2 = f2(x), etc. and you want to plot their graphs together on one plot. Imagine now that for some reason it is easier to obtain the set of x for a given y; as in, there exists an oracle which given a y, will return all the x1, x2, etc. in increasing order for which y = f1(x1), y = f2(x2), etc.. In essence, it computes the inverse functions given a y. Suppose you uniformly sample in y, so you have a list of lists of x's. If you plot this data treating all the first x in each sublist as a function of y, and all the second x's in each sublist as a different function of y, etc., you obtain a plot like below. In the above plot, the horizontal axis is y, and the vertical axis is x. Note that the navy blue "curve" is the set of smallest x as a function of y (the set of points you would see looking up from underneath the plot), while the magenta curve is the set of second smallest x, etc. Obviously, the far left navy blue and magenta curves belong to a single function and should be connected. As you move towards the right, there are ambiguities and cross-overs. In those cases, it doesn't matter how the curves of the functions are connected, as long as it "looks" reasonable (there is a proper way, but I'll settle for this for now). Now, the algorithm output should be samples of y as a function of x for each function, which when you plot it would look like: (Apologies for the poor Paint edit job :) I was thinking I proceed going one column at a time in the first pic and trying to match adjacent values based on slopes and how close they are to each other, but I'm not sure if there is a better way. Also, if this is a solved or documented problem, then I have no idea what to Google for, so any pointers would be helpful. Aside The actual application is in the computation of band structures of crystals, for anyone who is curious. The functions are the bands of the crystal, with the horizontal axis of the first plot being frequency, and the vertical axis is the k-vector. It turns out solving an eigenvalue problem for each frequency to get the eigenvalues (the k's) is easier in this case. It is fairly common to need to "prettify" and connect the resulting band structure plots, and I was wondering if there is an algorithmic way of doing it instead of having to do it by hand.
0
0
0
0
1
0
So I want to be able to parse, and evaluate, "dice expressions" in C#. A dice expression is defined like so: <expr> := <expr> + <expr> | <expr> - <expr> | [<number>]d(<number>|%) | <number> <number> := positive integer So e.g. d6+20-2d3 would be allowed, and should evaluate as rand.Next(1, 7) + 20 - (rand.Next(1, 4) + rand.Next(1, 4)) Also d% should be equivalent to d100. I know I could hack together some solution, but I also know that this seems like a very typical computer-science type problem, so there must be some super-elegant solution I should look into. I'd like the result of my parsing to have these capabilities: I should be able to output a normalized form of the expression; I'm thinking dice first, sorted by dice size, and always with a prefix. So e.g. the above sample would become 1d6-2d3+20. Also any instances of d% would become d100 in the normalized form. I should be able to evaluate the expression at-will, rolling different random numbers each time. I should be able to evaluate the expression with all of the dice-rolls maximized, so e.g. the sample above would give (deterministically) 1*6+20+2*3 = 32. I know that this is exactly the type of thing Haskell, and probably other functional-type languages, would be great at, but I'd like to stay in C# if possible. My initial thoughts tend toward recursion, lists, and maybe some LINQ, but again, if I tried without some pointers from people who know things, I'm sure it'd end up being an inelegant mess. Another tactic that might work would be some initial regex-based string-replacement to turn dice expressions into rand.Next calls, and then on-the-fly evaluation or compilation... would this actually work? How could I avoid creating a new rand object every time?
0
0
0
0
1
0
I am using a 3D engine called Electro which is programmed using Lua. It's not a very good 3D engine, but I don't have any choice in the matter. Anyway, I'm trying to take a flat quadrilateral and transform it to be in a specific location and orientation. I know exactly where it is supposed to go (i.e. I know the exact vertices where the corners should end up), but I'm hitting a snag in getting it rotated to the right place. Electro does not allow you to apply transformation matrices. Instead, you must transform models by using built-in scale, position (that is, translate), and rotation functions. The rotation function takes an object and 3 angles (in degrees): E.set_entity_rotation(entity, xangle, yangle, zangle) The documentation does not speficy this, but after looking through Electro's source, I'm reasonably certain that the rotation is applied in order of X rotation -> Y rotation -> Z rotation. My question is this: If my starting object is a flat quadrilateral lying on the X-Z plane centered at the origin, and the destination position is in a different location and orientation where the destination vertices are known, how could I use Electro's rotation function to rotate it into the correct orientation before I move it to the correct place? I've been racking my brain for two days trying to figure this out, looking at math that I don't understand dealing with Euler angles and such, but I'm still lost. Can anyone help me out?
0
0
0
0
1
0
i have mathematical problem which I'm unable to convert to PHP or explain differently. Can somebody send my in the right direction? I have two number which are in order (sequence). #1 and #2. I want to somehow compare those two numbers and get a positive number lower than 100 as the result of the comparison. The higher the values, the higher the result should be. However, if #2 is also high, then the result should be "dimmed" accordingly... These are the "expected results": #1: 5 #2: 10 => ~ 5 #2: 10 #2: 5 => ~ 8 #1: 50 #2: 60 => ~ 12 #1: 50 #2: 100 => ~ 8 #1: 100 #2: 50 => ~ 20 #1: 500 #2: 500 => ~ 25 #1: 500 #2: 100 => ~ 50 #1: 100 #2: 500 => ~ 15 The number (1 or 2) values are ranged between 0 and 1000. The results are just estimates, they will obviously be different. I just want to show how it is related.
0
0
0
0
1
0
At first I have 5 cards by random, of course. Only one time I can change and also l have already taught [the program] the poker rules in my system. My problem is how can I choose "I don't need this card or there are cards?". I can change by myself but computer doesn't know. I think maybe it is difficult but have you guys any help to offer?
0
1
0
0
0
0
For sure this is very trivial math stuff for some of you. But: When I rotate a view, lets say starting at 0 degrees and rotating forward 0.1, 1, 10, 100, 150, 160, 170, 179, 179,999, and keeping on rotating in the same direction, this happens, to say it loud and clear: BANG !!!! BAAAAAAAAANNNNNGGGG!!!! -179,9999, -170, -150, -50, 0, 50, 100, 170, 179,99, and again: BBBBAAAANNNGGG!!! -179,999, -170, -100, and so on... for sure you know what I mean ;-) Imagine you driving on a road and suddenly your miles-o-meter jumps negative like that. You wold freak out, right? And you know what? This is VERY bad for my algorithm. I have no idea how to resolve this other than checking in if-else-blocks if my value suddenly swapped over. Something tells me I have to look at some math functions like sinus waves and other stuff. But my math knowledge sucks to the highest degree. How can I solve this out? I try to calculate distances between angles, i.e. I have two views where one resides on the other, and both are rotated. And I want to calculate the overall rotation of both views. This little but mad thingy destroys my calculations as soon as values swap over suddenly from -179,99999 to 179,99999. Also I don't know if a 180 exists or if things swap somewhere at fabsf(179,999999999999999999999) if you know what I mean. For example: What would be -170 degrees minus 50 degrees? Well, I think -220 degrees. But instead when I rotate -170 - 50 I end up getting this value: 40 degrees. How can I receive what I expect, the -220 instead of 40, without any kind of unsecure swapping-if-else logic? Sometimes my selfmade-swapper works, but sometimes it doesnt due to math incprecisions. Edit: I calculate the angles from the transform.rotation.z property of the view's layers.
0
0
0
0
1
0
In my data structures class, we've been assigned a project in which we are required to make a fully functioning Quantum Tic-Tac-Toe game in which a player faces a bot that plays to win. The professor suggested we use a game tree in our AI. However, as usual, I am looking for something more challenging. Can anyone suggest a better, more advanced approach that I could research and implement? I'm not looking for something completely ridiculous that makes the problem more complex. Rather, I'm looking for an advanced approach -- like using an A* algorithm rather than a BFS.
0
1
0
0
0
0
My problem: How can I take two 3D points and lock them to a single axis? For instance, so that both their z-axes are 0. What I'm trying to do: I have a set of 3D coordinates in a scene, representing a a box with a pyramid on it. I also have a camera, represented by another 3D coordinate. I subtract the camera coordinate from the scene coordinate and normalize it, returning a vector that points to the camera. I then do ray-plane intersection with a plane that is behind the camera point. O + tD Where O (origin) is the camera position, D is the direction from the scene point to the camera and t is time it takes for the ray to intersect the plane from the camera point. If that doesn't make sense, here's a crude drawing: I've searched far and wide, and as far as I can tell, this is called using a "pinhole camera". The problem is not my camera rotation, I've eliminated that. The trouble is in translating the intersection point to barycentric (uv) coordinates. The translation on the x-axis looks like this: uaxis.x = -a_PlaneNormal.y; uaxis.y = a_PlaneNormal.x; uaxis.z = a_PlaneNormal.z; point vaxis = uaxis.CopyCrossProduct(a_PlaneNormal); point2d.x = intersection.DotProduct(uaxis); point2d.y = intersection.DotProduct(vaxis); return point2d; While the translation on the z-axis looks like this: uaxis.x = -a_PlaneNormal.z; uaxis.y = a_PlaneNormal.y; uaxis.z = a_PlaneNormal.x; point vaxis = uaxis.CopyCrossProduct(a_PlaneNormal); point2d.x = intersection.DotProduct(uaxis); point2d.y = intersection.DotProduct(vaxis); return point2d; My question is: how can I turn a ray plane intersection point to barycentric coordinates on both the x and the z axis?
0
0
0
0
1
0
I do know that feedforward multi-layer neural networks with backprop are used with Reinforcement Learning as to help it generalize the actions our agent does. This is, if we have a big state space, we can do some actions, and they will help generalize over the whole state space. What do recurrent neural networks do, instead? To what tasks are they used for, in general?
0
1
0
0
0
0
Given a convex polygon represented by a set of vertices (we can assume they're in counter-clockwise order), how can this polygon be broken down into a set of right triangles whose legs are aligned with the X- and Y-axes? Since I probably lack some math terminology, "legs" are what I'm calling those two lines that are not the hypotenuse (apologies in advance if I've stabbed math jargon in the face--brief corrections are extra credit).
0
0
0
0
1
0
int x = 73; int y = 100; double pct = x/y; Why do I see 0 instead of .73?
0
0
0
0
1
0
HI All, How can I calculate direction vector of a line segment, defined by start point (x1, y1) and end point (x2, y2)? Cheers.
0
0
0
0
1
0
I would like to extract the most used colors inside an image, or at least the primary tones Could you recommend me how can I start with this task? or point me to a similar code? I have being looking for it but no success.
0
0
0
1
0
0
I'm currently looking at python because I really like the text parsing capabilities and the nltk library, but traditionally I am a .Net/C# programmer. I don't think IronPython is an integration point for me because I am using NLTK and presumably would need a port of that library to the CLR. I've looked a little at Python for .NET and was wondering if this was a good place to start. Is there a way to marshal a python class into C#? Also, is this solution still being used? Better yet, has anyone done this? One thing I am considering is just using a persistence medium as a go-between (parse in Python, store in MongoDB, and run site in .NET).
0
1
0
0
0
0
While displaying the download status in a window, I have information like: 1) Total file size (f) 2) Downloaded file size (f') 3) Current download speed (s) A naive time-remaining calculation would be (f-f')/(s), but this value is way-to-shaky (6m remaining / 2h remaining / 5m remaining! deja vu?! :) Would there be a calculation which is both stabler and not extremely wrong (showing 1h even when the download is about to complete)?
0
0
0
0
1
0
afternoon all. Iv'e come across some mathematical problems that im not too good at. does anyone know how to calculate the ratio for Height against width? Regards Phil
0
0
0
0
1
0
Is there a utility to create an identity matrix of specified size in Java?
0
0
0
0
1
0
Are there are any good open source online math editors? I couldn't find anything searching on Google.
0
0
0
0
1
0
Here's something I'm trying to figure out concerning display objects in ActionScript3 / Flex. Let's say you have a display object who's registration point is in the top left and you want to scale it from its center (middle of the display object), How could you easily acheive this with the flash.geom.Matrix class Thanks for your help
0
0
0
0
1
0
I'm trying to output a value from xml this is what I do - <?php echo $responseTemp->Items->Item->CustomerReviews->AverageRating; ?> This outputs 4.5, but when I change it to the code below it displays as 8. Why isn't it displaying as 9? Thanks. <?php echo $responseTemp->Items->Item->CustomerReviews->AverageRating*2; ?>
0
0
0
0
1
0
I'd like to write a program that lets users draw points, lines, and circles as though with a straightedge and compass. Then I want to be able to answer the question, "are these three points collinear?" To answer correctly, I need to avoid rounding error when calculating the points. Is this possible? How can I represent the points in memory? (I looked into some unusual numeric libraries, but I didn't find anything that claimed to offer both exact arithmetic and exact comparisons that are guaranteed to terminate.)
0
0
0
0
1
0
Is it possible to programmatically convert regular English into English haiku? Or is this something too complicated to contemplate? I have a feeling that this is a lot more involved than a Pig Latin formatter.
0
1
0
0
0
0
I know I am not the only one who does not like progress bars or time estimates which give unrealistic estimates in software. Best examples are installers which jump from 0% to 90% in 10 seconds and then take an hour to complete the final 10%. Most of the time programmers just estimate the steps to complete a task and then display currentstep/totalsteps as a percentage, ignoring the fact that each step might take a different time to complete. For example, if you insert rows into a database, the insertion time can increase with the number of inserted rows (easy example), or the time to copy files does not only depend on the size of the file but also on the location on the disk and how fragmented it is. Today, I asked myself if anybody already tried to model this and maybe created a library with a configurable robust estimator. I know that it is difficult to give robust estimates because external factors (network connection, user runs other programs, etc) play their part. Maybe there is also a solution that uses profiling to set up a better estimator, or one could use machine learning approaches. Does anybody know of advanced solutions for this problem? In connection to this, I found the article Rethinking the progress bar very interesing. It shows how progress bars can change the perception of time and how you can use those insights to create progress bars that seem to be faster. EDIT: I can think of ways how to manually tune the time estimate, and even with a 'estimator library' I will have to fine tune the algorithm. But I think this problem could be tackled with statistical tools. Of course, the estimator would collect data during the process to create better estimates for the next steps. What I do now is to take the average time something took in the previous step (steps grouped by type and normalized by e.g. file size, size of transaction) and take this average as estimate for the next steps (again: counting in different types and sizes). Now, I know there are better statistical tools to create estimators and I wonder if anybody applied those to the problem.
0
0
0
1
0
0
I have a few sets of information available to me, currently: position on screen (Point) orientation of point (double, say 15 degrees) distance (length from point) What I want to do is pick X (less than 6 I think) number of points in an angular spread facing the same orientation as the position with a distance of distance so that they are always on screen. I can do this, but my implementation does not take into account the fact that some of the points end up off the screen, and all my attempts are quite poor and overly complex. Does anyone have a good way of doing this? EDIT: Added graphic to show what im after...
0
0
0
0
1
0
Motivation: I'd like to be able to use toy functional programming in languages without first-order functions, by using natural numbers instead of functions. A universal function is a function f : N -> (N -> N), equivalently f : N * N -> N that enumerates all possible computable functions. In other words, there's a number k such that f(k) is the squaring function, there's a number j such that f(j) is the n-th prime function etc. To write such a function, one can take any Turing-complete language (programming language compiler, lambda calculus, Turing machines...) and enumerate all programs. I'd like to allow not only evaluation, but also operations on functions like addition, composition, currying. For example, given indices of two functions f,g I'd like to know what is the index of the function f+g, or f composed with g. This would allow "toy functional programming". What is a good way to write such code library? I'm not looking for a minimalistic Turing tarpit that will struggle to compute factorial of 10, nor I don't want to write an advanced compiler. It should have some basic functions like addition and possibility to write loop, but not much more. Solutions in all high-level languages are welcome. Pseudocode, Haskell and Python are preferred. You can assume arbitrary precision arithmetic. Using eval or similar is not allowed. Clarification: Enumerated functions will consist of all partial recursive (computable) ones - this includes functions that don't halt on some inputs. The universal function will hang in that cases; of course this is unavoidable. See also: m-recursive functions - http://en.wikipedia.org/wiki/Μ-recursive_function.
0
0
0
0
1
0
I'm interested in developing a natural language command language for a domain with existing rules. I was very impressed when Terry Winograd's SHRDLU showed the way (the conversation below is 40 years old! Astonishing). Can we do better now and if so where can I get examples? Person: Pick up a big red block. Computer: OK. Person: Grasp the pyramid. Computer: I don't understand which pyramid you mean. Person (changing their mind): Find a block which is taller than the one you are holding and put it into the box. Computer: By "it", I assume you mean the block which is taller than the one I am holding. Computer: OK. Person: What does the box contain? Computer: The blue pyramid and the blue block. Person: What is the pyramid supported by? Computer: The box. Person: How many blocks are not in the box? Computer: Four of them. Person: Is at least one of them narrower than the one which I told you to pick up? Computer: Yes, the red cube. I have an ontology for the domain so can reason over common problems.
0
1
0
0
0
0
I am looking for an open source Natural Language Processing library for c/c++ and especially i am interested in Part of speech tagging.
0
1
0
0
0
0
I will phrase the problem in the precise form that I want below: Given: Two floating point lists N and D of the same length k (k is multiple of 2). It is known that for all i=0,...,k-1, there exists j != i such that D[j]*D[i] == N[i]*N[j]. (I'm using zero-based indexing) Return: A (length k/2) list of pairs (i,j) such that D[j]*D[i] == N[i]*N[j]. The pairs returned may not be unique (any valid list of pairs is okay) The application for this algorithm is to find reciprocal pairs of eigenvalues of a generalized palindromic eigenvalue problem. The equality condition is equivalent to N[i]/D[i] == D[j]/N[j], but also works when denominators are zero (which is a definite possibility). Degeneracies in the eigenvalue problem cause the pairs to be non-unique. More generally, the algorithm is equivalent to: Given: A list X of length k (k is multiple of 2). It is known that for all i=0,...,k-1, there exists j != i such that IsMatch(X[i],X[j]) returns true, where IsMatch is a boolean matching function which is guaranteed to return true for at least one j != i for all i. Return: A (length k/2) list of pairs (i,j) such that IsMatch(i,j) == true for all pairs in the list. The pairs returned may not be unique (any valid list of pairs is okay) Obviously, my first problem can be formulated in terms of the second with IsMatch(u,v) := { (u - 1/v) == 0 }. Now, due to limitations of floating point precision, there will never be exact equality, so I want the solution which minimizes the match error. In other words, assume that IsMatch(u,v) returns the value u - 1/v and I want the algorithm to return a list for which IsMatch returns the minimal set of errors. This is a combinatorial optimization problem. I was thinking I can first naively compute the match error between all possible pairs of indexes i and j, but then I would need to select the set of minimum errors, and I don't know how I would do that. Clarification The IsMatch function is reflexive (IsMatch(a,b) implies IsMatch(b,a)), but not transitive. It is, however, 3-transitive: IsMatch(a,b) && IsMatch(b,c) && IsMatch(c,d) implies IsMatch(a,d). Addendum This problem is apparently identically the minimum weight perfect matching problem in graph theory. However, in my case I know that there should be a "good" perfect matching, so the distribution of edge weights is not totally random. I feel that this information should be used somehow. The question now is if there is a good implementation to the min-weight-perfect-matching problem that uses my prior knowledge to arrive at a solution early in the search. I'm also open to pointers towards a simple implementation of any such algorithm.
0
0
0
0
1
0
I've wrote a parser in PHP that converts a string representation of an equation to RPN based on feedback from an earlier question. Whilst testing it I found two different equations that parse to the same thing in RPN. Because they end up as the same thing in RPN when you solve them you get the same answer. 3 + 4 * 8 / (1 -5) 3 + 4 * 8 / 1 -5 Both end up as 348*15-/+ which when solved gives an answer of -5 which is correct for the first one, but the answer to the second one should be 30. So have I misunderstood how to convert to RPN? The code to my parser can be found in the above link to the previous question.
0
0
0
0
1
0
Is there an algorithm that checks whether creating a new thread pays off performance wise? I'll set a maximum of threads that can be created anyway but if I add just one task it wouldn't be an advantage to start a new thread for that. The programming language I use is python. Edit 1# Can this question even be answered or is it to general because it depends on what the threads work on?
0
0
0
0
1
0
There are plenty of Chess AI's around, and evidently some are good enough to beat some of the world's greatest players. I've heard that many attempts have been made to write successful AI's for the board game Go, but so far nothing has been conceived beyond average amateur level. Could it be that the task of mathematically calculating the optimal move at any given time in Go is an NP-complete problem?
0
1
0
0
0
0
9 = 2^X mod 11 What is X and how do you find X? Its related to finding the plain text in RSA algorithm and I'm writing a C program for it.
0
0
0
0
1
0
I am looking for a way to convert any number to a percentage in the following way: 1.00 is 50% numbers below 1.00 approach 0% logarithmically numbers above 1.00 approach 100% logarithmically. x > 0. So y needs to approach 0 as x becomes infinitely small on the positive side. I'm sure this is simple to do, but I can't recall how to do it.
0
0
0
0
1
0
I've 3 .jsp files. index.jsp and sqrtcalculator.jsp and error.jsp. In index.jsp there's a text field and a button. In sqrtcalculator.jps there's the, well, calculator. Now, when I leave the field empty and press the button, an expection is called, because the field is empty. And I can then reroute to an individual error.jsp site to display the errors, and exception stack like <%= request.getAttribute("javax.servlet.error.request_uri") %> <%= exception.getMessage() %> <%= exception %> etc. Problem is, when I enter -5 in the textfield, I can't get an exception, because Math.sqrt(-5) doesn't return an error but "NaN". How can I force it to be an exception? The idea is to reroute the user to an individual error.jsp and displaying the errors. But like I said Math.sqrt(-5) doesn't return errors or exceptions but "NaN" textstring. I don't want something like this just FYI <%if (NaN){ %> <p>Nope, Square root from negative numbers is not defined!</p> <%} %>
0
0
0
0
1
0
Any examples, tips, guidance for the following scenario? I have retrieved updates from several different news websites. I then analyse that information to predict on current trend in the world. I could only find the information on data mining when searching for above idea, but it is for database systems. While data mining is similar to what i am trying to do, data mining in databases information is more specific than what I have retrieved from websites. So could someone guide me on this aspect? I really appreciate any help you can give on this. Thanks.
0
1
0
1
0
0
I have to do a final project for my computational linguistics class. We've been using OCaml the entire time, but I also have familiarity with Java. We've studied morphology, FSMs, collecting parse trees, CYK parsing, tries, pushdown automata, regular expressions, formal language theory, some semantics, etc. Here are some ideas I've come up with. Do you have anything you think would be cool? A script that scans Facebook threads for obnoxious* comments and silently hides them with JS (this would be run with the user's consent, obviously) An analysis of a piece of writing using semantics, syntax, punctuation usage, and other metrics, to try to "fingerprint" the author. It could be used to determine if two works are likely written by the same author. Or, someone could put in a bunch of writing he's done over time, and get a sense of how his style has changed. A chat bot (less interesting/original) I may be permitted to use pre-existing libraries to do this. Do any exist for OCaml? Without a library/toolkit, the above three ideas are probably infeasible, unless I limit it to a very specific domain. Lower level ideas: Operations on finite state machines - minimizing, composing transducers, proving that an FSM is in a minimal possible state. I am very interested in graph theory, so any overlap with FSMs could be a good venue to explore. (What else can I do with FSMs?) Something cool with regex? Something cool with CYK? Does anyone else have any cool ideas? *obnoxious defined as having following certain patterns typical of junior high schoolers. The vagueness of this term is not an issue; for the credit I could define whatever I want and target that.
0
1
0
0
0
0
Is there a lowest common denominator format for multidimensional images or matrices analogous to netpbm/netpgm for 2d images? How would you use protocol buffers to define a 3d image or matrix of 16 bit unsigned numbers? Why didn't the netpbm people allow more dimensions in the row, column line?
0
0
0
0
1
0
I am trying to check the location of a point(px, py) on 2D graph in relation to a line segment (lx1, ly1) (lx2, ly2), using logic of North South East West directions. The logic I have implemented is to draw a perpendicular on the line segment from the point. if perpendicular is on line that means its south. If point on right side means its East. If point on left side means West. If perpendicular is away from line in forward direction will mean North. If perpendicular is away from line in backward direction will mean South. My problem is that this logic looks good on paper, but its getting really hard to decide whether its a NW, NE, SW or SE case. Can anyone suggest me how to compute this logic?? I am using C++, but algorithm in any language will be a great help. I am using end point of line segment to calculate North South East West relation. Cheers
0
0
0
0
1
0
What would be a fast way to implent this osscilation function. A signature would look like this: public static double Calculate(UInt64 currentCounter, uint duration, uint inDuration, uint outDuration) And the result should be a double that as currentCounter advances, ossciates between 0 and 1. The osscialtion speed is defines by the duration parameter (the number of ticks for a single osccilation). Similarily the ascent and descent speed is defines via inDUration and outDuration (inDUration + outDuration). alt text http://img252.imageshack.us/img252/9457/graphuf.jpg The x-Axis of this graph would of course be currentCounter.
0
0
0
0
1
0
I have a double which is: double mydouble = 10; and I want 10^12, so 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10 * 10. I tried double newDouble = pow(10, 12); and it returns me in NSLog: pow=-1.991886 makes not much sense... I think pow isn't my friend right?
0
0
0
0
1
0
Algorithm for a drawing and painting robot - Hello I want to write a piece of software which analyses an image, and then produces an image which captures what a human eye perceives in the original image, using a minimum of bezier path objects of varying of colour and opacity. Unlike the recent twitter super compression contest (see: stackoverflow.com/questions/891643/twitter-image-encoding-challenge), my goal is not to create a replica which is faithful to the image, but instead to replicate the human experience of looking at the image. As an example, if the original image shows a red balloon in the top left corner, and the reproduction has something that looks like a red balloon in the top left corner then I will have achieved my goal, even if the balloon in the reproduction is not quite in the same position and not quite the same size or colour. When I say "as perceived by a human", I mean this in a very limited sense. i am not attempting to analyse the meaning of an image, I don't need to know what an image is of, i am only interested in the key visual features a human eye would notice, to the extent that this can be automated by an algorithm which has no capacity to conceptualise what it is actually observing. Why this unusual criteria of human perception over photographic accuracy? This software would be used to drive a drawing and painting robot, which will be collaborating with a human artist (see: video.google.com/videosearch?q=mr%20squiggle). Rather than treating marks made by the human which are not photographically perfect as necessarily being mistakes, The algorithm should seek to incorporate what is already on the canvas into the final image. So relative brightness, hue, saturation, size and position are much more important than being photographically identical to the original. The maintaining the topology of the features, block of colour, gradients, convex and concave curve will be more important the exact size shape and colour of those features Still with me? My problem is that I suffering a little from the "when you have a hammer everything looks like a nail" syndrome. To me it seems the way to do this is using a genetic algorithm with something like the comparison of wavelet transforms (see: grail.cs.washington.edu/projects/query/) used by retrievr (see: labs.systemone.at/retrievr/) to select fit solutions. But the main reason I see this as the answer, is that these are these are the techniques I know, there are probably much more elegant solutions using techniques I don't now anything about. It would be especially interesting to take into account the ways the human vision system analyses an image, so perhaps special attention needs to be paid to straight lines, and angles, high contrast borders and large blocks of similar colours. Do you have any suggestions for things I should read on vision, image algorithms, genetic algorithms or similar projects? Thank you Mat PS. Some of the spelling above may appear wrong to you and your spellcheck. It's just international spelling variations which may differ from the standard in your country: e.g. Australian standard: colour vs American standard: color
0
1
0
0
0
0
I'm interested in implementing an algorithm on the GPU using HLSL, but one of my main concerns is that I would like a variable level of precision. Are there techniques out there to emulate 64bit precision and higher that could be implemented on the GPU. Thanks!
0
0
0
0
1
0
How can i generate dynamically this array. var posX:Array = [0,-20,20,-40,0,40,-60,-20,20,60,-80,-40,0,40,80,-100,-60,-20,20,60,100] The numbers in the array refer to the x position of the object. I use it to place objects in triangular formation. 0 -20 20 -40 0 40 -60 -20 20 60 etc Thank you in advance
0
0
0
0
1
0
and we need to put these balls into boxes. How many states of the states could there be? This is part of a computer simulation puzzle. I've almost forget all my math knowledges.
0
0
0
0
1
0
I'm trying to write a function that can calculate revenue at different tiered levels... For example you sell $10000 worth of widgets. Any earnings from $1 - $999 we take 50%, $1000 - $4999 we take 25%, $5000 - $9999 we take 10%, $10000 - $19999 5%. The percentage is not taken based on the final value. So if you earned $10000 you don't just fall into the 10% column. Your first $1000 is subject to 50%, the next $5000 25%, the next $4000 10%. Thanks in advance. **Final working code. Thanks for the help! $input = 10000; $tiers = array('1000' => .5, '5000' => .25, '10000' => .1, '20000' => .05, '22000' => .01); $accounted_for = 0; $total_share = 0; $tier = each($tiers); while($accounted_for < $input) { $cutoff = $tier[0]; $percent = $tier[1]; $level = (min($cutoff, $input) - $accounted_for) * $percent; $total_share += $level; $accounted_for = $cutoff; $tier = each($tiers); } return $total_share;
0
0
0
0
1
0
In javascript, I am trying to draw a line that is at an angle that is user defined. Basically, I have a point (x,y) and an angle to create the next point at. The length of the line need to be 10px. Let's say that the point to start with is (180, 200)... if I give it angle "A" and the (I guess)hypotenuse is 10, what would my equation(s) be to get the X and Y for a slope? Thanks for your help!
0
0
0
0
1
0
What are the (practical) applications of Unification? Where it is actually being used in real world? I couldn't understand the whole idea of what it is really about and why it's considered as a part of Artificial Intelligence.
0
1
0
0
0
0