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
There is a ruby stemmer https://github.com/aurelian/ruby-stemmer, but it 1) does not stem English irregular verbs 2) fails to build native extensions on Windows. Is there an alternative that fixes at least one of the problems?
0
1
0
0
0
0
I'm working on a Pythagorean Theorem program that calculates the sides and angles of a right triangle. I have the side measurements and all that down, but I can't find the Visual Basic function that will allow me to calculate the angles from the side measurements. I've tried asin and sinh, but both give me the wrong measure.
0
0
0
0
1
0
I want to extract important terms from a text and create a domain specific term set. Then I want to learn how these words are used in text, positively or negatively. Do you know any open source project which will help me to accomplish this tasks? Edit: Example Text: "Although car is not comfortable, I like the design of it." From this text, I want to extract something like these: design: positive comfort(able): negative
0
1
0
1
0
0
We are supposed to write a program to solve the following initial value problem numerically using 4th order Runge-Kutta. That algorithm isn't a problem and I can post my solution when I finish. The problem is, separating it out cleanly into something I can put into Runge-Kutta. e^(-x') = x' −x + exp(−t^3) x(t=0) = 1 Any ideas what type of ODE this is called? or methods to solve this? I feel more confident with CS skills and programming numerical methods than I do in math... so any insights into this problem would be helpful. Update: If anyone is interested in the solution the code is below. I thought it was an interesting problem. import numpy as np import matplotlib.pyplot as plt def Newton(fn, dfn, xp_guess, x, t, tolerance): iterations = 0 value = 100. max_iter = 100 xp = xp_guess value = fn(t, x, xp) while (abs(value) > tolerance and iterations < max_iter): xp = xp - (value / dfn(t,x,xp)) value = fn(t,x,xp) iterations += 1 root = xp return root tolerance = 0.00001 x_init = 1. tmin = 0.0 tmax = 4.0 t = tmin n = 1 y = 0.0 xp_init = 0.5 def fn(t,x,xp): ''' 0 = x' - x + e^(-t^3) - e^(-x') ''' return (xp - x + np.e**(-t**3.) - np.e**(-xp)) def dfn(t,x,xp): return 1 + np.e**(-xp) i = 0 h = 0.0001 tarr = np.arange(tmin, tmax, h) y = np.zeros((len(tarr))) x = x_init xp = xp_init for t in tarr: # RK4 with values coming from Newton's method y[i] = x f1 = Newton(fn, dfn, xp, x, t, tolerance) K1 = h * f1 f2 = Newton(fn, dfn, f1, x+0.5*K1, t+0.5*h, tolerance) K2 = h * f2 f3 = Newton(fn, dfn, f2, x+0.5*K2, t+0.5*h, tolerance) K3 = h * f3 f4 = Newton(fn, dfn, f3, x+K3, t+h, tolerance) K4 = h * f4 x = x + (K1+2.*K2+2.*K3+K4)/6. xp = f4 i += 1 fig = plt.figure() ax = fig.add_subplot(1,1,1) ax.plot(tarr, y) plt.show()
0
0
0
0
1
0
How do I find a coordinate using cartesian coordinate system with just an index? For instance, 4 points to 1,2 and 9 points to 1,3. Assume that the blocks will always wrap around 1,1. I'm not married to the order of the grid, but I want to call the location by an index rather then a coronate if at all possible. I'm trying to create a grid for game tiles.
0
0
0
0
1
0
I have a formula in JS that uses the bitwise NOT operator. ~~(n/m + 0.5) * m; How do I write the same expression in ruby? There is no bitwise NOT operator in ruby.
0
0
0
0
1
0
I want to flexibly access motion capture data from C/C++ code. We currently have a bunch of separate files (.c3d format). We can expect the full set of data to be several hours long and tracking about 50 markers (4 floats each) per frame, sampled at 60 hz. So we're probably looking at a couple of gigabytes of data. I'd like to have a database that can hold the data, allowing it to be relatively rapidly retrieved, augmented, and modified. I like to be able to apply labels to the data and retrieve sequences of frames by label, time indices (e.g., frame 400-2000, or every 30th frame) or other potential criteria. Does such a thing already exist? Could I do it with SQLite for example? Does anyone have an intuition for what kind of performance I might get? Currently, I'm just loading one .c3d file at a time and processing it. I haven't yet begun to apply meta-data/labels to sequences. I'll be accessing the sequences for visualization, statistical analysis, and training for machine-learning.
0
0
0
1
0
0
I have a set of examples, which are each annotated with feature data. The examples and features describe the settings of an experiment in an arbitrary domain (e.g. number-of-switches, number-of-days-performed, number-of-participants, etc.). Certain features are fixed (i.e. static), while others I can manually set (i.e. variable) in future experiments. Each example also has a "reward" feature, which is a continuous number bounded between 0 and 1, indicating the success of the experiment as determined by an expert. Based on this example set, and given a set of static features for a future experiment, how would I determine the optimal value to use for a specific variable so as to maximise the reward? Also, does this process have a formal name? I've done some research, and this sounds similar to regression analysis, but I'm still not sure if it's the same thing.
0
0
0
1
0
0
I am using the following R code to produce a confusion matrix comparing the true labels of some data to the output of a neural network. t <- table(as.factor(test.labels), as.factor(nnetpredict)) However, sometimes the neural network doesn't predict any of a certain class, so the table isn't square (as, for example, there are 5 levels in the test.labels factor, but only 3 levels in the nnetpredict factor). I want to make the table square by adding in any factor levels necessary, and setting their counts to zero. How should I go about doing this? Example: > table(as.factor(a), as.factor(b)) 1 2 3 4 5 6 7 8 9 10 1 1 0 0 0 0 0 0 1 0 0 2 0 1 0 0 0 0 0 0 1 0 3 0 0 1 0 0 0 0 0 0 1 4 0 0 0 1 0 0 0 0 0 0 5 0 0 0 0 1 0 0 0 0 0 6 0 0 0 0 0 1 0 0 0 0 7 0 0 0 0 0 0 1 0 0 0 You can see in the table above that there are 7 rows, but 10 columns, because the a factor only has 7 levels, whereas the b factor has 10 levels. What I want to do is to pad the table with zeros so that the row labels and the column labels are the same, and the matrix is square. From the example above, this would produce: 1 2 3 4 5 6 7 8 9 10 1 1 0 0 0 0 0 0 1 0 0 2 0 1 0 0 0 0 0 0 1 0 3 0 0 1 0 0 0 0 0 0 1 4 0 0 0 1 0 0 0 0 0 0 5 0 0 0 0 1 0 0 0 0 0 6 0 0 0 0 0 1 0 0 0 0 7 0 0 0 0 0 0 1 0 0 0 8 0 0 0 0 0 0 0 0 0 0 9 0 0 0 0 0 0 0 0 0 0 10 0 0 0 0 0 0 0 0 0 0 The reason I need to do this is two-fold: For display to users/in reports So that I can use a function to calculate the Kappa statistic, which requires a table formatted like this (square, same row and col labels)
0
0
0
1
0
0
I'd like to know what kind of real life problems can be tackled by "duality methods" in functional programming. More precisely, I'd like to know whether someone did actually use a duality method like the ones I present below, or whether there are other interesting examples. I'd be particularly interested in existing implementations, probably in Haskell. [Since the majority of people which will be interested in this question likely know Haskell, let me please add the Haskell tag, even if the question is quite language independent] Let me explain what I mean by duality (by lack of a better name) through a few examples. The first one is the real numbers. Assume the existence of a Integer and a Rational type, and define a real number as a function (pardon my Haskell, I'm no hardcore haskeller) type Real = Integer -> Rational such that whenever x :: Real denotes the real number x, x n yields a rational number which is within 2^(-n) of x. Now one can do (+) :: Real -> Real -> Real (+) x y n = (x $ n + 1) + (y $ n + 1) or likewise for other arithmetic operations. Given a continuous real function f, one can also compute f x as soon as one can compute a modulus of continuity for f. This has the advantage that one can write natural looking code, and at the end, get a result at the desired level of precision automatically. However, it is no longer possible to compare real numbers for equality. The only kind of comparison possible between x and y is x < y + eps. Another example of duality is this question on probability measures, which triggered the present question in my head. Let us write type Measure a = (a -> Double) -> Double and define measures as integration procedures against functions. In the linked question, I show how natural it is in this framework to express concepts like convolution or pushforward which are much more difficult (computationally, but also theoretically) to define at the level of probability densities. It allows one to compose building blocks from probability theory, and in principle allows one to build complex Monte Carlo procedures, and even allows one to work with explicit probability densities (at the expense of numerical integration). I'd be especially interested in any attempt at a real world library on this topic. Another example that I have in mind, but did not quite formalize yet is the notion of vector fields (from differential geometry), that one can express as differentiation operators. For this, one needs a suitable type of "smooth real valued functions", and then a vector field is like this: type VectorField = SmoothFunction -> SmoothFunction such that v (f * g) = f * (v g) + g * (v f). Of course, describing a sheaf of regular functions in say Haskell should not be easy. But by doing that, we could express all the stuff from differential geometry in a totally coordinate independant way, and plug coordinates at the very end. There are other examples, eg. Taylor series have been discussed in Sigfpe's blog (I can't find this particular post though), where an analytic function is the following type: type AnalyticFunction = Double -> Integer -> [Double] and where f x n returns the n first partial sums of the Taylor expansion of f around x. This allows us to seamlessly write all kind of arithmetic on analytic functions, including stuff like f / g where f and g both can vanish at a point (along with some of their derivatives), or even f^(-1) (provided f' does not vanish). At the end, only the necessary terms of the intermediate series are computed to yield the value of a given expression.
0
0
0
0
1
0
Ok I have another pong related question. Now I'm trying to improve "AI". I read on the internet that I should predict ball's x and y and move there paddle. Heres my equations. y=ax+b a1=(y1-y2)/(x1-x2) - a of the circles line, x1, y1 are taken before movent and x2 y2 after. b1=y1-ax1 then I calculated coord for the line of paddle movement using constants like pos 0 0 and screen height, width. To calculate point of intersetcion I made equation: a1x4+b1=a2x4+b2. a1 b1 b2 a2 are things I calculated before. And it doesnt work :P What's wrong ?
0
0
0
0
1
0
double g[2][2]; g[0][0] = cos(M_PI*0.5*(c - w*0.5)); g[0][1] = sin(M_PI*0.5*(c - w*0.5)); g[1][0] = cos(M_PI*0.5*(c + w*0.5)); g[1][1] = sin(M_PI*0.5*(c + w*0.5)); The matrix g is given. How do I rewrite the above to find the value of (c,w)?
0
0
0
0
1
0
Here's my code: Double[] x = {1.0, 2.0, 3.0}; Double[] fx = {1.0, 8.0, 27.0}; s = x.length; Double[][] newton = new Double[(2*s)-1][s+1]; for(int i=0, z=0;i<s;i++,z+=2){ newton[z][0]=x[i]; newton[z][1]=fx[i]; } int i=1, ii=2, j=2, ss=s; for(int z=0;z<s-1;z++,j++,ss-=1,ii++){ for(int y=0;y<ss-1;y++,i+=2){ newton[i][j]=(newton[i+1][j-1]-newton[i-1][j-1])/(newton[i+(ii-1)][0]-newton[i-(ii-1)][0]); } i=ii; } } Sorry for the ugly code. Given x points = {1, 2, 3} and f(x) = {1, 8, 27}, the above code would produce a 2-dimension array like this: 1.0 1.0 7.0 2.0 8.0 6.0 19.0 3.0 27.0 which is a divided difference table. Then, I want to generate its interpolating polynomial function. Thus, with above example, using Newton's polynomial rule, the output function should be 1 + 7(x-1) + 6(x-1)(x-2) = 6x^2-11x+6. I'm really stuck on this, can anyone help me how to produce an output like that?
0
0
0
0
1
0
i want to compute intersection line, given by 2 planes. my main program gives me, plane parameters a,b,-1,d (my equation is ax+by-z+d=0). so, my function for computing equation of intersection line is as; vector<double> LineofIntersection(vector<double> plane1,vector<double> plane2) { double a1=plane1.at(0); double a2=plane2.at(0); double b1=plane1.at(1); double b2=plane2.at(1); double d1=plane1.at(2); double d2=plane2.at(2); int c1=-1,c2=-1; double cros_x=fabs((b1*c2)-(b2*c1)); double cros_y=fabs((a2*c1)-(a1*c2)); double cros_z=fabs((a1*b2)-(a2*b1)); vector <double> point; vector <double> pointout; int maxc; // max coordinate if (cros_x > cros_y){ if (cros_x > cros_z) maxc = 1; else maxc = 3; } else { if (cros_y > cros_z) maxc = 2; else maxc = 3; } // vector <double> point; vector <double> pointout; switch (maxc) { // select max coordinate case 1: // intersect with x=0 point.at(0)=0; point.at(1)=(d2-d1)/(b2-b1); point.at(2)=(b1*d2-2*b1*d1+d1*b2)/(b2-b1); break; case 2: // intersect with y=0 point.at(0)=(d2-d1)/(a1-a2); point.at(1)=0; point.at(2)=(a1*d2-a2*d1)/(a1-a2); break; case 3: // intersect with z=0 point.at(0)=(b1*d2-b2*d1)/(a1*b2-a2*b1); point.at(1)=(a2*d1-a1*d2)/(a1*b2-a2*b1); point.at(2)=0; break; } pointout.push_back(point.at(0)); pointout.push_back(point.at(1)); pointout.push_back(point.at(2)); return pointout; } in the main program, i call this function as: vector<double> linep=LineofIntersection(plane1,plane2); cout<<linep.at(1)<<" "<<linep.at(1)<<" "<<linep.at(2); but, i got error message and cannot run the program. any help please.
0
0
0
0
1
0
For the question "Ellipse around the data in MATLAB", in the answer given by Amro, he says the following: "If you want the ellipse to represent a specific level of standard deviation, the correct way of doing is by scaling the covariance matrix" and the code to scale it was given as STD = 2; %# 2 standard deviations conf = 2*normcdf(STD)-1; %# covers around 95% of population scale = chi2inv(conf,2); %# inverse chi-squared with dof=#dimensions Cov = cov(X0) * scale; [V D] = eig(Cov); I don't understand the first 3 lines of the above code snippet. How is the scale calculated by chi2inv(conf,2), and what is the rationale behind multiplying it with the covariace matrix? Additional Question: I also found that if I scale it with 1.5 STD, i.e. 86% tiles, the ellipse can cover all of the points, my points set are clumping together, at almost all the cases. On the other hand, if I scale it with 3 STD, i.e. 99%tiles, the ellipse is far too big. Then how can I choose a STD to just tightly cover the clumping points? Here is an example: The inner ellipse corresponds to 1.5 STD and outer to 2.5 STD. why 1.5 STD is tightly cover the clumping white points? Is there any approach or reason to define it?
0
0
0
0
1
0
I have a GTGE game and I am having some problems with the math. I don't understand why it isn't moving the way I want it to. When you click somewhere the sprite moves right there. When you right-click it calculates the angle and moves there, but it doesn't stop. I capture the position of the mouse and every time it updates the screen i check to see if the sprite has reached the position, but when it does it doesn't stop. Here is my code: import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.Toolkit; import com.golden.gamedev.Game; import com.golden.gamedev.GameLoader; import com.golden.gamedev.object.Background; import com.golden.gamedev.object.Sprite; import com.golden.gamedev.object.background.ImageBackground; public class SpriteTest extends Game { //Default Background Background background; //Toolkit! Toolkit toolkit = Toolkit.getDefaultToolkit(); //Main Sprite Sprite pacman; Dimension stop; @Override public void initResources() { //Load the background background = new ImageBackground(getImage("nature-wallpapers.jpg")); //Load the Sprite pacman = new Sprite(getImage("pacman.png")); pacman.setActive(false); pacman.setBackground(background); playMusic("intro.mid"); showCursor(); } @Override public void render(Graphics2D g) { //Render background background.render(g); //Render sprites pacman.render(g); } @Override public void update(long elapsedTime) { //Update the background background.update(elapsedTime); //Update sprites if(click()) { pacman.setActive(true); pacman.setLocation(getMouseX(), getMouseY()); } if(rightClick()) { int spriteLocX = (int) pacman.getX(); int spriteLocY = (int) pacman.getY(); int mouseX = getMouseX(); int mouseY = getMouseY(); pacman.setMovement(1, -(Math.toDegrees(Math.atan2(mouseY - spriteLocY, mouseX - spriteLocX )))); stop = new Dimension(mouseX, mouseY); } if(stop != null) { if(pacman.getX() == stop.getWidth()) { if(pacman.getY() == stop.getHeight()){ pacman.setMovement(0, 0); } } } pacman.update(elapsedTime); } public static void main(String[] args) { GameLoader game = new GameLoader(); game.setup(new SpriteTest(), new Dimension(800,600), true); game.start(); } }
0
0
0
0
1
0
Looking at another question of mine I realized that technically there is nothing preventing this algorithm from running for an infinite period of time. (IE: It never returns) Because of the chance that rand.Next(1, 100000); could theoretically keep generating the same value. Out of curiosity; how would I calculate the probability of this happening? I assume it would be very small? Code from other question: Random rand = new Random(); List<Int32> result = new List<Int32>(); for (Int32 i = 0; i < 300; i++) { Int32 curValue = rand.Next(1, 100000); while (result.Exists(value => value == curValue)) { curValue = rand.Next(1, 100000); } result.Add(curValue); }
0
0
0
0
1
0
I need to draw a line in my website, actually a curve representing a third degree polynom. What is the easiest way of finding a third degree equation that fits two points with given slopes in javascript? Find the third degree equation for(or find the coeffecient a,b,c,d in general formula ax^3+bx^2+cx+d = y): startX, startY, startSlope endX, endY, endSlope
0
0
0
0
1
0
I have the values x = 0 => y = 0 x = 1 => y = 1 x = 3 => y = 27 x = 4 => y = 64 I want to create a polynomial function using JAVA to create the function x^3. The program should create the function and display it, and if i give any values it should calculate the interpolated values. I have created a function which just produced the values using Aitken but it doesnt produce the function and it is really hard to understand how to do the function. Because i dont know how to put the X value as X in the java program.
0
0
0
0
1
0
I simply want to add to numbers (currency if you will) like 1.5 and 1.47 together and have it equal 1.97. How is this accomplished? I did not know I did not know how to do this! :) var discountAmount = 0; var ogCookie = < %= strJsonCookie % > for (var i = 0; i < ogCookie.products.length; i++) { discountAmount = parseFloat(discountAmount) + parseFloat(ogCookie.products[i].discount_amount); } alert(discountAmount);
0
0
0
0
1
0
Hey guys, I'm new to neural networks.. I want to know how to come up with equations for outputs of nodes in the hidden and output layers of a neural network. I would like to know the answer to the below and how you did it. I haven't been able to find any approchable reading material on this either. Assume I have a binary classification problem. Assume that I have a multi-layer neural network with one hidden layer. Assume that I have a sigmoid activation function given by f(x)=1/(1+e^-z). Does anyone know how I find the equation for the output of the nodes in the hidden layer and the output of the nodes in the output layer? Thanks guys, any help would be great.
0
1
0
0
0
0
How do I write a function for this in C language? y = 20 ln (x + 3) ? How do I write the ln function?
0
0
0
0
1
0
Given a infinite set/Universe (U) of alphanumeric elements and a family (F) of subsets of (U). Calculate/Group all related subsets in (F), where all elements are covered or less, see example. The Universe is not really infinite, but very large, approximately 59Mil elements and growing. Family (F) subsets, are not constant either, approximately 13Mil elements and growing as well. Example: U = {9b3745e9,ab70de17,1c410139,44038bbf,9c610bb,...,N} F1 = {9b3745e9,07ee0220} F2 = {9b3745e9,ab70de17,99b5d738} F3 = {99b5d738,07ee0220} F4 = {9b3745e9,ab70de17,1c410139} F4calculate()={F2(2),F1(1)} Of cause you can do it on brutal iteration, but over time it is not the optimal solution (NP-complete problem). Any ideas how this can be solved more efficient? Encoding subsets, while using a element/vector Codebook that is larger than Universe, for instance 70Mil or 100Mil. But I'm not sure about calculation.
0
0
0
0
1
0
I'm having some troubles with this equation. Essentially, I'd like the artboard (grid) div to position itself to the edge of the browser when the cursor is within 200px of the edge. This can easily be done by setting the position by watching the mouse coords, however I'd like it to be fluid. I.E. If the mouse is 199px from the left edge then the lVal should slowly decrement until the artboard object edge is inline with the chrome edge. At the moment, I have this working for the left edge but I can't figure out how to do it with the right without causing a slight pop. Please review my example below. http://dev.nimmbl.com/sampler/# winSize[] = document window size (y,x) 2940 = width of artboard object function moveArtboard(e){ var t = docbody.offset(), space = 400, lVal, tVal; lVal = Math.round((space / 2) + (e.pageX - t.left) * (winSize[1] - (2940 + space)) / winSize[1]); tVal = Math.round((space / 2) + (e.pageY - t.top ) * (winSize[0] - (1200 + space)) / winSize[0]); if(lVal >= 0){ artboard.obj.css({ "left": 0, "top": tVal }); } else if(lVal + -winSize[1] <= -2940){ artboard.obj.css({ "left": "auto", "right": 0, "top": tVal }); } else { artboard.obj.css({ "left": lVal, "top": tVal }); } }
0
0
0
0
1
0
The third-party is feeding me 10 percent as the number 10. In my code how do I move the decimal 2 places over for the variable itemDiscountPercent? if (boolActive) { itemDiscountPercent = Math.percent(ogCookie.products[i].discount_percent); itemPrice = ogCookie.products[i].price; itemQty = ogCookie.products[i].quantity; if (itemQty > 1) { itemDiscountPercent = itemDiscountPercent * itemQty; } priceDiscount = itemPrice * itemDiscountPercent; alert(itemDiscountPercent); alert(itemPrice); alert(priceDiscount); } So instead of getting 299.8 for a line item with quantity 2, I need it to be 2.99 so I can subtract it later in the code.
0
0
0
0
1
0
For an educational NLP project I need a list of all Italian words. I thought I would write a crawler that will get the words from www.wordreference.com. I use Python with the mechanize crawler framework. but when i use the code: br = mechanize.Browser() br.open("http://www.wordreference.com/iten/abaco") html = br.response().get_data() print html I get some page from "yahoo.com". is it possible this website has an anticrawler mechanism?
0
1
0
0
0
0
I have 2 questions about bezier curves, and using them to approximate portions of circles. Given the unit circle arc (1,0)->(cos(a),sin(a)) where 0 < a < pi/2, will it result in a good approximation of this arc to find the bezier curve's control points p1, p2 by solving the equations imposed by the requirements B(1/3) = (cos(a/3), sin(a/3)) and B(2/3) = (cos(2a/3), sin(2a/3)). (In other words, requiring that the bezier curve go through two evenly spaced points in the arc). If we have an affine transformation A which turns the circle arc in an ellipse arc will the transformed control points Ap0, Ap1, Ap2, Ap3 define a good bezier approximation to the ellipse arc? p0 and p3, of course, are the start and end points of the curve: (1,0) and (cos(a), sin(a)). Thank you
0
0
0
0
1
0
I am trying to write code to compute the Efield on a point P in both the x and y direction, from a charged ring. double y_eField = (_ke_value * _dq * (Sin_angle) / (Math.Pow(r, r))); Problem I am having is the code seems to follow the equation as given but the result it outputs is not correct at all. Anyone able to help please? I appreciate the help.
0
0
0
0
1
0
I'm quite new to jquery. I've made extensive use of what i've been able to find and understand. However, i'm not sure at all how to tackle this particular problem. I have an integer that manifests as a DOM string in html. Using Jquery, i've set up a contextual menu that displays the numbers +1->+10, and -1->-10. I'm looking for a way to add/subtract the value of an entry of the contextual menu, from the initial integer. For example, i have the initial integer 100, i right click on it, revealing the contextual menu. I go to the -5, and click it. The integer changes to 95.
0
0
0
0
1
0
I have a vector v1 (suppose v1= a1,b2,c1) and this v1 passes through the point x1,y1,z1. Now I need a second vector, v2 which is perpendicular to the v1. Suppose that v2 is passing through the second point x2,y2,z2. However, my final goal is to find the intersection point of above two lines. So, could you help me to find the vector which is perpendicular to another given vector? PLZ Anyone helps me.
0
0
0
0
1
0
I'm practicing up for a programming competition, and i'm going over some difficult problems that I wasn't able to answer in the past. One of them was the King's Maze. Essentially you are given an NxN array of numbers -50<x<50 that represent "tokens". You have to start at position 1,1(i assume that's 0,0 in array indexes) and finish at N,N. You have to pick up tokens on cells you visit, and you can't step on a cell with no token (represented by a 0). If you get surrounded by 0's you lose. If there is no solution to a maze you output "No solution". Else, you output the highest possible number you can get from adding up the tokens you pick up. I have no idea how to solve this problem. I figured you could write a maze algorithm to solve it, but that takes time, and in programming contests you are only given two hours to solve multiple problems. I'm guessing there's some sort of pattern i'm missing. Anyone know how I should approach this? Also, it might help to mention that this problem is meant for high school students.
0
0
0
0
1
0
How do I get cart checkout price exact to the penny using Javascript? Right now after taking out all of the trial .rounds etc I was trying.. I am coming up 1.5 cents too high using a high 15 products/prices to test. for (var i = 0; i < Cookie.products.length; i++) { boolActive = Cookie.products[i].og_active; if (boolActive) { itemPrice = Cookie.products[i].price; itemQty = Cookie.products[i].quantity; itemDiscountPercent = Cookie.products[i].discount_percent; subtotal = itemPrice * itemQty; priceDiscount = (subtotal * itemDiscountPercent); discountAmount += priceDiscount; } } if (!isNaN(discountAmount)) { var newCartTotal = (cartTotal - priceDiscount); alert("New Cart Total: " + newCartTotal); }
0
0
0
0
1
0
I have to implement an intelligent version of Hijara Game in Prolog. You can play the game and learn the rules in the following link: http://www.sapphiregames.com/online/hijara.php I will use Alpha Beta algorithm (up to certain level of the search tree). This is my first experience with Artificial Intelligence and I don't know how to create the evaluation function to be used by the algorithm. I would appreciate very much if anyone could help me Thank you!
0
1
0
0
0
0
I think I'm having a brain fart here... Also, please note, the setTimeout and the hardcoded 6 is just there for testing out the animation right now. It'll end up being in a .load() and do a count on the images. Anyways this code: var imagesLoaded = 0; var loader = function(){ setTimeout(function(){ if(imagesLoaded < 6){ imagesLoaded++; console.log($('.'+settings.loaderClass).width()/imagesLoaded+'px') loader(); } },500) } loader(); Almost works, but the math is the issue. That goes backwards. Fine, so I reverse it like: console.log(imagesLoaded/$('.'+settings.loaderClass).width()+'px') but then I get: 0.0026041666666666665px 0.005208333333333333px 0.0078125px 0.010416666666666666px 0.013020833333333334px 0.015625px And, obviously, that wouldn't work. Whats the math i have to do? Basically the markup is simply: <div class="loader"> <div class="loaderBar"></div> </div> and im just increasing the width of the .loaderBar. Thanks!
0
0
0
0
1
0
How can I calculate the area of a complex object (cylinder for example) with an FEA algorithm with C#? I have data of Elements stored in ".dat" file (cylinder.dat) I can read coordinates of all elements but I don't have any idea how can I calculate the area. Does anyone know what kind of algorithm can solve this problem?
0
0
0
0
1
0
Possible Duplicates: Is JavaScript's Math broken? Java floating point arithmetic I have the current code for(double j = .01; j <= .17; j+=.01){ System.out.println(j); } the output is: 0.01 0.02 0.03 0.04 0.05 0.060000000000000005 0.07 0.08 0.09 0.09999999999999999 0.10999999999999999 0.11999999999999998 0.12999999999999998 0.13999999999999999 0.15 0.16 0.17 Can someone explain why this is happening? How do you fix this? Besides writing a rounding function?
0
0
0
0
1
0
the question is: x dy/dx = 2y ; y(0)=0 because when i solve this problem the integration constant 'c' gets zero... and i have to find its value in order to calculate a solution to given IVP
0
0
0
0
1
0
In computer vision, what would be a good approach to tracking a human in the black and white same scene at different times of the day (i.e. different levels of illumination)? The scene will never be dark so I don't need to worry about searching using infra-red or anything for heat sensing. I need to identify the people and then also track them so there are two parts. Any advice would be great. Thanks.
0
1
0
0
0
0
I have some GPS sample data taken from a device. What I need to do is to "move" the data to the "left" by, let's say, 1 to 5 meters. I know how to do the moving part, the only problem is that the moving is not as accurate as I want it to be. What I currently do: I take the GPS coordinates (latitude, longitude pairs) I convert them using plate carrée transformation. I scale the resulting coordinates to the longitudinal distance (distance on x) and the latitudinal distance (distance on y) - imagine the entire GPS sample data is inside a rectangle being bound by the maximum and minimum latitude/longitude. I compute these distances using the formula for the Great Circle Distance between the extreme values for longitude and latitude. I move the points x meters in the wanted direction I convert back to GPS coordinates I don't really have the accuracy I want. For example moving to the left by 3 meters means less than 3 meters (around 1.8m - maybe 2). What are the known solutions for doing such things? I need a solution that deviates at most by 0.2-0.5 meters from the real point (not 1.2 like in the current case). LATER: Is this kind of approach good? By this kind I mean to transform the GPS coordinates into plane coordinates and back to GPS. Is there other way? LATER2: The approach of converting to a conformal map is probably the one that will be used. In case of a small rectangle, and since there are not roads at the poles probably Mercator will be used. Opinions? Thanks, Iulian PS: I'm working on small areas - so imagine the bounding rectangle I'm talking about to have the length of each side no more than 5 kilometers. (So a 5x5km rectangle is maximum).
0
0
0
0
1
0
I am looking to research an appropriate algorithm for my purpose, can someone suggest a good learning algorithm for the following scenario: A user can search for some word in a set of sentences. I will then return the top 10 sentences based on that keyword, I want the algorithm to allow user input, that is a user can click on the best sentences and this information will help the search algorithm to return more appropriate results in the future.
0
1
0
1
0
0
Imagine a gravity/rotation sensor of iPhone that for each attitude of the device provides a gravity vector (Vg) and a current 3x3 rotation matrix (M0). Such as: Vg * M0 = Vz Vz * Mt = Vg where: Vg - current gravity vector M0 - current rotation matrix Mt - inverse (or actually transpose) matrix of M0 Vz - negative Z-axis vector = { 0, 0, -1 } There is a need to have an option to calibrate the accelometer and gyroscope by all axis that means we would like to store the reference matrix (C0) for the reference gravity vector (Vc) at some moment of time. So: Vc * C0 = Vz Vz * Ct = Vc where: Vc - reference gravity vector C0 - reference rotation matrix Ct - inverse (or actually transpose) matrix of C0 Vz - negative Z-axis vector = { 0, 0, -1 } Now if we will use the reference matrix as a zero-reference one then the calibrated gravity (Vx) or a gravity in relation to the reference one (Vc) is possible to be computed with the composite rotation matrix (X0). So: Vg * X0 = Vc Vc * Xt = Vg --> M0 = X0 * C0 --> X0 = X0 * C0 * Ct --> X0 = M0 * Ct Mt = Ct * Xt --> Xt = C0 * Ct * Xt --> Xt = C0 * Mt --> Vx * X0 = Vz Vz * Xt = Vx where: Vx - computed (calibrated) gravity vector X0 - composite rotation matrix Xt - inverse (or actually transpose) matrix of X0 Vg - current gravity vector M0 - current rotation matrix Mt - inverse (or actually transpose) matrix of M0 Vc - reference gravity vector C0 - reference rotation matrix Ct - inverse (or actually transpose) matrix of C0 Vz - negative Z-axis vector = { 0, 0, -1 } Everything above works perfectly. But there is a problem - by using all formulas above to get the calibrated gravity we will have to first perform the computation of composite matrix for each of the next device attitudes or rotations with usage of the current rotation matrix - that is a way expensive operation. The purpose is to compute a kind of universal recalibration matrix (R0) that could be used to compute the calibrated gravity (Vx) directly from the current gravity (Vg) with only one multiplication and without being dependant on the current rotation matrix (M0) because this current matrix is already included into the current gravity (Vg), such as: Vg * R0 = Vx Vx * Rt = Vg Just applying reference matrix (C0) to the gravity vector (Vg) doesn't work, so: Vg * C0 != Vx Vx * Ct != Vg That happens because Vg = Vz * Mt translates into Vg = Vz * Ct * Xt thus postmultiplying it with C0 wont give us Xt and the resulting vector will be completely odd. Is solution possible?
0
0
0
0
1
0
I need some help with math and OpenGL. I want to make some object follow another one, that is, turn its face to another object every time the former moves. So I learned about glRotate. I thought I would obtain the (x, y, z) of the former everytime it moves and then send its coordinates to another function which should update the 'facing to' property of the latter. But, how do I find the 'angle' parameter to glRotate based on both new and old direction of the follower object? Any help is highly appreciated. Thanks for you time.
0
0
0
0
1
0
Can someone enlighten me on the MeCab default output? what annotation does the MeCab output and where can i find the tagset for the morpho analyzer http://mecab.sourceforge.net/ can anyone decipher this output from MeCab? <s> ブギス・ジャンクション ブギス・ジャンクション ブギス・ジャンクション 名詞-一般 に ニ に 助詞-格助詞-一般 は ハ は 助詞-係助詞 最も モットモ 最も 副詞-一般 買い カイ 買う 動詞-自立 五段・ワ行促音便 連用形 物慣れ モノナレ 物慣れる 動詞-自立 一段 連用形 し シ する 動詞-自立 サ変・スル 連用形 た タ た 助動詞 特殊・タ 基本形 人々 ヒトビト 人々 名詞-一般 を ヲ を 助詞-格助詞-一般 も モ も 助詞-係助詞 魅了 ミリョウ 魅了 名詞-サ変接続 する スル する 動詞-自立 サ変・スル 基本形 品 シナ 品 名詞-一般 揃え ソロエ 揃える 動詞-自立 一段 連用形 が ガ が 助詞-格助詞-一般 あり アリ ある 動詞-自立 五段・ラ行 連用形 ます マス ます 助動詞 特殊・マス 基本形 。 。 。 記号-句点 </s>
0
1
0
0
0
0
Problem: Consider the problem of adding two n-bit binary integers, stored in two n-element arrays A and B. The sum of the two integers should be stored in binary form in an (n + 1)-element array C. State the problem formally and write pseudocode for adding the two integers. Solution: C ← [1 ... n + 1] ▹ C is zero-filled. for i ← 1 to n do sum ← A[i] + B[i] + C[i] C[i] ← sum % 2 C[i + 1] ← sum / 2 ▹ Integer division. output C Question: I thought the C[i] is A[i]+B[i] why are you adding sum ← A[i] + B[i] + C[i] in step 3? why sum % 2 (why need to use modulo in step 4?) why sum / 2 (why need to use division in step 5?) Could you please explain above solution with real example? Thanks.
0
0
0
0
1
0
I want to generate all triples from the graph. All triple from the first "set" would be 1,2,3 and 1,3,2 and 3,2,1. I'm not interested in the other triple of this set ( i.e. 2,1,3 or 3,1,2 ). How can I do this?
0
0
0
0
1
0
I have an NSMutableArray of objects and a property per each object which contains a double. I want to get the Arithmetic Mode (most common value) from the NSMutableArray. What is the fastest way of doing this as it is running through a lot of data.
0
0
0
0
1
0
I'm working on a project where I need to analyze a page of text and collections of pages of text to determine dominant words. I'd like to know if there is a library (prefer c# or java) that will handle the heavy lifting for me. If not, is there an algorithm or multiple that would achieve my goals below. What I want to do is similar to word clouds built from a url or rss feed that you find on the web, except I don't want the visualization. They are used all the time for analyzing the presidential candidate speeches to see what the theme or most used words are. The complication, is that I need to do this on thousands of short documents, and then collections or categories of these documents. My initial plan was to parse the document out, then filter common words - of, the, he, she, etc.. Then count the number of times the remaining words show up in the text (and overall collection/category). The problem is that in the future, I would like to handle stemming, plural forms, etc.. I would also like to see if there is a way to identify important phrases. (Instead of a count of a word, the count of a phrase being 2-3 words together) Any guidance on a strategy, libraries or algorithms that would help are appreciated.
0
1
0
0
0
0
Im doing a Java application where I'll have to determine what are the Trending Topics from a specific collection of tweets, obtained trough the Twitter Search. While searching in the web, I found out that the algorithm defines that a topic is trending, when it has a big number of mentions in a specific time, that is, in the exact moment. So there must be a decay calculation so that the topics change often. However, I have another doubt: How does twitter determines what specific terms in a tweet should be the TT? For example, I've observed that most TT's are hashtag or proper nouns. Does this make any sense? Or do they analyse all words and determine the frequency? I hope someone can help me! Thanks!
0
1
0
0
0
0
I am new in AI(Artificial Intelligence) learning Version spaces and i need help in solving sum tasks. Am using a software which will do the learning process so my task is to learn and understand what is going on(i mean why the software produces such results) and etc.. My task is i have a brand of cars: Brand Likes _____ _____ opel yes toyota no bmw yes ford yes nissan no and my questions are: 1)how can i learn which car brand a person likes? my understanding is the first brand(opel) in the examples should be positive(yes) or? 2) how can i learn which car brand a person dislikes? should i make the first brand negative(no)? 3) how can i create two hierarchies so that they can be used to learn which car brands a person likes and which ones he dislikes? UPDATE I need help for the following requirements also: 1) Make up two different hierarchies for learning the examples that both hierarchies allow you to learn which brand the person likes, while learning which brands the person dislikes can be learned with only one hierarchy and cannot be learned with the other hierarchy. 2) What can you be concluded about when it is possible to learn the opposite concept and when not? Please am learning how the thing works so be patient with me. thanks thanks for your help.
0
1
0
1
0
0
This page has a simple alert: alert(185.3 + 12.37); To me, that should equal 197.67 However, in the browsers I've tested (Chrome/Safari on OSX, FF on Win7) the answer is: 197.67000000000002 Why is that? Is this just a known bug or is there more to JavaScript addition than I realize?
0
0
0
0
1
0
I'm writing some code that iterates a set of POS tags (generated by pos_tag in NLTK) to search for POS patterns. Matching sets of POS tags are stored in a list for later processing. Surely a regex-style pattern filter already exists for a task like this, but a couple of initial google searches didn't give me anything. Are there any code snippets out there that can do my POS pattern filtering for me? Thanks, Dave EDIT: Complete solution (using RegexParser, and where messages is any string) text = nltk.word_tokenize(message) tags = nltk.pos_tag(text) grammar = r""" RULE_1: {<JJ>+<NNP>*<NN>*} """ chunker = nltk.RegexpParser(grammar) chunked = chunker.parse(tags) def filter(tree): return (tree.node == "RULE_1") for s in chunked.subtrees(filter): print s Check out http://nltk.googlecode.com/svn/trunk/doc/book/ch07.html and http://www.regular-expressions.info/reference.html for more on creating the rules.
0
1
0
0
0
0
I have the compute the sum S = (a*x + b*y + c) % N. Yes it looks like a quadratic equation but it is not because the x and y have some properties and have to be calculated using some recurrence relations. Because the sum exceeds even the limits of unsigned long long I want to know how could I compute that sum using the properties of the modulo operation, properties that allow the writing of the sum something like that(I say something because I do not remember exactly how are those properties): (a*x)%N + (b*y)%N + c%N, thus avoiding exceeding the limits of unsigned long long. Thanks in advance for your concern! :)
0
0
0
0
1
0
Having fnc: bool ISINTREE( int x, BinTree<int> t) { bool b = false if (!t.isEmpty()) { if (x == t.getRoot()) { b = true } else { if (ISINTREE(x,t.leftTree())) { b = true } if (ISINTREE(x,t.rightTree())) { b = true } } } return b } How to prove (using mathematical induction) that T(n)= 11 × 2^n − 7 is a solution of the recurrence system for this fnc. EDITED Let F(n) = 11*2^n – 7 Now, for k>0 T(k-1) = F(k-1) = 11*2^(k-1)-7 T(k) = 7+2*(T(k-1)) =7 + 2 * (11*2^(k-1) -7) = 11*2^k -7
0
0
0
0
1
0
There is a byte [01100111] and I've to break it in such way [0|11|00111] so after moving parts of this byte into different bytes I'll get: [00000000] => 0 (in decimal) [00000011] => 3 (in decimal) [00000111] => 7 (in decimal) I've try to do that with such code: byte b=(byte)0x67; byte b1=(byte)(first>>7); byte b2=(byte)((byte)(first<<1)>>6); byte b3=(byte)((byte)(first<<3)>>3); But I got: b1 is 0 b2 is -1 //but I need 3.... b3 is 7 Where I've mistake? Thanks
0
0
0
0
1
0
What is an efficient way to compute pq, where q is an integer?
0
0
0
0
1
0
I have a dataset composed of millions of examples, where each example contains 128 continuous-value features classified with a name. I'm trying to find a large robust database/index to use to use as a KNN classifier for high-dimensional data. I tried Weka's IBk classifier, but it chokes on this much data, and even then it has to be loaded into memory. Would Lucene, specifically through the PyLucene interface, be a possible alternative? I've found Lire, which seems to use Lucene in a similar way, but after reviewing the code, I'm not sure how they're pulling it off, or if it's the same thing I'm trying to do. I realize Lucene is designed as a text indexing tool, and not as a general purpose classifier, but is it possible to use it in this way?
0
0
0
1
0
0
I tried the code below, which draws a good approximation of a circle if the rectangle's width is the same as its height; but it doesn't draw a great oval, the "corners" are very pointed. Any suggestions? float width = rect.width(); float height = rect.height(); float centerX = rect.width() / 2; float centerY = rect.height() / 2; float diameter = Math.min(width, height); float length = (float) (0.5522847498 * diameter/2); path.moveTo(0, centerY); path.cubicTo(0, centerY - length, 0, centerX - length, 0, centerX, 0); path.cubicTo(centerX + length, 0, width, centerY - length, height, centerY); path.cubicTo(width, centerY + length, centerX + length, height, centerX, height); path.cubicTo(centerX - length, height, 0, centerY + length, 0, centerY);
0
0
0
0
1
0
I was surfing the net looking for a nice effect for turning pages on Android and there just doesn't seem to be one. Since I'm learning the platform it seemed like a nice thing to be able to do is this. I managed to find a page here: http://wdnuon.blogspot.com/2010/05/implementing-ibooks-page-curling-using.html - (void)deform { Vertex2f vi; // Current input vertex Vertex3f v1; // First stage of the deformation Vertex3f *vo; // Pointer to the finished vertex CGFloat R, r, beta; for (ushort ii = 0; ii < numVertices_; ii++) { // Get the current input vertex. vi = inputMesh_[ii]; // Radius of the circle circumscribed by vertex (vi.x, vi.y) around A on the x-y plane R = sqrt(vi.x * vi.x + pow(vi.y - A, 2)); // Now get the radius of the cone cross section intersected by our vertex in 3D space. r = R * sin(theta); // Angle subtended by arc |ST| on the cone cross section. beta = asin(vi.x / R) / sin(theta); // *** MAGIC!!! *** v1.x = r * sin(beta); v1.y = R + A - r * (1 - cos(beta)) * sin(theta); v1.z = r * (1 - cos(beta)) * cos(theta); // Apply a basic rotation transform around the y axis to rotate the curled page. // These two steps could be combined through simple substitution, but are left // separate to keep the math simple for debugging and illustrative purposes. vo = &outputMesh_[ii]; vo->x = (v1.x * cos(rho) - v1.z * sin(rho)); vo->y = v1.y; vo->z = (v1.x * sin(rho) + v1.z * cos(rho)); } } that gives an example (above) code for iPhone but I have no idea how I would go about implementing this on android. Could any of the Math gods out there please help me out with how I would go about implementing this in Android Java. Is it possible using the native draw APIs, would I have to use openGL? Could I mimik the behaviour somehow? Any help would be appreciated. Thanks. ****************EDIT********************************************** I found a Bitmap Mesh example in the Android API demos: http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/BitmapMesh.html Maybe someone could help me out on an equation to simply fold the top right corner inward diagnally across the page to create a similar effect that I can later apply shadows to to gie it more depth?
0
0
0
0
1
0
i am trying to compile my program where i am using the functions like sqrt pow and fabs. I do have math.h included but for some reason i get errors like: error C2668: 'fabs' : ambiguous call to overloaded function same for the rest of the functions i have this included: #include "stdafx.h" #include "math.h" i tried including but still same errors. Does anyone know why they are not being recognized? my file is .cpp not .c but it is an MFC project. thanks
0
0
0
0
1
0
Is there an artificial intelligence (AI) programming framework for game software engineers? I'm specifically looking for a library of object-oriented classes that I can use in a game. Specifically, I would like to know the best way to program NPC decision making that is purely object oriented. I have googled and gotten a lot of useless links to machine learning and theoretical AI websites that have absolutely nothing to do with practical software engineering. Any frameworks I've found are all either out of date or too academic to be useful. Specifically, I'm looking for Java or Objective-C libraries.
0
1
0
0
0
0
Say I have a bunch of hotel rooms, suitable for 1,2 or 3 persons. A group of 4 persons would like to book and I want to present them with all the possible configurations, since different configurations have different prices. Possible combinations include: 4 * 1 person room 2 * 2 person room 1 * 3 person room + 1 * 1 person room etcetera, etcetera How would I go about calculating the different groupings? An added complexity is that some of these persons may be children, which should always be combined with adults in a room. I figured I should just calculate all combinations and filter out the ones who don't satisfy this constraint. Any hints, tips or pointers?
0
0
0
0
1
0
I have a problem drawing different functions with PHP (GD, of course). I managed to draw different functions but whenever the parameters of the function change - the function floats wherever it wants. Let us say that I have a first function y=x^2 and I have to draw it from -5 to 5. This means that the first point would be at (-5;25). And I can move that to whatever point I want if I know that. But if I choose y=2x^2 with an interval x=(-5;5). The first point is at (-5;50). So I need help in calculating how to move any function to, let's say, (0;0). The functions are parabola/catenary alike.
0
0
0
0
1
0
I'm trying to load an external page which contains a table like this: <table id="uniquedatatable"> <tr class="row"> <td class="num col"><a> 1 </a></td> <td class="str col"><a>Text</a></td> <td class="num col"><a> 7</a></td> <td class="str col"><a>Text</a></td> </tr> </table> *Notice the whitespace's in the class names of the td's and around the numbers (1,7). I need to find all cell's (td's) with class "num col", get the numeric value between the a tag'a and sum all the values. Last I need to display this value on my own page. So the result I would get from the above table should be: 1 + 7 = 8. I've gotten this far: <script src="http://code.jquery.com/jquery-1.5.1.min.js" type="text/javascript"></script> <p id="result"></p> <script type="text/javascript"> var url = "http://someurl"; var sum = 0; $('#result').load('url #uniquedatatable tr td.num col a', function() { sum += Number($(this).text()); }); _gel('result').innerHTML = sum; </script> Realizing something is wrong (close to being correct I hope :)), I need help connecting the "dots" here so that I can: Calculate the sum (this is the "big" problem :S) Write the result back. Any help is appreciated.
0
0
0
0
1
0
http://i52.tinypic.com/5mmjoi.png <- take a peek here for the equations Well, I've been studying matrices lately as I was interested more into the workings of changes of coordinate systems, obj->world and such. And I am looking at this couple of equations which are trying to interpret the vector-matrix multiplication as a linear combination of the matrix's row vectors scaled by the individual components of the u vector. I do understand that they are just "reshaping" it into a few components, scaling the basis vectors of the translated coordinate system. The standard vector product is exactly the same as the combined row vectors scaled by x,y,z. It's more intuitive to see it when it is decomposed as such than just vague multiplications of the y coordinate with the second vector's x coordinate in the standard version and then added to the z and x values, how the dot product dictates. My question is: How does one know what alterations are allowed, he just simply picks out the parts of the solution vector, sorting it by x, y and z. Do you simply do that or are there rules. The result certainly is correct, he has all the stuff necessary for a linear combination but how does he know what can and can't he touch? A little more elaboration, even from the top, would be appreciated? Basically how and why does this work? Thanks everyone!
0
0
0
0
1
0
I have the current code: Public Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long <DllImport("user32.dll", SetLastError:=True, CharSet:=CharSet.Auto)> _ Private Shared Function SendMessage(ByVal hWnd As HandleRef, ByVal Msg As UInteger, ByVal wParam As IntPtr, ByVal lParam As String) As IntPtr End Function Declare Auto Function SendMessage Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr Public Function WindowHandle(ByVal sTitle As String) As Long WindowHandle = FindWindow(vbNullString, sTitle) End Function Dim CurrentProcess As Process Dim CurrentHandle As IntPtr Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick SendMessage(CurrentHandle, 256, Keys.A, 0) SendMessage(CurrentHandle, 257, Keys.A, 65539) End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Try CurrentProcess = Process.GetProcessesByName(ListBox1.SelectedItem.ToString.Remove(0, ListBox1.SelectedItem.ToString.IndexOf("{") + 1).Replace("}", ""))(0) CurrentHandle = New IntPtr(WindowHandle(CurrentProcess.MainWindowTitle)) Timer1.Start() Catch ex As Exception MsgBox(ex.Message) End Try End Sub If you take a look at the button sub, every time it runs, it errors with "Arithmetic overflow error!" What is wrong here? This should work... right? Sorry, this is a bit vague but it's as much as I know.
0
0
0
0
1
0
Given point a point a (x1,y1) and a point c (x3,y3) we can calculate a slope m. Assuming we have a distance d I'm a bit stuck trying to figure out how to find a point b (x2,y2) which is d distance from x1,y1 in the direction of c. Does anyone know how to calculate this? I thought about using the midpoint function but it's not quite there. Help?
0
0
0
0
1
0
So far I have double futurevalue = moneyin * (1+ interest) * year;
0
0
0
0
1
0
A twist on the classic sudoku solver that I've recently run into is the (rather crazy) inequality sudoku, which is your classic sudoku puzzle with the added twist that there are inequality conditions added to each box. Now, I've managed to scratch out a regular sudoku solver in Python (using a brute-force method), but I'm having trouble grasping what methods I would use to tackle this problem. Am I overthinking it or is this much more complicated than a normal puzzle?
0
0
0
0
1
0
I am using OdePkg in Octave to solve a system of stiff ODEs, e.g. by ode5r: function yprime = myODEs(t,Y,param) yprime = [ - param(1) * Y(1); # ODE for Y(1) param(1) * Y(1) - param(2) Y(2) * Y(3); # ODE for Y(2) param(2) Y(2) * Y(3) # ODE for Y(3) # etc. ]; time_span = [1, 24] # time span of interest Y0 = [1.0, 1.1, 1.3] # initial values for dependent variables Y param = [7.2, 8.6, 9.5] # parameters, to be optimized [t, Y] = ode5r(@myODEs, time_span, Y0, ..., param); The solver stores the dependent variables Y in a matrix with respect to time t (vector): t Y(1) Y(2) Y(3) 0.0 1.0 1.1 1.3 0.1 ... ... ... 0.5 ... ... ... 0.9 ... ... ... ... ... ... ... 4.0 ... ... ... ... ... ... ... 24.0 ... ... ... I want to fit the parameters in param, so that the resulting variables Y best fit my reference values, e.g.: t Y(1) Y(2) Y(3) 0.5 1.1 N/A N/A 1.0 1.9 N/A N/A 4.0 2.3 2.7 2.1 5.0 N/A 2.6 2.2 24.0 0.9 1.5 2.0 Which Octave/Matlab (other languages are welcome) routine can perform a multi-parameter (least square / spline) fit? How is it possible to combine parameter sets for different initial values Y0 in the fit? I would be glad if you could provide me with some hints and possibilities. Best regards, Simon
0
0
0
0
1
0
Say theoretically you just generate random numbers [using standard libraries] in as many threads as you can [bound by hardware]. How fast would C++ over Java? no disk i/o, memory or gc. Just pure Math.random() calls across threads.
0
0
0
0
1
0
I am trying to convert the following sentence to a well formed formula using first-order logic(Predicate logic). All towers are of the same color. I have defined the following predicates: Tower(x) :: x is a tower. Color(x, y) :: x is of color y I am not able to convert the aforementioned sentence into a well formed formula using the above predicates. Is it possible to convert it using the above predicates or some new predicate should be required. Please advise. EDIT: Forgot to add a detail. There are only three available colours in the world (red, green, blue). Can this detail be used. Does that make any difference to the solution?
0
1
0
0
0
0
have you got your maths hat on ? I am doing some credit card processing work, and i need to on-charge the bank service fee as a convenience fee to the customer. If i sell something for $100 and i get charged 3% of my total transaction as a bank service fee. How much do i need to charge in total to make sure i still end up with $100 in my hand (after the bank has taken their 3% fee away) So anyway I need a formula that I can use that will handle different sales amounts and percentages to calculate the correct surcharge to pass on hope that makes sense This was my first attempt, it works fine for small numbers but for large amounts (eg $5000) it is wrong $surcharge = ($total + ($total * $rate)) * $rate; Here is an example for those that say just add the bank pct on $sale = $100 $pct_rate = 0.03; $surcharge = $sale * $pct_rate; $total = $100 + surcharge ; // =103 // test it $moneyinthehand = 103 - (103 * $rate); // moneyinthehand = $99.91 (which is not $sale price)
0
0
0
0
1
0
I have a table created using the table() command in R: y x 0 1 2 3 4 5 6 7 8 9 0 23 0 0 0 0 1 0 0 0 0 1 0 23 1 0 1 0 1 2 0 2 2 1 1 28 0 0 0 1 0 2 2 3 0 1 0 24 0 1 0 0 0 1 4 1 1 0 0 34 0 3 0 0 0 5 0 0 0 0 0 33 0 0 0 0 6 0 0 0 0 0 2 32 0 0 0 7 0 1 0 1 0 0 0 36 0 1 8 1 1 1 1 0 0 0 1 20 1 9 1 3 0 1 0 1 0 1 0 24 This table shows the results of a classification, and I want to sum the leading diagonal of it (the diagonal with the large numbers - like 23, 23, 28 etc). Is there a sensible/easy way to do this in R?
0
0
0
1
0
0
A numeric string ([0-9A-F]+) is given. What's the probability that it's a hexadecimal number?
0
0
0
0
1
0
I would like a web interface for a user to describe a one-dimensional real-valued function. I'm imagining the user being presented with a blank pair of axes and they can click anywhere to create points that are thick and draggable. Double-clicking a point, let's say, makes it disappear. The actual function should be shown in real time as an interpolation of the user-supplied points. Here's what this looks like implemented in Mathematica (though of course I'm looking for something in javascript): (source: yootles.com)
0
0
0
0
1
0
I'm trying to integrate django-registration with django-math-captcha, but I'm running into troubles. I followed the examples math captcha's github. If I subclass registration.forms.RegistrationForm with MathCaptchaModelForm or MathCaptchaForm I get different errors My code and respective errors class RegistrationForm(forms.Form, MathCaptchaModelForm) Error: Error when calling the metaclass bases metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases or class RegistrationForm(forms.Form, MathCaptchaForm) Error:Error when calling the metaclass bases. Cannot create a consistent method resolution order (MRO) for bases Form, MathCaptchaForm Thanks for your help!
0
0
0
0
1
0
I am looking for a way to compare a user submitted audio recording against a reference recording for comparison in order to give someone a grade or percentage for language learning. I realize that this is a very un-scientific way of doing things and is more than a gimmick than anything. My first thoughts are some sort of audio fingerprinting, or waveform comparison. Any ideas where I should be looking?
0
0
0
1
0
0
Is there an algorithm that can solve a non-linear congruence in modular arithmetic? I read that such a problem is classified as NP-complete. In my specific case the congruence is of the form: x^3 + ax + b congruent to 0 (mod 2^64) where a and b are known constants and I need to solve it for x.
0
0
0
0
1
0
What went wrong? [1]> (log (exp 1)) 0.99999994
0
0
0
0
1
0
I have a collection of QList<int>'s that I need to calculate the union of. Is there a built in function anywhere that does this for me? If not, are there any special considerations that I should make when implementing this myself?
0
0
0
0
1
0
Yesterday, an interesting question comes to mind, Given N points, how do you find the maximum number of points that are on a circle? Can you suggest anything other than brute-force? What is O(?)?
0
0
0
0
1
0
Given A set of numbers n[1], n[2], n[3], .... n[x] And a number M I would like to find the best combination of n[a] + n[b] + n[c] + ... + n[?] >= M The combination should reach the minimum required to reach or go beyond M with no other combination giving a better result. Will be doing this in PHP so usage of PHP libraries is ok. If not, just a general algorithm will do. Thanks!
0
0
0
0
1
0
hello I want to round an amount in javascript but unable to do and totally stuck. My scenario is, I have a base amount and marukup % on base. On the basis of these two I want to calculate total amount. I have calculated the amount but i want to round the result. I have used following formula amount=base+((base/100)*markup This formula always give me result without decimal point. I want to get exact amount upto two decimal points. I have used math.round like this amount=math.round(base+((base/100)*markup).toFixed(2) but it always return result without decimal point. For example my base value is 121 and markup is 5%. The amount should be 127.05 . But above formula always returns 127. Any guidelines?
0
0
0
0
1
0
I want to compute scores for some data I have in a MySQL database. The score will be computed as follows: score = COUNT(purchases MADE BETWEEN NOW() AND (NOW() - 1 WEEK)) + 0.7 * COUNT(purchases MADE BETWEEN (NOW() - 1 WEEK) AND (NOW() - 2 WEEKS)) + 0.4 * COUNT(purchases OLDER THAN (NOW() - 2 WEEKS)) I have purchses in a table with a purchase_time column. Is it possible to do this in MySQL and get output similar to the following? ORDER_ID SCORE 3 8 4 3 5 15 Thanks --- EDIT --- The table structure is: tblOrder - table id - primary key created - time stamp
0
0
0
0
1
0
I'd like to know if there is any good (and freely available) text, on how to obtain motion vectors of macro blocks in raw video stream. This is often used in video compression, although my application of it is not video encoding. Code that does this is available in OSS codecs, but understanding the method by reading the code is kinda hard. My actual goal is to determine camera motion in 2D projection space, assuming the camera is only changing it's orientation (NOT the position). What I'd like to do is divide the frames into macro blocks, obtain their motion vectors, and get the camera motion by averaging those vectors. I guess OpenCV could help with this problem, but it's not available on my target platform.
0
0
0
0
1
0
I'm using spreading-activation to get related concepts to a given one. If I want to calculate the similarity between 'London' and 'Paris', I get 2 vectors such as: vector for 'Paris': Paris : 1.0 City : 0.9 Capital : 0.7 France : 0.6 Europe : 0.5 ... vector for 'London': London : 1.0 City : 0.9 England : 0.9 United Kingdom : 0.8 Europe : 0.5 ... The issue is that the vectors can have different lengths. What similarity measure can be used in this situation? As far as I know the cosine measure can be applied only on vectors having the same size. I found these packages: SimMetrics: http://staffwww.dcs.shef.ac.uk/people/S.Chapman/simmetrics.html and COLT: http://nlp.stanford.edu/nlp/javadoc/colt-docs/overview-summary.html How is it possible to use them in my scenario? Thanks! Mulone
0
0
0
0
1
0
Possible Duplicate: Java: Parse a mathematical expression given as a string and return a number Hello there, I would like to ask you, if exist some way how to convert string "1+2+3" to math equation? Exist for this purpose some function or method in Java? Thanks for hints.
0
0
0
0
1
0
I'm going to ask this question using Scala syntax, even though the question is really language independent. Suppose I have two lists val groundtruth:List[Range] val testresult:List[Range] And I want to find all of the elements of testresult that overlap some element in groundtruth. I can do this as follows: def overlaps(x:Range,y:Range) = (x contains y.start) || (y contains x.start) val result = testresult.filter{ tr => groundtruth.exists{gt => overlaps(gt,tr)}} But this takes O(testresult.size * groundtruth.size) time to run. Is there a faster algorithm for computing this result, or a data structure that can make the exists test more efficient? P.S. The algorithm should work on groundtruth and testresult generated with an expression like the following. In other words, there are no guarantees about the relationships between the ranges within a list, the Ranges have an average size of 100 or larger. (1 to 1000).map{x => val midPt = r.nextInt(100000); ((midPt - r.nextInt(100)) to (midPt + r.nextInt(100))); }.toList
0
1
0
0
0
0
alert(Math.cos(Math.PI/2)); Why the result is not exact zero? Is this inaccurancy, or some implementation error?
0
0
0
0
1
0
there is a matrix library for java available http://math.nist.gov/javanumerics/jama/ is there anything similar in groovy?
0
0
0
0
1
0
I have to use a round method that follows this behavior: 7.00 -> round -> 7 7.50 -> round -> 7 7.51 -> round -> 8 I tried to use Math.Round, but it works a little bit different. Dim val As Decimal = 7.5 Dim a As Decimal = Math.Round(val, 0) ' -> 8 Dim b As Decimal = Math.Round(val, 0, MidpointRounding.AwayFromZero) ' -> 8 Dim c As Decimal = Math.Round(val, 0, MidpointRounding.ToEven) ' -> 8 How can I implement my rounding logic?
0
0
0
0
1
0
This is a part of my AI project. I have to implement a bot, which occupies a square, in a field of LXW squares. If a square in the field is empty, it has value 0, if it is occupied by an object, its value is 1. A continuous set of squares with value 1 is called an object. I have to figure out the identity and location of all objects in the field I have the following info : sense() : this function returns occupancy status of my neighbouring 8 squares move(x) : allows me to move to a neighbouring square in x direction getId(x) : gives me id of object in x direction wrt me, and if there is no object, returns -1 However, whenever I call a sense or getID function, the object can move to a different position with a small probability I was thinking of using BFS to traverse the grid. Or would it be better to keep a list of already traversed positions and move randomly? What are some of the AI techniques that I could use to solve this problem? How about some planning techniques?
0
1
0
0
0
0
I wonder if there is an elegant way to derive all compositions of 2n as the sum of n non-negative integer variables. For example, for n = 2 variables x and y, there are 5 compositions with two parts : x = 0 y = 4; x = 1 y = 3; x = 2 y = 2; x = 3 y = 1; x = 4 y = 0 such that x + y = 4 = 2n. More generally, the problem can be formulated to find all the compositions of s into n non-negative integer variables with their sum equals to s. Any suggestion on how to compute this problem efficiently would be welcome, and some pseudo-code would be much appreciated. Thanks. Edit: while solutions are presented below as in Perl and Prolog, a Java implementation may present a new problem as linear data structures such as arrays need to be passed around and manipulated during the recursive calls, and such practice can become quite expensive as n gets larger, I wonder if there is an alternative (and more efficient) Java implementation for this problem.
0
0
0
0
1
0
There is a "simple" plain math formula for data alignment contained in the assembly source code of TinyPE, from this address: http://www.phreedom.org/solar/code/tinype/ This is the formula: %define round(n, r) (((n+(r-1))/r)*r) I know that its main intention is to get numbers like n=31 aligned to something like round(n,r)==32 when r=8. I know that n represents the intended number and r is the rounding "base" multiple. I also know that, given it is simple assembly source code, all operations return integer numbers only, so any decimals are conveniently lost and thus don't cause any calculation "errors". The question is whether the following explanation is accurate, or if there is a better, more correct one. I don't want to blindly use a snippet I could be misunderstanding somehow. Also, I would have liked to use number+(round%(number%round)), but it causes division by zero when "number" is an exact multiple of "round". This formula gets the nearest multiple of a number which is power of two: In this example our number is 31 and the number we want to have as "base" multiple is 8. It returns 32: (((31+(8-1))/8)*8) First we get 8-1, which gives 7. We add it to 31, which gives 38. Then we divide 38/8, which gives 4.75. From this, the integer value is 4. This 4 is multiplied by 8, which gives 32. The logical/mathematical intention of each of these formula parts is as follows: -- The 8-1 parts makes that an excess be present, whether the original number (in this case 31) is a multiple or not of the base rounding number (in this case 8), and that gives a range that goes through 7 non-multiple numbers and a possible multiple. The -1 causes that we don't get the wrong calculation by going right to the next non-nearest multiple but it just gives an inexact margin to detect the rest of previous "factors". -- By dividing this exceeded number by the base multiple (8 in this case), in its integer part, we get only the previous factors. The excess that we add to it makes that the number gets aligned to the nearest multiple, if it's within the immediate range without going up to two multiples ahead (hence the -1). -- By multiplying the purely integer part of this factor (4 in this case) by the base multiple r (8 in this case), we get the exact nearest multiple, without going to the next one. For instance the nearest multiple of 8, starting from 31, is 32, not 40.
0
0
0
0
1
0
I have a rectangle (called the target) and want to place another rectangle (called the satellite) alongside. The satellite has a position (top, bottom, left, right) that determines the placement edge relative to the target. It also has an alignment that (left, center, right for top and bottom position, top, middle and bottom for left and right position). Example: +----------+----------------------------+ | | | | Target | Satellite, Position=RIGHT, | | | Align=TOP | | | | | |----------------------------+ | | +----------+ I know the top left coordinates of the target and also its width and height. I also know the width and height of the satellite and want to calculate the top left coordinates of it. I could do that as a series of 12 if clauses, but maybe there is a more elegant, mathematical or algorithmic way to do it. Is there an alternative way to this: # s = satellite, t = target if pos == "top" && align == "left" s.x = t.x s.y = t.y - s.height else if pos == "top" && align == "center" s.x = t.x + t.width / 2 - s.width / 2 s.y = t.y - s.height # etc, etc Any good solutions in Ruby or JavaScript?
0
0
0
0
1
0
I have a set of points that form a path. I would like to determine the minimum distance from any given point to this path. The path might look something like this: points = [ [50, 58], [53, 67], [59, 82], [64, 75], [75, 73] ]; where the first value is the x coordinate and the second the y coordinate. The path is open ended (it will not form a closed loop) and is made of straight segments between the points. So, given a point, eg. [90, 84], how to calculate the shortest distance from that point to the path? I'm not necessarily looking for a complete solution, but any pointers and ideas will be appreciated.
0
0
0
0
1
0
This should be a bit of simple geometry: How do I calculate the points to draw the lines in the code below so that it makes a 2D cone or wedge shape? import flash.geom.Point; //draw circle var mc=new Sprite() mc.graphics.lineStyle(0,0) mc.graphics.drawCircle(0,0,30) mc.x=mc.y=Math.random()*300+100 addChild(mc) //draw lines: graphics.lineStyle(0,0) var p=new Point(Math.random()*500,Math.random()*400) graphics.moveTo(p.x, p.y) graphics.lineTo(mc.x,mc.y) // << should be point on edge of circle graphics.moveTo(p.x, p.y) graphics.lineTo(mc.x,mc.y) // << should be point on opposite edge of circle UPDATE: Thanks guys, I should have mentioned my aim is not to draw a wedge shape, but to draw a line from a random point to the edge of an existing circle. If you're more comfortable with algebra than actionscript, maybe you could have a look at this graphic and post a formula for me?
0
0
0
0
1
0
I have a matrix with n columns, n rows and every element is initialized with 0. I want to select the largest circle in that matrix, and set the values to 1. 000010000 000111000 000111000 001111100 011111110 The drawing isnt't very artistic (or correct)... 001111100 matrix: 9*9 000111000 largest circle 000111000 000010000 Can you help me with the java algorithm ? Language: Java Thank you, Horatiu
0
0
0
0
1
0
As a follow-up to this question: I was in the process of implementing a calculator app using Apple's complex number support when I noticed that if one calculates using that support, one ends up with the following: (1+i)^2=1.2246063538223773e-16 + 2i Of course the correct identity is (1+i)^2=2i. This is a specific example of a more general phenomenon -- roundoff errors can be really annoying if they round a part that is supposed to be zero to something that is slightly nonzero. Suggestions on how to deal with this? I could implement integer powers of complex numbers in other ways, but the general problem will remain, and my solution could itself cause other inconsistencies.
0
0
0
0
1
0
So this is in a way connected to my problem with drawing the energy levels etc. link to the problem. Anywho, I was using discretization to get the energy levels and wave functions for various potentials, and I'm probably a tool in programming, because I have no idea how to get the numerical result for the energy eigenvalues. I have a strong sense that it has to be possible to just extract that information from the given code (the code has eig_banded routine from linalg module). But I'm just a tool and cannot figure how to do it :\ So I just need the numerical value of the energy that I draw... I tried with (this is a part of the code from the link): def calc(Nmesh,POWER,L ,numwav=0): # dx=L/Nmesh x = np.arange(-L,L+0.0001,dx) Npts=len(x) V = x**POWER # ai = np.empty((2,Npts)) # ai[:,i] = a[:,i-1] ai[0,:] = 1/dx**2 + V # ai[1,:] = -1.0/dx**2/2 # ai[1,Npts-2] = -99.0 # a = ai[:,1:-1] f = report_time(linalg.eig_banded) eig, vec = f(a, lower=True,overwrite_a_band=True, select='i',select_range=(0,numwav) ) # wave = np.empty(Npts) wave[1:-1] = vec[:,numwav] wave[0] = 0 # wave[Npts-1] = 0 # wave = 150*wave + eig[numwav] return x, V, wave, eig[numwav] def main(): try: numwav = int(sys.argv[1]) except (IndexError, ValueError): numwav = 2 POWER=4 L=4.0 Nmesh = 512 print 'Nmesh=%d' % Nmesh x, V, wave, y = calc(Nmesh, POWER, L,numwav) print 'Energy eigenvalue is: %d' % y But for this instance it will give that eigenvalue is 4, and on the plot it's closer to the 4.76... What am I doing wrong? :(
0
0
0
0
1
0