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
In a company, there are three categories: A,B,C. They want to give an increment. So if category C gets N% as increment. category B gets 2N% as increment and category A gets 3N% as increment. But the increment should be atleast 1% and The total updated salary should not exceed $50,000. Print the increment and the total updated salary for a particular employee. Assume all the required variables. How do I solve the above, there seem to be many unknown parameters like SALARY A, SALARY B, SALARY C, and increment N. looking for the maximum possible value of N within the restriction
0
0
0
0
1
0
I have a list of (about 200-300) 2d points. I know needs to find the polygon that encloses all of them. The polygon has to be convex, and it should be as complex as possible (i.e. not a rectangular bounding box). It should find this in as low as possible time, but there are no restrictions on memory. You may answer in pseudocode or any language you want to use.
0
0
0
0
1
0
(source: roughnotebook at sites.google.com) I need to switch from the XY co-ordinate system shown above to the X'Y' co-ordinate system using System::Drawing::Drawing2D (i.e. GDI+). This is what I have in mind: float rotation = // +90 below is because AB is the new vertical... Math::Atan2(pB.Y - pA.Y, pB.X - pA.X) * 180.0 / Math::PI + 90.0f; Matrix m; m.Translate(pA.X, pA.Y); m.Rotate(rotation); m.Invert(); array<PointF> points = gcnew array<PointF>{ pC }; m.TransformPoints(points); Is there a way to do this while minimizing rounding errors? Can I avoid the Atan2 (or other inverse trigonometric function) call here?
0
0
0
0
1
0
i want to compare do simple math in django template like {% forloop.counter > 5 %} {% endfor %} how do i achieve this?
0
0
0
0
1
0
i am researcher student. I am searching large data for knapsack problem. I wanted test my algorithm for knapsack problem. But i couldn't find large data. I need data has 1000 item and capacity is no matter. The point is item as much as huge it's good for my algorithm. Is there any huge data available in internet. Does anybody know please guys i need urgent.
0
1
0
0
0
0
I'm a c# noob but I really need a professional's help. I am using visual studio 2005 for a project so I don't have math.linq I need to calculate the standard deviation of a generic list of objects. The list contains just a list of float numbers, nothing too complicated. However I have never done this before so i need someone to show me that has calculated standard deviation of a generic list before. Here is my code that I tried to start on: //this is my list of objects inside. The valve data just contains a bunch of floats. public class ValveDataResults { private List<ValveData> m_ValveResults; public void AddValveData(ValveData valve) { m_ValveResults.Add(valve); } //this is the function where the standard deviation needs to be calculated: public float LatchTimeStdev() { //below this is a working example of how to get an average or mean //of same list and same "LatchTime" that needs to be calculated here as well. } //function to calculate average of latch time, can be copied for above st dev. public float LatchTimeMean() { float returnValue = 0; foreach (ValveData value in m_ValveResults) { returnValue += value.LatchTime; } returnValue = (returnValue / m_ValveResults.Count) * 0.02f; return returnValue; } } The "Latch Time" is a float object of the "ValveData" object which is inserted into the m_ValveResults list. That's it. Any help would much be appreciated. Thanks
0
0
0
0
1
0
Consider the problem of counting the number of structurally distinct binary search trees: Given N, find the number of structurally distinct binary search trees containing the values 1 .. N It's pretty easy to give an algorithm that solves this: fix every possible number in the root, then recursively solve the problem for the left and right subtrees: countBST(numKeys) if numKeys <= 1 return 1 else result = 0 for i = 1 .. numKeys leftBST = countBST(i - 1) rightBST = countBST(numKeys - i) result += leftBST * rightBST return result I've recently been familiarizing myself with treaps, and I posed the following problem to myself: Given N, find the number of distinct treaps containing the values 1 .. N with priorities 1 .. N. Two treaps are distinct if they are structurally different relative to EITHER the key OR the priority (read on for clarification). I've been trying to figure out a formula or an algorithm that can solve this for a while now, but I haven't been successful. This is what I noticed though: The answers for n = 2 and n = 3 seem to be 2 and 6, based on me drawing trees on paper. If we ignore the part that says treaps can also be different relative to the priority of the nodes, the problem seems to be identical to counting just binary search trees, since we'll be able to assign priorities to each BST such that it also respects the heap invariant. I haven't proven this though. I think the hard part is accounting for the possibility to permute the priorities without changing the structure. For example, consider this treap, where the nodes are represented as (key, priority) pairs: (3, 5) / \ (2, 3) (4, 4) / \ (1, 1) (5, 2) We can permute the priorities of both the second and third levels while still maintaining the heap invariant, so we get more solutions even though no keys switch place. This probably gets even uglier for bigger trees. For example, this is a different treap from the one above: (3, 5) / \ (2, 4) (4, 3) // swapped priorities / \ (1, 1) (5, 2) I'd appreciate if anyone can share any ideas on how to approach this. It seemed like an interesting counting problem when I thought about it. Maybe someone else thought about it too and even solved it!
0
0
0
0
1
0
I am beginning some studies into machine learning and it seems these two are often used in this field. They seem very similar, so how would one decide which is best to use?
0
0
0
1
0
0
i want to compare do simple math in django template like {% forloop.counter > 5 %} {% endfor %} how do i achieve this?
0
0
0
0
1
0
I would like to compare my application for handwritten mathematical symbols recognition with the Math Input Panel (MIP) contained in Windows 7. I have a library of recorded mouse strokes representing different mathematical formulas and I need to send them to the MIP to measure its performance. I tried to simulate mouse move but it's not working. Here are constants and imported methods that I use: const UInt32 MOUSEEVENTF_LEFTDOWN = 0x0002; const UInt32 MOUSEEVENTF_LEFTUP = 0x0004; [DllImport("user32.dll", CharSet = CharSet.Unicode)] public static extern IntPtr FindWindow(string lpClassName, string lpWindowName); [DllImport("user32.dll")] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool SetForegroundWindow(IntPtr hWnd); [DllImport("user32.dll")] static extern void mouse_event(UInt32 dwFlags, UInt32 dx, UInt32 dy, UInt32 dwData, UIntPtr dwExtraInfo); And that's the code itself: IntPtr windowHandle = FindWindow("MathInput_Window", ""); SetForegroundWindow(windowHandle); Cursor.Position = new Point(600, 700); mouse_event(MOUSEEVENTF_LEFTDOWN, 600, 700, 0, UIntPtr.Zero); for (int x = 600; x <= 650; x++) { Cursor.Position = new Point(x, 700); } for (int y = 700; y <= 750; y++) { Cursor.Position = new Point(650, y); } mouse_event(MOUSEEVENTF_LEFTUP, 650, 750, 0, UIntPtr.Zero); But the only thing i get is a single dot at the position [600,700]. The funny thing is that when I use MSPaint instead of MIP everything is working perfectly. Does anyone have some idea how it could be solved?
0
0
0
0
1
0
I need to plot a 2 argument function (so I need a 3D plot) - ideally Mathematica style with nice colours for different values, which I will then use in a Latex document. I would prefer to get a vector output (i.e. EPS), so that it prints nicely. Please note that I will not display it on the screen (my app runs as a batch job).
0
0
0
0
1
0
Let's say you want to convert from degrees to radians: radians = degrees * (pi / 180) If pi is considered a constant for the purpose of this calculation, then the resulting radians value should have the same number of significant digits as the initial degrees. I.E. -32.39 degrees = -0.5653 radians # 4 significant digits -32.38795 degrees = -0.5652763 radians # 7 significant digits I was surprised that I couldn't find any examples in any language of how to perform this seemingly simple operation. My first thought is to: degrees_str = degrees # remove any non-significant leading zeros from degrees_str # degree_digits = count the remaining digit characters in degrees_str # radian_int_digits = count the digits in integer portion of the radians # round radians to (degree_digits - radian_int_digits) digits after the decimal point Is that the most efficient manner in performing this general type of calculation (not specific to degrees/radians)?
0
0
0
0
1
0
Does anyone know of a Calculus library for JavaScript? I've done some Googling and haven't come up with anything. I applied for the WolframAlpha API, but that's expensive unless they choose to give me a grant. Ideally, I could feed an Array of 2d points into a function, and get back the graph (Array) of points of the derivative. If such a library does not exist, I will create one to share.
0
0
0
0
1
0
so say i have a grid: 0 - 1 - 2 - 3 4 - 5 - 6 - 7 8 - 9 - 10 - 11 12 - 13 - 14 - 15 (but will be more rows...) how can i find out programmatically if a random number (within the range of the numbers) is equal to the far right number: 3,7,11,15...? thanks
0
0
0
0
1
0
I would like to maximize a function with one parameter. So I run gradient descent (or, ascent actually): I start with an initial parameter and keep adding the gradient (times some learning rate factor that gets smaller and smaller), re-evaluate the gradient given the new parameter, and so on until convergence. But there is one problem: My parameter must stay positive, so it is not supposed to become <= 0 because my function will be undefined. My gradient search will sometimes go into such regions though (when it was positive, the gradient told it to go a bit lower, and it overshoots). And to make things worse, the gradient at such a point might be negative, driving the search toward even more negative parameter values. (The reason is that the objective function contains logs, but the gradient doesn't.) What are some good (simple) algorithms that deal with this constrained optimization problem? I'm hoping for just a simple fix to my algorithm. Or maybe ignore the gradient and do some kind of line search for the optimal parameter?
0
0
0
0
1
0
I need an recursive algorithm to calculate determinant of n*n matrix.
0
0
0
0
1
0
What is the best library for Java to do numeric stuff like calculating integrals, finding roots of a function, calculating different probability cdf's, etc.?
0
0
0
0
1
0
This is the expected output: We are to make a C program that calculates for the Fibonacci Sequence. We're only allowed up to 3 variables and we're NOT allowed to use loops. And I don't know what to do and how to start. I hope you guys can help me. :/
0
0
0
0
1
0
I'm looking for an answer that scales, but for my specific purpose, I have a 48th dimension vector. This could be represented as an array of 48 integers all between 0 and 255. I have a large dictionary of these vectors, approximately 25 thousand of them. I need to be able to take a vector that may or may not be in my database, and quickly find which vector from the database is closest. By closest, I mean in terms of traditional distance formula. My code will end up in python but this is more a general question. Brute Force is too slow. I need a near dictionary speed lookup. Anyone have an idea?
0
0
0
0
1
0
ISGCI lists a lot of graph classes, many of which are recognizable in polynomial time. Is anyone here aware of actual implementations of these algorithms?
0
0
0
0
1
0
Having the following code in Java: double operation = 890 / 1440; System.out.println(operation); Result: 0.0 What I want is to save the first 4 decimal digits of this operation (0.6180). Do you know how can I do it?
0
0
0
0
1
0
I've been trying to solve this and I found an equation that gives the possibility of zero division errors. Not the best thing: v1 = (a,b) v2 = (c,d) d1 = (e,f) d2 = (h,i) l1: v1 + λd1 l2: v2 + µd2 Equation to find vector intersection of l1 and l2 programatically by re-arranging for lambda. (a,b) + λ(e,f) = (c,d) + µ(h,i) a + λe = c + µh b +λf = d + µi µh = a + λe - c µi = b +λf - d µ = (a + λe - c)/h µ = (b +λf - d)/i (a + λe - c)/h = (b +λf - d)/i a/h + λe/h - c/h = b/i +λf/i - d/i λe/h - λf/i = (b/i - d/i) - (a/h - c/h) λ(e/h - f/i) = (b - d)/i - (a - c)/h λ = ((b - d)/i - (a - c)/h)/(e/h - f/i) Intersection vector = (a + λe,b + λf) Not sure if it would even work in some cases. I haven't tested it. I need to know how to do this for values as in that example a-i. Thank you.
0
0
0
0
1
0
Since the trigonometric functions in java.lang.Math are quite slow: is there a library that does a quick and good approximation? It seems possible to do a calculation several times faster without losing much precision. (On my machine a multiplication takes 1.5ns, and java.lang.Math.sin 46ns to 116ns). Unfortunately there is not yet a way to use the hardware functions. UPDATE: The functions should be accurate enough, say, for GPS calculations. That means you would need at least 7 decimal digits accuracy, which rules out simple lookup tables. And it should be much faster than java.lang.Math.sin on your basic x86 system. Otherwise there would be no point in it. For values over pi/4 Java does some expensive computations in addition to the hardware functions. It does so for a good reason, but sometimes you care more about the speed than for last bit accuracy.
0
0
0
0
1
0
I'm writing a Connect4 game with an AI opponent using adversarial search techniques and I have somewhat run into a wall. I feel that I'm not far from a solution but that there's perhaps a problem where I'm switching perspectives (as in: the perspective of which participant I'm basing my evaluation scores on), missing a minus sign somewhere or something like that. The problem is either that in the variations that I've tried that the AI chooses not to block the player when the player has three-in-a-row but otherwise the AI plays a perfect game, or that he prefers to block the player, even if he has the chance to win the game. It also seems to matter whether or not the search depth is an even or an uneven number, as the AI is pants-on-head retarded at a 6-ply search, which is pretty telling that something is wrong. Search The algorithm used is negamax with alpha-beta pruning and is implemented as follows: private int Negamax(int depth, int alpha, int beta, Player player) { Player winner; if (Evaluator.IsLeafNode(game, out winner)) { return winner == player ? (10000 / depth) : (-10000 / depth); } if (depth == Constants.RecursionDepth) { return Evaluator.Evaluate(game, depth, player); } foreach (var move in moves) { int row; if (board.DoMove(move, player, out row)) { var value = -Negamax(depth + 1, -beta, -alpha, (Player)1 - (int)player); board.UndoMove(move, row, player); if (value > alpha) { alpha = value; if (player == Player.AI) { bestColumn = move; } } if (alpha >= beta) { return alpha; } } } return alpha; } I don't suspect that the problem is in this function, but it might be. Evaluation I've based the evaluation function off of the fact that there are only 69 possible ways to get four-in-a-row on a 7x6 board. I have a look-up table of about 350 items that contains the hardcoded information for every column and row which win-combinations the row+column is a part of. For example, for row 0 and column 0, the table looks like this: //c1r1 table[0][0] = new int[3]; table[0][0][0] = 21; table[0][0][1] = 27; table[0][0][2] = 61; This means that column 0, row 0 is part of win-combination 21, 27 and 61. I have a second table, that contains for both players how many stones it has in each of the win-combinations. When I do a move then I do the following: public bool DoMove(int column, Player p, out int row) { row = moves[column]; if (row >= 0) { Cells[column + row * Constants.Columns] = p; moves[column]--; var combinations = this.Game.PlayerCombinations[p]; foreach (int i in TerminalPositionsTable.Get(column,row)) { combinations[i]++; } return true; } else { return false; } } The opposite is of course being done for UndoMove. So after doing a move on column 0, row 0 by Player.Human, the table will be filled with a value of 1 at index 21, 27 and 61. If I do another move in a cell that is also part of win-combination 27, then the player combination table gets incremented at index 27 to 2. I hope I have made that clear, as it's used in the evaluation function to very quickly determine how close a player is to scoring four-in-a-row. The evaluation function, where I suspect the problem lies, is as follows: public static int Evaluate(Game game, int depth, Player player) { var combinations = game.PlayerCombinations[player]; int score = 0; for (int i = 0; i < combinations.Length; i++) { switch (combinations[i]) { case 1: score += 1; break; case 2: score += 5; break; case 3: score += 15; break; } } return score; } So I simply loop through the 69 possible win-combinations and add an amount to the score based on whether it's a single stone, two-in-a-row or three. The part I'm still confused about in this whole adversarial search is whether I should care which player is doing a move? I mean, should I pass in the player like I do here, or should I always evaluate the board from the perspective of the AI player? I've tried many combinations of aiScore - humanScore, or just always look from the perspective of Player.AI, and such. But I've hit a dead end and every combination I've tried was pretty flawed. So: Is the logic of my evaluation solid in its basis? When should I 'switch perspective'? Any help would be much appreciated. Update I've implemented Brennan's suggestions below, and while it has definitely much improved, for some reason it doesn't block three-in-a-rows on any column but the two left and right-most, and only when the search-depth is uneven. The AI is unbeatable at even search depths, but only until depth 8 and up. Then it refuses to block again. This is pretty telling that I'm probably very close, but still have some crucial flaw. Perhaps this has to do with me setting the column the AI should drop a stone in as Brennan commented, but I don't know when else to set it. Setting it only at depth 0 doesn't work. Update 2 Edited the code as it looks like now with Brennan's changes. Update 3 Created a Github repo with the full code. If you don't know how to work Git, just download a zip file from here. It's a .NET 4.0 project, and running it will create log files of the negamax algorithm in your documents/logs directory. The solution also contains a test project, that contains a test for every board column whether or not the AI chooses to block the player when the player has three-in-a-row there.
0
1
0
0
0
0
I have 4 numbers 0-3 which is an enum (objective-c) and I'd like to get the opposite using a formula. So if 0 is put into the formula it returns 2 and if it 2 is entered then it returns 0 (and same with 1 and 3). The reason being (and it is programming related) that I want to get the opposite of an enum without having to do an if or switch statement. But this means that any formula (if it is possible must uncomplex, so that it is more efficient than using if or switch.
0
0
0
0
1
0
I've got an sql query that pulls locations from a database based on coordinates within a certain range. Now I'm trying to order them by proximity with a bit of math - but no matter how many times im writing it out on paper I can't seem to figure out a working solution. lets describe a few variables: $plat (the latitude of the place) $plong (the longitude of the place) $slat (the latitude of the searched location) $slong (the longitude of the searched location) One big thing to note is that I've converted all coordinates to positive numbers and have another feild that determines positive or negative - but for this assume that I've already queried the nearby coordinates properly. In order to order it this way I've seen people use "ORDER BY abs(coord-coords)" for something simple -but what I need is something more like: [($slat - $plat) * ($slong - plong)] - but this causes problems because if the resulting calulation on one side is zero - then after multiplied the result would be zero as well - making it innaccurate. Any ideas -
0
0
0
0
1
0
I want to create a Voronoi diagram on several pairs of latitudes/longitudes, but want to use the great circle distance between them, not the (inaccurate) Pythagorean distance. Can I make qhull/qvoronoi or some other Linux program do this? I considered mapping the points to 3D, having qvoronoi create a 3D Voronoi diagram[1], and intersecting the result with the unit sphere, but I'm not sure that's easy. [1] I realize the 3D distance between two latitudes/longitudes (the "through the Earth" path) isn't the same as the great circle distance, but it's easy to prove that this transformation preserves relative distances, which is all that matters for a Voronoi diagram.
0
0
0
0
1
0
I solved this my self. I'll post the solution when were past due date for my homework. Okay, I'm going to build a parser or an evaluator. The de facto standard when parsing with prefix notation is to just use a stack. Add to the stack if input is a number, if it is an operator you can pop twice apply operator and put the result back on the stack. The stack here would be a list, so I need to know how I can apply the operators. The input would be a string. "(11+2*)" This would 1+1=2*2=4. First it would read 1, and 1 to the stack. Read another 1 and add it to the stack. Now it reads "+", so it removes(pop) twice from the stack and apply + and puts the result back. Read 2, put 2 on the stack. Read *, pop twice and apply *. Hope this makes sense. How would the predicate look like? I need one variable for the input string, one to maintain the stack, and one for the result? Three? I'm especially wondering about push and pop on the stack as well as removing as I go from the input string.
0
0
0
0
1
0
I'm trying to put buttons that have operators on them, like / * +, etc. I want to store the operator in such a way that I can use it in an expression, like 1 var 2 = 8 I would like to avoid having to use a different method for each operator, so an operator var would be my best option, I think. Objective-C for iPhone
0
0
0
0
1
0
In C#, I often have to limit an integer value to a range of values. For example, if an application expects a percentage, an integer from a user input must not be less than zero or more than one hundred. Another example: if there are five web pages which are accessed through Request.Params["p"], I expect a value from 1 to 5, not 0 or 256 or 99999. I often end by writing a quite ugly code like: page = Math.Max(0, Math.Min(2, page)); or even uglier: percentage = (inputPercentage < 0 || inputPercentage > 100) ? 0 : inputPercentage; Isn't there a smarter way to do such things within .NET Framework? I know I can write a general method int LimitToRange(int value, int inclusiveMinimum, int inlusiveMaximum) and use it in every project, but maybe there is already a magic method in the framework? If I need to do it manually, what would be the "best" (ie. less uglier and more fast) way to do what I'm doing in the first example? Something like this? public int LimitToRange(int value, int inclusiveMinimum, int inlusiveMaximum) { if (value >= inclusiveMinimum) { if (value <= inlusiveMaximum) { return value; } return inlusiveMaximum; } return inclusiveMinimum; }
0
0
0
0
1
0
I am looking for references (tutorials, books, academic literature) concerning structuring unstructured text in a manner similar to the google calendar quick add button. I understand this may come under the NLP category, but I am interested only in the process of going from something like "Levi jeans size 32 A0b293" to: Brand: Levi, Size: 32, Category: Jeans, code: A0b293 I imagine it would be some combination of lexical parsing and machine learning techniques. I am rather language agnostic but if pushed would prefer python, Matlab or C++ references Thanks
0
1
0
0
0
0
I have an arbitrary function or inequality (consisting of a number of trigonometrical, logarithmical, exponential, and arithmetic terms) that takes several arguments and I want to get its range knowing the domains of all the arguments. Are there any Java libraries that can help to solve a problem? What are the best practices to do that? Am I right that for an arbitrary function the only thing can be done is a brute-force approximation? Also, I'm interested in functions that can build intersections and complements for given domains. Upd. The functions are entered by the user so the complexity cannot be predicted. However, if the library will treat at least simple cases (1-2 variables, 1-2 terms) it will be OK. I suggest the functions will mostly define the intervals and contain at most 2 independent variables. For instance, definitions like y > (x+3), x ∈ [-7;8] y <= 2x, x ∈ [-∞; ∞] y = x, x ∈ {1,2,3} will be treated in 99% of cases and covering them will be enough for now. Well, maybe it's faster to write a simple brute-force for treating such cases. Probably it will be satisfactory for my case but if there are better options I would like to learn them.
0
0
0
0
1
0
Basically this script will subtract StartTime from EndTime, using a jQuery plugin the html form is populated with Start and End Time in the format HH:MM, an input field is populated with the result, it works except for one issue: If Start Time is between 08:00 and 09:59 it just returns strange results - results are 10 hours off to be precise, why? All other inputs calculate properly! function setValue() { var startTime = document.getElementById('ToilA'); var endTime = document.getElementById('EndHours'); startTime = startTime.value.split(":"); var startHour = parseInt(startTime[0]); var startMinutes = parseInt(startTime[1]); endTime = endTime.value.split(":"); var endHour = parseInt(endTime[0]); var endMinutes = parseInt(endTime[1]); //var hours, minutes; var today = new Date(); var time1 = new Date(2000, 01, 01, startHour, startMinutes, 0); var time2 = new Date(2000, 01, 01, endHour, endMinutes, 0); var milliSecs = (time2 - time1); msSecs = (1000); msMins = (msSecs * 60); msHours = (msMins * 60); numHours = Math.floor(milliSecs/msHours); numMins = Math.floor((milliSecs - (numHours * msHours)) / msMins); numSecs = Math.floor((milliSecs - (numHours * msHours) - (numMins * msMins))/ msSecs); numSecs = "0" + numSecs; numMins = "0" + numMins; DateCalc = (numHours + ":" + numMins); document.getElementById('CalculateHours').value = DateCalc; }
0
0
0
0
1
0
I find learning new topics comes best with an easy implementation to code to get the idea. This is how I learned genetic algorithms and genetic programming. What would be some good introductory programs to write to get started with machine learning? Preferably, let any referenced resources be accessible online so the community can benefit
0
1
0
1
0
0
I am writing a small utility for calculating a complicated mathematical formula (using commons-math library for integration and root finding). I was trying to write it in the same way as a normal business application, however I found that I am getting a quickly increasing number of classes. To get the first step of the calculations (1 line formula with 2 integrals), I already wrote 3 classes for every tiny bit of the calculation, so that I can use dependency injection and properly mock all the calls to commons-math. It is kind of getting out of control though, I will end up with 20 classes for a problem that could be solved on 2 screens in one class (without unit testing). What would be your preferred approach? I am very tempted to only rely on acceptance and higher level tests for this one.
0
0
0
0
1
0
I am working on a project that does a lot of querying and the some mathematical modeling based on results from these queries, and finally some scoring (read: "execution time too long to test thoroughly"). Recently I have realized a rather new problem/bug in my code; some of the results get NaN values for score! Here's how the scores are calculated: Note that pfound, psig are doubles that are always positive or 0 Double score1 = (pfound!=0) ? (Math.log(factorial((int)psig + 1))/pfound) : 0; score1 = score1 * alpha_coeff[0]; if (score1.isInfinite()) throw new RuntimeException(p.getName() + " score1 = Inf"); else if(score1.isNaN()) throw new RuntimeException(p.getName() + " score1 = NaN"); I have checked the possible causes triggering NaN, but I believe it should be safe from most of those: I am already checking for pfound == 0 (so no divide by zero) Argument to Math.log() cannot have a negative value What I suspect is whether or not factorial() (a custom function which return the factorial as a long) returns a long so big that it can't be cast into a double without loss of precision or something like that. I checked Long.doubleValue(), and apparently it generates NaN if it's argument results in NaN. Any comments? Am I missing something fundamental here?
0
0
0
0
1
0
A linear algebra question; Given a k-variate normed vector u (i.e. u : ||u||_2=1) how do you construct \Gamma_u, any arbitrary k*(k-1) matrix of unit vectors such that (u,\Gamma_u) forms an orthogonal basis ? I mean: from a computationnal stand point of view: what algorithm do you use to construct such matrices ? Thanks in advance,
0
0
0
0
1
0
How can i simulate a spray like windows paint ? i think it create points random , what is your opinion?
0
0
0
0
1
0
Why doesn't this work? @echo off for /l %%i in (0, 1, 100) do ( for /l %%j in (0, 1, 10) do ( set /a curr=%%i*10 + %%j echo %curr% ) echo "-----------------------------" ) This is the output I get from this: 1010 1010 1010 1010 1010 1010 1010 1010 1010 1010 1010 "----------------------------" 1010 1010 1010 1010 1010 1010 1010 1010 ... It seems like it precomputes the math before executing, so that when it does finally execute, %curr% is already at 1010. How do I keep it from doing that? I'm trying to get output like this: 0 1 2 3 4 5 6 7 8 9 10 "----------------------------" 11 12 ... Thanks in advance Answer from Johannes Rössel (for those who might look for it later): @echo off setlocal enabledelayedexpansion enableextensions for /l %%i in (0, 1, 100) do ( for /l %%j in (0, 1, 10) do ( set /a curr=%%i*10+%%j echo !curr! ) echo "-----------------------------" )
0
0
0
0
1
0
According to Daniel, in his answer, there is no easy way to modify the below function so I bit the bullet and started from scratch. Solution is below (as an answer). Actually, ignore my answer. See Tom Sirgedas' answer it's a lot shorter. I need to modify the solution found here: Calculate a vector from the center of a square to edge based on radius, that calcs the vector from the center of a rectangle, to work for any point within the rectangle. Here's the previous solution, from the link: double magnitude; double abs_cos_angle= fabs(cos(angle)); double abs_sin_angle= fabs(sin(angle)); if (width/2*abs_sin_angle <= height/2*abs_cos_angle) { magnitude= width/2/abs_cos_angle; } else { magnitude= height/2/abs_sin_angle; } double check_x= x + cos(angle)*magnitude; double check_y= y + sin(angle)*magnitude; check_x and check_y return the point on the edge of the rectangle that a line drawn from the center, at angle, will intersect. It's a while since I went to school, so I blindly tried replacing width/2 and height/2 with the point I'm interested in. Unfortunately that didn't work. Any ideas? ETA: This blind modification always returns the correct result if the line intersects the rectangle at the Top or Left. Depending on the quadrant the originating point is in, it returns a point too far away or too close when the line intersects the Right or Bottom.
0
0
0
0
1
0
I want to use Random forests for attribute reduction. One problem I have in my data is that I don't have discrete class - only continuous, which indicates how example differs from 'normal'. This class attribute is a kind of distance from zero to infinity. Is there any way to use Random forest for such data?
0
0
0
1
0
0
function setValue() { var startTime = document.getElementById('ToilA'); var endTime = document.getElementById('EndHours'); startTime = startTime.value.split(":"); var startHour = parseInt(startTime[0], 10); var startMinutes = parseInt(startTime[1], 10); endTime = endTime.value.split(":"); var endHour = parseInt(endTime[0], 10); var endMinutes = parseInt(endTime[1], 10); //var hours, minutes; var today = new Date(); var time1 = new Date(2000, 01, 01, startHour, startMinutes, 0); var time2 = new Date(2000, 01, 01, endHour, endMinutes, 0); var milliSecs = (time2 - time1); msSecs = (1000); msMins = (msSecs * 60); msHours = (msMins * 60); numHours = Math.floor(milliSecs/msHours); numMins = Math.floor((milliSecs - (numHours * msHours)) / msMins); numSecs = Math.floor((milliSecs - (numHours * msHours) - (numMins * msMins))/ msSecs); numSecs = "0" + numSecs; numMins = "0" + numMins; DateCalc = (numHours + ":" + numMins); document.getElementById('CalculateHours').value = DateCalc; } I have one more issue with this code, there is a leading 0 when the minute part is over 10. so it return something like 11:013 rather that 11:13, can this be fixed with math or will an if statement fix this? Like if number of items > 2, remove first item? I was going to just do a PHP script to remove this when the form is submitted, but it doesn't look good.
0
0
0
0
1
0
I am thinking recently on how floating point math works on computers and is hard for me understand all the tecnicals details behind the formulas. I would need to understand the basics of addition, subtraction, multiplication, division and remainder. With these I will be able to make trig functions and formulas. I can guess something about it, but its a bit unclear. I know that a fixed point can be made by separating a 4 byte integer by a signal flag, a radix and a mantissa. With this we have a 1 bit flag, a 5 bits radix and a 10 bit mantissa. A word of 32 bits is perfect for a floating point value :) To make an addition between two floats, I can simply try to add the two mantissas and add the carry to the 5 bits radix? This is a way to do floating point math (or fixed point math, to be true) or I am completely wrong? All the explanations I saw use formulas, multiplications, etc. and they look so complex for a thing I guess, would be a bit more simple. I would need an explanation more directed to beginning programmers and less to mathematicians.
0
0
0
0
1
0
I'm trying to figure out how to implement RSA crypto from scratch (just for the intellectual exercise), and i'm stuck on this point: For encryption, c = me mod n Now, e is normally 65537. m and n are 1024-bit integers (eg 128-byte arrays). This is obviously too big for standard methods. How would you implement this? I've been reading a bit about exponentiation here but it just isn't clicking for me: Wikipedia-Exponentiation by squaring This Chapter (see section 14.85) Thanks. edit: Also found this - is this more what i should be looking at? Wikipedia- Modular Exponentiation
0
0
0
0
1
0
Given this Short (signed): &Hxxxx I want to: Extract the most right &HxxFF as SByte (signed) Extract the left &H7Fxx as Byte (unsigned) Identify if the most left &H8xxx is positive or negative (bool result)
0
0
0
0
1
0
Background: I have a function in my program that takes a set of points and finds the minimum and maximum on the curve generated by those points. The thing is it is incredibly slow as it uses a while loop to figure out the min/max based on approximated error. Not completely sure what formal method this is because I did not write it myself, but I know we need a new and more efficient one. Question: My question is what is the best and most efficient method/algorithm to finding the min max points on a curve, using C#, that is also very accurate? About the curve: I have my Numerical Analysis book from college near me, so all I need is a method name and a nudge in the right direction. I can generate as many points as I choose to approximate the curve, but I want to keep the number of points to an efficient minimum. The curve is always in the shape of one segment of a Sin/Cos curve, but not always the same curve and will always be less that one period. The range of Theta is 0° to 359.999...° It has some phase and amplitude shift and Y will never be negative. This function/algorithm will have to run fast as it will be run every several hundred milliseconds as the curve changes. Any suggestions are appreciated. EDIT More info on the curve: The points are generated on mouse move. The points are a set of points based on the length of a rubber belt in a drive design with an idler, such as one like the serpentine belt in a car. The position of the idler determines the length of the belt and I get the curve [belt length(y) vs idler position(x)]. The idler in this case is a pivoting idler and will have constant circular motion. If the drive design changes the curve will change, either because the length points change, or because the range of motion of the idler has been constrained. The range of motion in the idler is potentially 0° to 359.999...° and is theta as stated above. For a slotted idler the maximum range is 1/2 of the period of the curve (easier problem). I guess what I need is a general solver for both types of idlers, but the real issue is with the pivoting idler.
0
0
0
0
1
0
I was just wondering if there's a way to generate many different combinations of numbers and letters, based off of just one number/letter? For example: From just this one String: 234jk43fc7898cfg58 We could generate MANY different combos like: HGYTD786Gjhghjg76fghf8 8976sgh8976 cv34905bv7 435bv4875bvg487bv 45b6467ne456n 4n56n45n6 ... where each generated string would end up being able to be recalculated BACK to its original String: 234jk43fc7898cfg58 Is this at all possible? I'd appreciate any help at all. Thank you
0
0
0
0
1
0
This is what I am doing, which works 99.999% of the time: ((int)(customerBatch.Amount * 100.0)).ToString() The Amount value is a double. I am trying to write the value out in pennies to a text file for transport to a server for processing. The Amount is never more than 2 digits of precision. If you use 580.55 for the Amount, this line of code returns 58054 as the string value. This code runs on a web server in 64-bit. Any ideas?
0
0
0
0
1
0
Is there anyone that has some ideas on how to implement the AdaBoost (Boostexter) algorithm in python? Cheers!
0
0
0
1
0
0
For RSA, how do i calculate the secret exponent? Given p and q the two primes, and phi=(p-1)(q-1), and the public exponent (0x10001), how do i get the secret exponent 'd' ? I've read that i have to do: d = e-1 mod phi using modular inversion and the euclidean equation but i cannot understand how the above formula maps to either the a-1 ≡ x mod m formula on the modular inversion wiki page, or how it maps to the euclidean GCD equation. Can someone help please, cheers
0
0
0
0
1
0
Is it possible to take something like x^2+5 and have it generate this: http://imgur.com/Muq2X.gif I'll be using Python so anything based in Python would work, but I'm open to other solutions such as latex output.
0
0
0
0
1
0
Possible Duplicates: Incorrect floating point math? Float compile-time calculation not happening? Strange stuff going on today, I'm about to lose it... #include <iomanip> #include <iostream> using namespace std; int main() { cout << setprecision(14); cout << (1/9+1/9+4/9) << endl; } This code outputs 0 on MSVC 9.0 x64 and x86 and on GCC 4.4 x64 and x86 (default options and strict math...). And as far as I remember, 1/9+1/9+4/9 = 6/9 = 2/3 != 0
0
0
0
0
1
0
I have a large sparse matrix representing attributes for millions of entities. For example, one record, representing an entity, might have attributes "has(fur)", "has(tail)", "makesSound(meow)", and "is(cat)". However, this data is incomplete. For example, another entity might have all the attributes of a typical "is(cat)" entity, but it might be missing the "is(cat)" attribute. In this case, I want to determine the probability that this entity should have the "is(cat)" attribute. So the problem I'm trying to solve is determining which missing attributes each entity should contain. Given an arbitrary record, I want to find the top N most likely attributes that are missing but should be included. I'm not sure what the formal name is for this type of problem, so I'm unsure what to search for when researching current solutions. Is there a scalable solution for this type of problem? My first is to simply calculate the conditional probability for each missing attribute (e.g. P(is(cat)|has(fur) and has(tail) and ... )), but that seems like a very slow approach. Plus, as I understand the traditional calculation of conditional probability, I imagine I'd run into problems where my entity contains a few unusual attributes that aren't common with other is(cat) entities, causing the conditional probability to be zero. My second idea is to train a Maximum Entropy classifier for each attribute, and then evaluate it based on the entity's current attributes. I think the probability calculation would be much more flexible, but this would still have scalability problems, since I'd have to train separate classifiers for potentially millions attributes. In addition, if I wanted to find the top N most likely attributes to include, I'd still have to evaluate all the classifiers, which would likely take forever. Are there better solutions?
0
0
0
1
0
0
I have a rather simple bird's-view 2D game where tower sprites defend against incoming moving sprites by shooting a bullet at them. My question: How do I calculate the needed bullet speed for the bullet to reach its moving target, provided that the bullet will always have the same defined speed? I'm using JavaScript and have these sprite variables (among others): sprite.x, sprite.y, sprite.width, sprite.height, sprite.speedX (i.e. velocity), sprite.speedY... so I have the objects originSprite, targetSprite and bulletSprite, all with these type of values, and I need to set the right bulletSprite speed values. Probably for it to look good, the bullet would start at the outside of the originSprite (or some defined radius, though I guess starting from the originSprite center would also work), but its bullet center would try hit into the center of the targetSprite or so. Note there's no gravity or anything in this world. (Perhaps I should have my sprites variables using angle and velocity but right now I'm using speedX and speedY...) Thanks so much!
0
0
0
0
1
0
I've studied some simple semantic network implementations and basic techniques for parsing natural language. However, I haven't seen many projects that try and bridge the gap between the two. For example, consider the dialog: "the man has a hat" "he has a coat" "what does he have?" => "a hat and coat" A simple semantic network, based on the grammar tree parsing of the above sentences, might look like: the_man = Entity('the man') has = Entity('has') a_hat = Entity('a hat') a_coat = Entity('a coat') Relation(the_man, has, a_hat) Relation(the_man, has, a_coat) print the_man.relations(has) => ['a hat', 'a coat'] However, this implementation assumes the prior knowledge that the text segments "the man" and "he" refer to the same network entity. How would you design a system that "learns" these relationships between segments of a semantic network? I'm used to thinking about ML/NL problems based on creating a simple training set of attribute/value pairs, and feeding it to a classification or regression algorithm, but I'm having trouble formulating this problem that way. Ultimately, it seems I would need to overlay probabilities on top of the semantic network, but that would drastically complicate an implementation. Is there any prior art along these lines? I've looked at a few libaries, like NLTK and OpenNLP, and while they have decent tools to handle symbolic logic and parse natural language, neither seems to have any kind of proabablilstic framework for converting one to the other.
0
1
0
1
0
0
I have fixed area 2d space filled with rectangles. I'd like to move the rectangles around, add new ones, remove some, but not allow them to overlap. If all of the rects are the same height and width (50x50px), what data structure should I use to store their position and what space they are using and what lookup method should I use against that structure when adding new rects to the scene?
0
0
0
0
1
0
I've got a 1km square, I'm dividing it up into 100meters both on the positive and negative sides of it.. __________y__________ | | | | | | | | | |---------|---------| x | | | | | | |_________|_________| Basically I'm making a square just like the one above. I'm diving it up into 100 meter squares both on the positive side and negative side of the x axis. I'm then plotting each point in their respective co-ords , I'm planning on throwing an (x,y) value through a bunch of if/else statements (at least 50 , upto 100) but I'm concerned with how expensive this would be. Is there a more efficient way of doing what I want to do? Here is an example of how I plan on doing it... if(tlat < lat && tlat > lat - 89930.7){ //point is within 100 meters on lat //On the NEGATIVE SIDE. if(tlng > lng && tlng < lng + 147999.8){ //point is within 100 meters on lat NEGATIVE && //withing 100 meters on lng POSITIVE layers.addcube(highlng100p, lowlng100p, yhigh, ylow, highlat100p, lowlat100p); highlng100p = highlng100p + 5; lowlng100p = lowlng100p + 5; highlat100p = highlat100p + 5; lowlat100p = lowlat100p + 5; }else if(tlng < lng && tlng > lng - 147999.8){ //point is within 100 meters on lat NEGATIVE && //withing 100 meters on lng NEGATIVE layers.addcube(highlat100n, lowlat100n, yhigh, ylow, highlng100n, lowlng100n); highlat100n = highlat100n + 5; lowlat100n = lowlat100n + 5; highlng100n = highlng100n + 5; lowlat100n = lowlat100n + 5; }else if(tlng > lng && tlng < lng + 295999.6){ //point is within 200 meters on lat NEGATIVE && //withing 200 meters on lng POSITIVE layers.addcube(highlat200n, lowlat200n, yhigh, ylow, highlng200p, lowlng200n); highlat200n = highlat200n + 5; lowlat200n = lowlat200n + 5; highlng200p = highlng200p + 5; lowlng200p = lowlng200p + 5; }else if(tlng < lng && tlng > lng - 295999.6){ //point is within 200 meters on lat NEGATIVE && //withing 200 meters on lng NEGATIVE layers.addcube(highlat200n, lowlat200n, yhigh, ylow, highlng200n, lowlng200n); highlat200n = highlat200n + 5; lowlat200n = lowlat200n + 5; highlng200n = highlng200n + 5; lowlng200n = lowlng200n + 5; }else if(tlng > lng && tlng < lng + 443999.4){ //point is within 300 meters on lat NEGATIVE && //withing 300 meters on lng POSITIVE layers.addcube(highlat300n, lowlat300n, yhigh, ylow, highlng300p, lowlng300p); highlat300n = highlat300n + 5; lowlat300n = lowlat300n + 5; highlng300p = highlng300p + 5; lowlng300p = lowlng300p + 5; }else if(tlng < lng && tlng > lng - 443999.4){ //point is within 300 meters on lat NEGATIVE && //withing 300 meters on lng NEGATIVE layers.addcube(highlat300n, lowlat300n, yhigh, ylow, highlng300n, lowlng300n); highlat300n = highlat300n + 5; lowlat300n = lowlat300n + 5; highlng300n = highlng300n + 5; lowlng300n = lowlng300n + 5; } else if(tlng > lng && tlng < lng + 591999.2){ //point is within 400 meters on lng //on the POSITIVE SIDE layers.addcube(highlat400n, lowlat400n, yhigh, ylow, highlng400p, lowlng400p); highlat400n = highlat400n + 5; lowlat400n = lowlat400n + 5; highlng400p = highlng400p + 5; lowlng400p = lowlng400p + 5; }else if(tlng < lng && tlng > lng - 591999.2){ //point is within 400 meters on lng //on the NEGATIVE SIDE layers.addcube(highlat400n, lowlat400n, yhigh, ylow, highlng400n, lowlng400n); highlat400n = highlat400n + 5; lowlat400n = lowlat400n + 5; highlng400n = highlng400n + 5; lowlng400n = lowlng400n + 5; }else if(tlng > lng && tlng < lng + 739999){ //point is within 500 meters on lng //on the POSITIVE SIDE layers.addcube(highlat500n, lowlat500n, yhigh, ylow, highlng500p, lowlng500p); highlat500n = highlat500n + 5; lowlat500n = lowlat500n + 5; highlng500p = highlng500p + 5; lowlng500p = lowlng500p + 5; }else if(tlng < lng && tlng > lng - 739999){ //point is within 500 meters on lng //on the NEGATIVE SIDE layers.addcube(highlat500n, lowlat500n, yhigh, ylow, highlng500n, lowlng500n); highlat500n = highlat500n + 5; lowlat500n = lowlat500n + 5; highlng500n = highlng500n + 5; lowlng500n = lowlng500n + 5; } } If anyone could help me make what I want to do much more efficient I'd appreciate it! Thanks,
0
0
0
0
1
0
I'm trying to implement decimal arithmetic in (La)TeX. I'm trying to use dimens to store the values. I want the arithmetic to be exact to some (fixed) number of decimal places. If I use 1pt as my base unit, then this fails, because \divide rounds down, so 1pt / 10 gives 0.09999pt. If I use something like 1000sp as my base unit, then I get working fixed point arithmetic with 3 decimal places, but I can't figure out an easy way to format the numbers. If I try to convert them to pt, so I can use TeX's display mechanism, I have the same problem with \divide. How do I fix this problem, or work around it?
0
0
0
0
1
0
I'm attempting to use the OpenAmplify API to evaluate the content of a URI. The point is to draw out the topics that are truly relevant to the article. Unfortunately, the topical analysis I'm getting back is: Huge, and Varied Neither quality is terribly useful for what I'm trying to do because the signal to noise ratio is being heavily skewed towards noise. I'm analyzing web content, so there is a certain amount (perhaps a large amount) of irrelevant content (ads, etc.) involved. I get that. Nonetheless, many of the topics being returned are either useless (utterly non-sensical, not even words), irrelevant (as in, where did that come from?) or too granular to provide any meaning or insight. I can probably filter out most of this noise using the value, um, value that is returned for each domain, subdomain, topic, et al, but I don't really know what it means. Certainly I understand that the value it's a measure of "the prominence of the word in the text," but the number itself appears entirely arbitrary in a way that I prevents me saying something like "ignore any terms with a value less than 50" and have it carry any real meaning. Are there any range criteria that I can use to help me understand how to use a topic's value score as a filtering threshold? Alternatively, is there another field that I should be using for this sort of filtration? Thanks for your help.
0
1
0
0
0
0
I have a coding/maths problem that I need help translating into C#. It's a poker chip calculator that takes in the BuyIn, the number of players and the total amount of chips for each colour (there are x amount of colours) and their value. It then shows you every possible combination of chips per person to equal the Buy In. The user can then pick the chipset distribution they would like to use. It's best illustrated with a simple example. BuyIn: $10 Number of Players: 1 10 Red Chips, $1 value 10 Blue Chips, $2 value 10 Green Chips, $5 value So, the possible combinations are: R/B/G 10/0/0 8/1/0 6/2/0 5/0/1 4/3/0 2/4/0 1/2/1 etc. I have spent a lot of time trying to come up with an algorithm in C#/.NET to work this out. I am stumbling on the variable factor - there's usually only 3 or 4 different chips colours in a set, but there could be any amount. If you have more than one player than you have to count up until TotalChips / NumberOfPlayers. I started off with a loop through all the chips and then looping from 0 up to NumberOfChips for that colour. And this is pretty much where I have spent the last 4 hours... how do I write the code to loop through x amount of chips and check the value of the sum of the chips and add it to a collection if it equals the BuyIn? I need to change my approach radically methinks... Can anyone put me on the right track on how to solve this please? Pseudo code would work - thank you for any advice! The below is my attempt so far - it's hopeless (and wont compile, just an example to show you my thought process so far) - Might be better not to look at it as it might biased you on a solution... private void SplitChips(List<ChipSuggestion> suggestions) { decimal valueRequired = (decimal)txtBuyIn.Value; decimal checkTotal = 0; ChipSuggestion suggestion; //loop through each colour foreach (Chip chip in (PagedCollectionView)gridChips.ItemsSource) { //for each value, loop through them all again foreach (Chip currentChip in (PagedCollectionView)gridChips.ItemsSource) { //start at 0 and go all the way up for (int i = 0; i < chip.TotalChipsInChipset; i++) { checkTotal = currentChip.ChipValue * i; //if it is greater than than ignore and stop if (checkTotal > valueRequired) { break; } else { //if it is equal to then this is a match if (checkTotal == valueRequired) { suggestion = new ChipSuggestion(); suggestion.SuggestionName = "Suggestion"; chipRed.NumberPerPlayer = i; suggestion.Chips.Add(chipRed); chipBlue.NumberPerPlayer = y; suggestion.Chips.Add(chipBlue); chipGreen.NumberPerPlayer = 0; suggestion.Chips.Add(chipGreen); //add this to the Suggestion suggestions.Add(suggestion); break; } } } } } }
0
0
0
0
1
0
I have two squares, S1 = (x1,y1,x2,y2) and S2 = (a1,b1,a2,b2) I'm looking for the A transformation matrix with which A * S1 = S2 As far as I see, A is an affine 3x3 matrix, so I have 9 unknown values. How can I calculate these values? thanks and best, Viktor
0
0
0
0
1
0
I was wondering what options were available to generate .png based on the kind of input one feeds a graphing calculator.. so (y^2 + 5x + 3) / ((3x + 3) + 5y + 18) would return The only thing I've found so far is texvc in mediawiki, but it seems overkill to get the whole mediawiki for one of it's modules.
0
0
0
0
1
0
I'm playing arround with a Genetic Algorithm in which I want to evolve graphs. Do you know a way to apply crossover and mutation when the chromosomes are graphs? Or am I missing a coding for the graphs that let me apply "regular" crossover and mutation over bit strings? thanks a lot! Any help, even if it is not directly related to my problem, is appreciated! Manuel
0
1
0
0
0
0
I'm not sure if this is possible, but basically I have two degrees that will change the width/size and skew of an image. In a tranformation matrix (<Matrix3DProjection/>), it works like this: M11:cos(x) M12:sin(y)*sin(x) M11:0 M21:0 M22:cos(y) M23:0 M31:0 M32:0 M33:1 So if I have X = 30° and Y=40°, my matrix is: M11:0.866 M12:0.321 M11:0 M21:0 M22:0.766 M23:0 M31:0 M32:0 M33:1 So becomes What I'd like to use instead is a <TransformGroup/> but can't quite figure out the <SkewTransform AngleY="???"/> portion. The <ScaleTransform/> seems easy enough by using M11 and M22 values above in ScaleX and ScaleY like <ScaleTransform ScaleX=".866" ScaleY=".766"/>. But I can't figure out the AngleY portion of <SkewTransform/> from an M12 value of 0.321. I know that from doinking around with this manually, a value of AngleY="20.3" seems very accurate. But I can't figure out the math behind this. Does anyone know?
0
0
0
0
1
0
For a 2D game I'm working on, I'd like to figure out when a projectile reaches its closest to point to its target. A projectile is a point that moves by a constant dx,dy per frame. A target is another point whose speed relative to the projectile is slow enough as to be considered stationary. I want to have the projectile explode when it is (approximately) as close to the target as it will be. What's a good way to calculate this? Absolute precision is not critical, this is the client-side simulation of an event that has already been resolved on the server. I'd prefer an algorithm that was fast and simple to one that was pixel perfect.
0
0
0
0
1
0
Im trying to make dynamic column list that will be 4 columns total (PHP). Im echoing an array and after every time 4 array items are echod, I would like to wrap those 4 array items in a div called "column". So basically, I thought I could do this with a self counting $i++ statement, but first off I'm having trouble starting the count from anything but zero (I tried setting the variable initially outside of the for each loop.) Anyways, ya, if you could kindly show me how to check to see if the $++ is divisible by 4 in php, so that I can insert a if $i++ is divisible by 4 then echo "" , it would be much appreciated. But first I believe I need to figure out how to start the counting at 1 (so that the if $i++ is divisible by 4 would work... right??)
0
0
0
0
1
0
Given the following letters in a license plate, how many combinations of them can you create AAAA1234 Please note that this is not a homework question (I am too old for college :) I am only trying to understand permutations and combinations. I always get lost when I see questions like this. Do I use n! or nPr or nCr. Any book on this subject in addition to the logic used to arrive at the answer will also be greatly appreciated.
0
0
0
0
1
0
Is the Stanford POS tagger able to detect collocation? If so, how do I use it? If I want to provide my own training file for the Stanford POS Tagger, do I have to tag the words according to the one like the WSJ This means that I have to 'bracket" the words into Entities and collocation right? If so, how do I find collocations from the tagger? I am avoiding the need of using a parser.
0
1
0
0
0
0
I'm looking to build an AI system to "pick" a fantasy football team. I have only basic knowledge of AI techniques (especially when it comes to game theory), so I am looking for advice on what techniques could be used to accomplish this and pointers to some reading materials. I am aware that this may be a very difficult or maybe even impossible task for AI to accurately complete: however I am not too concerned on the accuracy, rather I am interested in learning some AI and this seems like a fun way to apply it. Some basic facts about the game: A team of 14 players must be picked There is a limit on the total cost of players picked The players picked must adhere to a certain configuration (there must always be one goalkeeper, at least two defenders, one midfielder and one forward) The team may be altered on a weekly basis but removing/adding more than one player a week will inccur a penalty P.S. I have stats on every match played in last season, could this be used to train the AI system?
0
1
0
0
0
0
I am using JavaScript and trying to make a skew effect on a div. First, take a look at this video: http://www.youtube.com/watch?v=ny5Uy81smpE (0:40-0:60 should be enough). The video shows some nice transformations (skew) when you move the window. What I want to do is the same thing: to skew a div when I move it. Currently I just have a plain simple div: <div id="a" style="background: #0f0; position: absolute; left: 0px; top: 0px;"></div> I have done a simple skew transformation using the CSS3's transform property, but my implementation is buggy. Are there good tutorials or maths sites or resources that describe the logic behind this? I know JavaScript and CSS well enough to implement, if I just knew the logic and maths. I tried reading FreeWins source code, but I am not good in C. I am accepting any resourceful answers or pseudo code. My dragging system is part of a bigger system, thus, now that I post some real code, it does not work without giving you the entire system (that I can not do at this point). So, you can't run this code as is. The code I use is this (slightly modified though) to demonstrate my idea: /** * The draggable object. */ Draggable = function(targetElement, options) { this.targetElement = targetElement; // Initialize drag data. this.dragData = { startX: null, startY: null, lastX: null, lastY: null, offsetX: null, offsetY: null, lastTime: null, occuring: false }; // Set the cursor style. targetElement.style.cursor = 'move'; // The element to move. this.applyTo = options.applyTo || targetElement; // Event methods for "mouse down", "up" and "move". // Mouse up and move are binded to window. // We can attach and deattach "move" and "up" events as needed. var me = this; targetElement.addEventListener('mousedown', function(event) { me.onMouseDown.call(me, event); }, false); this.mouseUp = function(event) { me.onMouseUp.call(me, event); }; this.mouseMove = function(event) { me.onMouseMove.call(me, event); }; }; /** * The mouse down event. * @param {Object} event */ Draggable.prototype.onMouseDown = function(event) { // New drag event. if (this.dragData.occuring === false) { this.dragData.occuring = true; this.dragData.startX = this.dragData.lastX = event.clientX; this.dragData.startY = this.dragData.lastY = event.clientY; this.dragData.offsetX = parseInt(this.applyTo.style.left, 10) - event.clientX; this.dragData.offsetY = parseInt(this.applyTo.style.top, 10) - event.clientY; this.dragData.lastTime = (new Date()).getTime(); // Mouse up and move events. var me = this; window.addEventListener('mousemove', this.mouseMove, false); window.addEventListener('mouseup', this.mouseUp, false); } }; /** * The mouse movement event. * @param {Object} event */ Draggable.prototype.onMouseMove = function(event) { if (this.dragData.occuring === true) { // He is dragging me now, we move if there is need for that. var moved = (this.dragData.lastX !== event.clientX || this.dragData.lastY !== event.clientY); if (moved === true) { var element = this.applyTo; // The skew animation. :) var skew = (this.dragData.lastX - event.clientX) * 1; var limit = 25; if (Math.abs(skew) > limit) { skew = limit * (skew > 0 ? 1 : -1); } var transform = 'translateX(' + (event.clientX + this.dragData.offsetX - parseInt(element.style.left, 10)) + 'px)'; transform += 'translateY(' + (event.clientY + this.dragData.offsetY - parseInt(element.style.top, 10)) + 'px)'; transform += 'skew(' + skew + 'deg)'; element.style.MozTransform = transform; element.style.webkitTransform = transform; this.dragData.lastX = event.clientX; this.dragData.lastY = event.clientY; this.dragData.lastTime = (new Date()).getTime(); } } }; /** * The mouse up event. * @param {Object} event */ Draggable.prototype.onMouseUp = function(event) { this.dragData.occuring = false; var element = this.applyTo; // Reset transformations. element.style.MozTransform = ''; element.style.webkitTransform = ''; // Save the new position. element.style.left = (this.dragData.lastX + this.dragData.offsetX) + 'px'; element.style.top = (this.dragData.lastY + this.dragData.offsetY) + 'px'; // Remove useless events. window.removeEventListener('mousemove', this.mouseMove, false); window.removeEventListener('mousemove', this.mouseUp, false); }; Currently my dragging system is buggy and simple. I need more information on the logic that I should be applying.
0
0
0
0
1
0
I'm not sure if this is the right place to ask, but here goes... Short version: I'm trying to compute the orientation of a triangle on a plane, formed by the intersection of 3 edges, without explicitly computing the intersection points. Long version: I need to triangulate a PSLG on a triangle in 3D. The vertices of the PSLG are defined by the intersections of line segments with the plane through the triangle, and are guaranteed to lie within the triangle. Assuming I had the intersection points, I could project to 2D and use a point-line-side (or triangle signed area) test to determine the orientation of a triangle between any 3 intersection points. The problem is I can't explicitly compute the intersection points because of the floating-point error that accumulates when I find the line-plane intersection. To figure out if the line segments strike the triangle in the first place, I'm using some freely available robust geometric predicates, which give the sign of the volume of a tetrahedron, or equivalently which side of a plane a point lies on. I can determine if the line segment endpoints are on opposite sides of the plane through the triangle, then form tetrahedra between the line segment and each edge of the triangle to determine whether the intersection point lies within the triangle. Since I can't explicitly compute the intersection points, I'm wondering if there is a way to express the same 2D orient calculation in 3D using only the original points. If there are 3 edges striking the triangle that gives me 9 points in total to play with. Assuming what I'm asking is even possible (using only the 3D orient tests), then I'm guessing that I'll need to form some subset of all the possible tetrahedra between those 9 points. I'm having difficultly even visualizing this, let alone distilling it into a formula or code. I can't even google this because I don't know what the industry standard terminology might be for this type of problem. Any ideas how to proceed with this? Thanks. Perhaps I should ask MathOverflow as well... EDIT: After reading some of the comments, one thing that occurs to me... Perhaps if I could fit non-overlapping tetrahedra between the 3 line segments, then the orientation of any one of those that crossed the plane would be the answer I'm looking for. Other than when the edges enclose a simple triangular prism, I'm not sure this sub-problem is solvable either. EDIT: The requested image.
0
0
0
0
1
0
I know that sin is opposite/hypotenuse in a right angled triangle and cos is adjacent/hypotenuse. But when i come across functions like for Eg. In Flash :- something.x = Math.cos(someNumber) * someotherNumber; something.z = Math.sin(someNumber) * someotherNumber; what does it actually do? My stack overflows when i see such things. I don't understand trignometry that well. What is the opposite and what exactly is the hypotenuse in the above lines? And why does it use cos on one line and sin on other? Is there any shortcut for calculating these kind of things? Please help me. These things i didn't understand even when i took computer graphics classes and unfortunately even when i asked to my lecturer, she always used to tell, these things you already studied when you were in 7th grade. But i really don't remember that i studied anything like this. Thanks in advance :)
0
0
0
0
1
0
Is there something like automatic writing or surrealist automatism in programming?
0
1
0
0
0
0
I remember solving a lot of indefinite integration problems. There are certain standard methods of solving them, but nevertheless there are problems which take a combination of approaches to arrive at a solution. But how can we achieve the solution programatically. For instance look at the online integrator app of Mathematica. So how do we approach to write such a program which accepts a function as an argument and returns the indefinite integral of the function. PS. The input function can be assumed to be continuous(i.e. is not for instance sin(x)/x).
0
0
0
0
1
0
Is there an open source alternative to Mosek? Basically, I'm looking for large scale convex optimization solver packages. Thanks! EDIT: Forgot to mention earlier, problem is non-linear; mostly quadratic, but occasionally may need non-quadratic constraints + non-quadratic objective
0
0
0
0
1
0
well this is what i am doing: $total = (array_sum($odds))+$evens; $total = str_split($total); echo 'total[1]: '.$total[1].'<br />'; echo '10-$total[1]: ' . (10-($total[1])); and the output is: total[1]: 2 10-$total[1]: 87 my guess is it is being treated as a string, but how do i fix it? so, what i want to know is wh does (10-($total[1])); = 87? Update: yeah my mistake, a phantom 7, but can anyone now tell me why: echo $flybuys.' % '.$check.'<br />';    $res = $flybuys % $check;    echo 'res: '.$res; outputs: 6014359000000928 % 8 res: 7
0
0
0
0
1
0
I want to better understand what is required in order to implement a geo-spatial (aka proximity) search. I'd appreciate clarification on the following: Beyond the latitude & longitude for corresponding zip codes, what if anything, is required? Can anyone recommend any resources (books, websites, etc.) for understanding the formulas that can be used to calculate proximity such as: Haversine, Vincenty, Spherical? How easy and effective are Mysql's tools for implementing proximity searches? Does Google Maps have an API for proximity searches? For example if I provide, a zip code can it return zip codes within a set radius? I searched the Google Maps website but found nothing of the sort. Thanks.
0
0
0
0
1
0
Here is the setup. No assumptions for the values I am using. n=2; % dimension of vectors x and (square) matrix P r=2; % number of x vectors and P matrices x1 = [3;5] x2 = [9;6] x = cat(2,x1,x2) P1 = [6,11;15,-1] P2 = [2,21;-2,3] P(:,1)=P1(:) P(:,2)=P2(:) modePr = [-.4;16] TransPr=[5.9,0.1;20.2,-4.8] pred_modePr = TransPr'*modePr MixPr = TransPr.*(modePr*(pred_modePr.^(-1))') x0 = x*MixPr Then it was time to apply the following formula to get myP , where μij is MixPr. I used this code to get it: myP=zeros(n*n,r); Ptables(:,:,1)=P1; Ptables(:,:,2)=P2; for j=1:r for i = 1:r; temp = MixPr(i,j)*(Ptables(:,:,i) + ... (x(:,i)-x0(:,j))*(x(:,i)-x0(:,j))'); myP(:,j)= myP(:,j) + temp(:); end end Some brilliant guy proposed this formula as another way to produce myP for j=1:r xk1=x(:,j); PP=xk1*xk1'; PP0(:,j)=PP(:); xk1=x0(:,j); PP=xk1*xk1'; PP1(:,j)=PP(:); end myP = (P+PP0)*MixPr-PP1 I tried to formulate the equality between the two methods and seems to be this one. To make things easier, I skipped the summation of matrix P in both methods . where the first part denotes the formula that I used, and the second comes from his code snippet. Do you think this is an obvious equality? If yes, ignore all the above and just try to explain why. I could only start from the LHS, and after some algebra I think I proved it equals to the RHS. However I can't see how did he (or she) think of it in the first place.
0
0
0
0
1
0
regarding the stanford tagger, I've provided my own labelled corpus for training the model for the stanford tagger. However, I've realised that the tagging speed of my model for the tagger is much less slower than the default wsjleft3 tagger model. What might contribute to this? And how do I improve the speed of my model? (I've added 3 or 4 custom tags in addition to the Penn treebank tagsets)
0
1
0
0
0
0
Let's say I have a polygon with points: (0,0) (100,0) (100,100) (0,100) Lets also let it's center be (50,50). To rotate it would I add 50 to each component of each point, then do x' = cos(theta)*x - sin(theta)*y y' = sin(theta)*x + cos(theta)*y Then subtract 50 from each component of each point? Thanks
0
0
0
0
1
0
I know that to scale verticies I simply have to multiply by a scale factor. But I noticed that most vector drawing applications show the shapes bounding box and by dragging one of the edge it will scale the geometry toward the opposite edge, then if you go past this edge it will end up mirroring the geometry on that axis. How is scaling toward an edge done? Ex: If you select the topmost edge of a circle, it will scale toward the bottom edge of its bounding box until it looks like nothing, sort of like a raindrop that collapses when it hits the ground. I hope this is clear enough. Thanks
0
0
0
0
1
0
This is probably straight forward enough but for some reason I just can't crack it (well actually its because I'm terrible at maths sadly!). I have a viewport that shows 800 pixels at a time and I want to move it left and right over a virtual number of pixels say 2400 pixels wide. I use the relative position of a scrollbar (0-1) to determine the virtual pixel that the viewport should have moved to. I have a loop n = 800 that I run through. I want to start reading an array of plottin points from the position the slider tells me and iterate through the next 800 points from that point. The problem I have is when my scrollbar is all the way to the right and its relative position = 1 my readpoint = 2400..... which in a way is right. But that makes my read position of plotting points go to the last point and when I begin my iteration I have no points left to read. Based on my moving an 800 pixel wide sliding box analagy the left point of the box should be 1600 in this case and its right point should be 2400 How can I achieve this? Do I need some sort of value mapping formula? private function calculateShuttleRelativePosition():void { var _x:Number=_scrollthumb.x _sliderCenter=_x + (_scrollthumb.width / 2) _sliderRange=_scrollbar.width - _scrollthumb.width; _slider_rel_pos=(_sliderCenter - _sliderCenterMinLeft) / _sliderRange } pixel = slider relative position * 2400 readpoint= pixel
0
0
0
0
1
0
What is the maximum length (in kilometers or miles - but please specify) that one degree of latitude and longitude can have in the Earth surface? I'm not sure if I'm being clear enough, let me rephrase that. The Earth is not a perfect circle, as we all know, and a change of 1.0 in the latitude / longitude on the equator (or in Ecuador) can mean one distance while the same change at the poles can mean another completely different distance. I'm trying to shrink down the number of results returned by the database (in this case MySQL) so that I can calculate the distances between several points using the Great Circle formula. Instead of selecting all points and then calculating them individually I wish to select coordinates that are inside the latitude / longitude boundaries, e.g.: SELECT * FROM poi WHERE latitude >= 75 AND latitude <= 80 AND longitude >= 75 AND longitude <= 80; PS: It's late and I feel that my English didn't came up as I expected, if there is something that you are unable to understand please say so and I'll fix/improve it as needed, thanks.
0
0
0
0
1
0
If I have a matrix that is iterated horizontally and then vertically it would enumerate like this: 0 1 2 3 4 5 6 7 8 9 ------------------------------ 0 | 1 2 3 4 5 6 7 8 9 10 1 | 11 12 13 14 15 16 17 18 19 20 2 | 21 22 23 24 25 26 27 28 29 30 if I want to enumerate vertically I could do this: total_rows * coln+ rown+ 1 0 1 2 3 4 5 6 7 8 9 -------------------------- 0 |1 4 7 10 13 16 19 22 25 28 1 |2 5 8 11 14 17 20 23 26 29 2 |3 6 9 12 15 18 21 24 27 30 anybody have the algorithm handy to enumerate grouped columns vertically? ???? 0 1 2 3 4 5 6 7 8 9 ------------------------------ 0 |1 2 7 8 13 14 19 20 25 26 1 |3 4 9 10 15 16 21 22 27 28 2 |5 6 11 12 17 18 23 24 29 30
0
0
0
0
1
0
So I have a circle of planes which get constructed as: plane.x = Math.cos(angle) * radius; plane.z = Math.sin(angle) * radius; plane.rotationY = (-360 / numItems) * i - 90; which calculates how many angular slices there are for total number of planes (rotationY) and places each plane into it's place on a circle of radius. then to update their rotation around the circle I have: var rotateTo:Number = (-360 / numItems) * currentItem + 90; TweenLite.to(planesHolder, 1, { rotationY:rotateTo, ease:Quint.easeInOut } ); as you can see planes are circling and each is oriented 90 degrees out from the circle. I'm using this as a reference - it's pretty much that: http://papervision2.com/a-simple-papervision-carousel/ Now, what I'd like to find out is how could I calculate degree of orientation for each individual plane to always face camera without normal, if it's possible at all. I've tried plane.LookAt(camera), but that doesn't work. Basically every plane should have orientation as the one facing camera in the middle. Somehow I think I can't modify that example from link to do that. edit: OK I answered my own question after I wrote it. Helps to read your own thoughts written. So as I'm orienting planes individually and rotating them all as a group, what I did after tween of the group in code above, was to loop through each plane and orient it to the Y orientation of the forward plane as so: for (var i:int = 0; i < planes.length; i++) { TweenLite.to(planes[i], 1, { rotationY:(-360 / numItems * rotoItem - 90), ease:Quint.easeInOut } ); } rotoItem is the one at the front. Case closed.
0
0
0
0
1
0
It's been a while since my assembly class in college (20 years to be exact). When someone gives you a number, say 19444, and says that X is bits 15 through 8 and Y are bits 7 through 0... how do I calculate values of X and Y? I promise this is not homework, just a software guy unwisely trying to do some firmware programming.
0
0
0
0
1
0
Is there an easy way to take a String such as "5*4" and return 20?
0
0
0
0
1
0
Currently I am interning at a software company and one of my tasks has been to implement the recognition of mouse gestures. One of the senior developers helped me get started and provided code/projects that uses the $1 Unistroke Recognizer http://depts.washington.edu/aimgroup/proj/dollar/. I get, in a broad way, what the $1 Unistroke Recognizer is doing and how it works but am a bit overwhelmed with trying to understand all of the internals/finer details of it. My problem is that I am trying to recognize the gesture of moving the mouse downards, then upwards. The $1 Unistroke Recognizer determines that the gesture I created was a downwards gesture, which is infact what it ought to do. What I really would like it to do is say "I recognize a downards gesture AND THEN an upwards gesture." I do not know if the lack of understanding of the $1 Unistroke Recognizer completely is causing me to scratch my head, but does anyone have any ideas as to how to recognize two different gestures from moving the mouse downwards then upwards? Here is my idea that I thought might help me but would love for someone who is an expert or even knows just a bit more than me to let me know what you think. Any help or resources that you know of would be greatly appreciated. How My Application Currently Works: The way that my current application works is that I capture points from where the mouse cursor is while the user holds down the left mouse button. A list of points then gets feed to a the gesture recognizer and it then spits out what it thinks to be the best shape/gesture that cooresponds to the captured points. My Idea: What I wanted to do is before I feed the points to the gesture recognizer is to somehow go through all the points and break them down into separate lines or curves. This way I could feed each line/curve in one at a time and from the basic movements of down, up, left, right, diagonals, and curves I could determine the final shape/gesture. One way I thought would be good in determining if there are separate lines in my list of points is sampling groups of points and looking at their slope. If the slope of a sampled group of points differed X% from some other group of sampled points then it would be safe to assume that there is indeed a separate line present. What I Think Are Possible Problems In My Thinking: Where do I determine the end of a line and the start of a separate line? If I was to use the idea of checking the slope of a group of points and then determined that there was a separate line present that doesn't mean I nessecarily found the slope of a separate line. For example if you were to draw a straight edged "L" with a right angle and sample the slope of the points around the corner of the "L" you would see that the slope would give resonable indication that there is a separate line present but those points don't correspond to the start of a separate line. How to deal with the ever changing slope of a curved line? The gesture recognizer that I use handles curves already in the way I want it too. But I don't want my method that I use to determine separate lines keep on looking for these so called separate lines in a curve because its slope is changing all the time when I sample groups of points. Would I just stop sampling points once the slope changed more than X% so many times in a row? I'm not using the correct "type" of math for determining separate lines. Math isn't my strongest subject but I did do some research. I tried to look into Dot Products and see if that would point me in some direction, but I don't know if it will. Has anyone used Dot Prodcuts for doing something like this or some other method? Final Thoughts, Remarks, And Thanks: Part of my problem I feel like is that I don't know how to compeletly ask my question. I wouldn't be surprised if this problem has already been asked (in one way or another) and a solution exist that can be Googled. But my search results on Google didn't provide any solutions as I just don't know exactly how to ask my question yet. If you feel like it is confusing please let me know where and why and I will help clarify it. In doing so maybe my searches on Google will become more precise and I will be able to find a solution. I just want to say thanks again for reading my post. I know its long but didn't really know where else to ask it. Imma talk with some other people around the office but all of my best solutions I have used throughout school have come from the StackOverflow community so I owe much thanks to you. Edits To This Post: (7/6 4:00 PM) Another idea I thought about was comparing all the points before a Min/Max point. For example, if I moved the mouse downards then upwards, my starting point would be the current Max point while the point where I start moving the mouse back upwards would be my min point. I could then go ahead and look to see if there are any points after the min point and if so say that there could be a new potential line. I dunno how well this will work on other shapes like stars but thats another thing Im going to look into. Has anyone done something similar to this before?
0
0
0
0
1
0
I have a binary class dataset (0 / 1) with a large skew towards the "0" class (about 30000 vs 1500). There are 7 features for each instance, no missing values. When I use the J48 or any other tree classifier, I get almost all of the "1" instances misclassified as "0". Setting the classifier to "unpruned", setting minimum number of instances per leaf to 1, setting confidence factor to 1, adding a dummy attribute with instance ID number - all of this didn't help. I just can't create a model that overfits my data! I've also tried almost all of the other classifiers Weka provides, but got similar results. Using IB1 gets 100% accuracy (trainset on trainset) so it's not a problem of multiple instances with the same feature values and different classes. How can I create a completely unpruned tree? Or otherwise force Weka to overfit my data? Thanks. Update: Okay, this is absurd. I've used only about 3100 negative and 1200 positive examples, and this is the tree I got (unpruned!): J48 unpruned tree ------------------ F <= 0.90747: 1 (201.0/54.0) F > 0.90747: 0 (4153.0/1062.0) Needless to say, IB1 still gives 100% precision. Update 2: Don't know how I missed it - unpruned SimpleCart works and gives 100% accuracy train on train; pruned SimpleCart is not as biased as J48 and has a decent false positive and negative ratio.
0
0
0
1
0
0
I know this will really turn out to be simple, but my brain is just not working. I need a function in C# that will return -1 if the integer passed to the function has a negative sign, return 1 if the integer has a positive sign and return 0 if the number passed is 0. So for example: int Sign=SignFunction(-82); // Should return -1 int Sign2=SignFunction(197); // Should return 1 int Sign3=SignFunction(0); // Should return 0
0
0
0
0
1
0
I am creating a web shop and have to calculate how much to charge the customer to make sure that the fees are cancelled. The payment system adds the fees and I want the customer to pay them. The fees are 2.45% and € 1.10. This means that if the customer shops for € 100, and I report that value to the payment system, we will only get € 96.45. (100 - (2.45 + 1.1)). That is not good. How do I calculate the right value to send to the payment system, so that we get € 100? It is not just to say € 100 + 2.45% + € 1.1 = € 103.55 and report this to the payment system. Because then the payment system will say € 103.55 - ((2.45% of 103.55) + 1.1) € 103.55 - (2,536975 + 1.1) € 103.55 - 3,636975 € 99,913025 and that is, obviously, not correct. So how do I calculate what to send to the payment system to get the desired value? I have come so far, that it is the following equation: X - (X * 0.0245) - 1.10 = Y Here, X is the desired amount to send to the payment system and Y is the amount the customer has shopped for (100), therefore: X - (X * 0.0245) - 1.10 = 100 But how do I solve that to find out what X is? Thanks in advance
0
0
0
0
1
0
I'm trying to get GCC (or clang) to consistently use the SSE instruction for sqrt instead of the math library function for a computationally intensive scientific application. I've tried a variety of GCCs on various 32 and 64 bit OS X and Linux systems. I'm making sure to enable sse with -mfpmath=sse (and -march=core2 to satisfy GCCs requirement to use -mfpmath=sse on 32 bit). I'm also using -O3. Depending on the GCC or clang version, the generated assembly doesn't consistently use SSE's sqrtss. In some versions of GCC, all the sqrts use the instruction. In others, there is mixed usage of sqrtss and calling the math library function. Is there a way to give a hint or force the compiler to only use the SSE instruction?
0
0
0
0
1
0
I have an online RPG game which I'm taking seriously. Lately I've been having problem with users making bogus characters with bogus names, just a bunch of different letters. Like Ghytjrhfsdjfnsdms, Yiiiedawdmnwe, Hhhhhhhhhhejejekk. I force them to change names but it's becoming too much. What can I do about this? Could I somehow check so at least you can't use more than 2 of the same letter beside each other?? And also maybe if it contains vowels
0
1
0
0
0
0
I'm pretty new to NLP in general, but getting really good at Perl, and I was wondering what kind of powerful NLP modules are out there. Basically, I have a file with a bunch of paragraphs, and some of them are people's biographies. So, first I need to look for a person's name, and that helps with the rest of the process later. So I was roughly starting with something like this: foreach $PPid (0 .. $PPscalar) { $paragraph = @PP[$PPid]; if ($paragraph =~ /^(\w+ \w\. \w+|\w+ \w+)( also|)( has served| served| worked| joined| currently serves| has| was| is|, )/){ $possibleName = $1; $badName = 0; foreach $piece (@pieces){ if ($possibleName =~ /$piece/){ $badName = 1; } } if ($badName == 0){ push @namePile, $possibleName; } } } Because most of the names start at the beginning of the paragraphs. And then I'm looking for keywords that denote action or possession, but right now, that picks up extra junk that is not a name. There has to be a module to do this, right?
0
1
0
0
0
0
I'm currently doing some computation in Mathematica related to Quantum Mechanics. As we've moved from a 1D to 2D lattice model, the problem size is becoming problematic Currently, we have a summation that looks something like this: corr[r1_, r2_, i_, j_] = Sum[Cos[f[x1, x2] Angle[i] r1 + f[y1, y2] Angle[j] r2], {x1, HL}, {x2, HL}, {y1, HL + 1, 2 HL}, {y2, HL + 1, 2 HL}]; f[. , .] is a lookup function for a pre-computed correlation function, and Angle[.] is precomputed as well. There's no way at all to simplify this further in any way. We already took a simple optimization by converting a complex exponential (which had zero imaginary part) to the cosine expression above. The big problem is that those HL's are based on dimension size: For linear dimension L along an axis, HL corresponds to L^d (d = 2 here). So our computation is O(n^8) in reality, neglecting the sum over i, j. This normally isn't too bad for L = 8, if it weren't for the fact that we iterate this for 125 values of r1, and 125 of r2 to create an 125 x 125 image. My question is: How can I most efficiently calculate this in Mathematica? I would do this in another language but there are certain problems that will make it just as slow if I tried it in something like C++. Extra info: This is a ND-ND (number density) correlation calculation. All of the x's and y's refer to discete points on a discrete 2D grid. The only non-discrete thing here is our r's.
0
0
0
0
1
0
Here is the main problem. I have very large database (25,000 or so) of 48 dimensional vectors, each populated with values ranging from 0-255. The specifics are not so important but I figure it might help give context. I don't need a nearest neighbor, so approximate neighbor searches that are within a degree of accuracy are acceptable. I've been toying around with Locality Sensitivity Hashing but I'm very very lost. I've written a hash function as described in the article under "Stable Distributions" as best I can. Here is the code. def lsh(vector, mean, stdev, r = 1.0, a = None, b = None): if not a: a = [normalvariate(mean, stdev) for i in range(48)] if not b: b = uniform(0, r) hashVal = (sum([a[i]*vectorA[i] for i in range(48)]) + b)/r return hashVal The hashing function is 'working' at least some. If I order a list of points by hash value and compute average distance between a point and it's neighbor in the list, the average distance is about 400, compared to an average distance of about 530 for any two randomly selected points. My biggest questions are these. A: Any suggestions on where I can read more about this. My searching hasn't produced a lot of results. B: The method suggests it outputs an integer value (which mine does not). And then you're supposed to try to find matches for this integer value and a match denotes a likely nearest neighbor. I understand I'm supposed to compute some set of tables of hash values for all my points and then check said tables for hash matches, but the values I'm returning don't seem to be fine enough that I'll end up with matches at all. More testing is needed on my part. C: Instructions on how to construct hash functions based on the other hashing methods?
0
0
0
0
1
0
suppose i a have a multiplicative expression with lots of multiplicands (small expressions) expression = a*b*c*d*....*w where for example c is (x-1), d is (y**2-16), k is (xy-60)..... x,y are numbers and i know that c,d,k,j maybe zero Does the order i write the expression matters for faster evaluation? Is it better to write cdkj....*w or python will evaluate all expression no matter the order i write?
0
0
0
0
1
0
I know how to move, rotate, and scale, but how does skewing work? what would I have to do to a set of verticies to skew them? Thanks
0
0
0
0
1
0
I'm only familiar with the no-frills javadoc generator, however I'd like to include some mathematical equations in my javadoc (rather than constantly referencing another document). Is there a convenient option to do something like include/properly render LaTeX (most preferred - then I could just cut-n-paste) or MathML tags?
0
0
0
0
1
0
A product of n copies of a set S is denoted Sn. For example, {0, 1}3 is the set of all 3­-bit sequences: {0,1}3 = {(0,0,0),(0,0,1),(0,1,0),(0,1,1),(1,0,0),(1,0,1),(1,1,0),(1,1,1)} What's the simplest way to replicate this idea in Python?
0
0
0
0
1
0