text
stringlengths
0
27.6k
python
int64
0
1
DeepLearning or NLP
int64
0
1
Other
int64
0
1
Machine Learning
int64
0
1
Mathematics
int64
0
1
Trash
int64
0
1
I'm using a feed-foward neural network in python using the pybrain implementation. For the training, i'll be using the back-propagation algorithm. I know that with the neural-networks, we need to have just the right amount of data in order not to under/over-train the network. I could get about 1200 different templates of training data for the datasets. So here's the question: How do I calculate the optimal amount of data for my training? Since I've tried with 500 items in the dataset and it took many hours to converge, I would prefer not to have to try too much sizes. The results we're quite good with this last size but I would like to find the optimal amount. The neural network has about 7 inputs, 3 hidden nodes and one output.
0
1
0
1
0
0
I have just started learning about NLP and I have to do a course project this semester. what I want to do is : a.) Fetch the tweets from twitter for a particular topic ( How can I do that?? ) b.) Have already trained data against which I can decide if the tweets I fetched has positive or negative sentiment ( how to train this data ) c.) show the results to user I want to use Java for this, and I found that we can use LingPipe for this I am all new to this and building the app for the first time, so guidance is very much appreciated
0
1
0
0
0
0
I would like to find log/ln equation and express in javascript to graph google maps zoom against km distance. Unfortunately my javascript skills are better than my math skills. Values are approximate. km zoom 5 13 10 11 20 10 40 9 80 8 160 7 180 6 something like: zoom = Math.round((13/Math.log(km)));
0
0
0
0
1
0
I need to create a pogo stick that jumps across the screen in arcs. I was thinking the best way to do this would be to move it on a sin wave. If the top of the wave is 1, the ground is 0 and the bottom of the wave is -1, then every time it hits 0 I would reset the values to start the sin wave again. So instead of following the typical sin wave (0, 1, 0, -1, 0 etc) it would go 0, 1, 0, 1, 0 etc. Unfortunately my math is pretty terrible and I've been trying for hours to develop a formula. At the moment I'm just trying to make a normal sin wave where the top half emulates a pogo stick jumping, can't seem to even get that far. The closest I have is: m_vel.x++; float f = PI / 30 / 2; m_vel.y = 200 * sin(f * m_vel.x); m_vel.y = -m_vel.y; I need the waves to be quite narrow, and the high point to be quite high. The above formula starts off ok for the first iteration but then the waves get wider and the high and low points close in on each other. Can anyone help a math noob out?
0
0
0
0
1
0
I'm using matlab. I have matrix like 9 4 5 7 Its inverse must be k= [ 7 -4 -5 9] When I use inv matrix at matlab inv(k); I get adouble matrix Like (not true number) .37 -.32 -.32 .44 How can I get the inverse from the previous matrix? 7 -4 -5 9
0
0
0
0
1
0
Why is the output of the dResult invalid ? Env: Visual Studio 2008 int _tmain(int argc, _TCHAR* argv[]) { double dN = - 0.091023604111478473 ; double dD = 0.127777777777777; double dResult = pow( dN,dD ); //dResult = -1.#IND000000000000 return 0; }
0
0
0
0
1
0
What are the efficient algorithms for finding a vertex tour in a weighted undirected graph with maximum cost if we need to start from a particular vertex?
0
0
0
0
1
0
Is it the case with WPF since it's written from scratch, thus doesn't need to be like WinForms? Just like C# Math uses Double by default, right? I wanted to ask this after seeing classes like LinearDoubleKeyFrame, etc.
0
0
0
0
1
0
sadly I'm not really experienced in using random numbers in programming, despite the use of uniform integers in range. Therefore i have to questions regarding this topic. Question 1 (more specific): I'm looking for a way to chose array elements (dynamic size, but known) according to a probability distribution similar to the curve of "exponential decay" (http://en.wikipedia.org/wiki/Exponential_decay). Meaning: i want to prefer to chose the first elements rather than the others. I want an monotonic decreasing function (no growing before decreasing like in many well-known probability-distributions like the gamma-distribution). Maybe the geometric-distribution is something which i could use? But then i need an answer to my second question regarding the scaling of this distribution to array indexes. The dual method to prefer choosing the last elements rather than the first would be ok too, of course. Question 2 (more general): Is there a concept in any implementation which will scale me any continuous random-distribution to a given array-range (including discretization)? Example: Use a gaussian normal distribution and the result is always a valid index in some array (meaning: the middle elements are preferred). Could this (link text) be something like i want to use? Platform and Libraries: I'm programming in C++ and use the boost::random library at the moment (link text), but i'm willing to use something like the the gsl library or other quality libraries. One more wish: I would prefer a way using some quality libraries rather than some quick-and-dirty custom_functions. Thanks!
0
0
0
0
1
0
What standard naming conventions and or math libraries do you use? I currently use #include <stdint.h> typedef float float32_t; typedef double float64_t; /*! ISO C99: 7.18 Integer types 8, 16, 32, or 64 bits intN_t = two’s complement signed integer type with width N, no padding bits. uintN_t = an unsigned integer type with width N. floatN_t = N bit IEE 754 float. uintN_t intN_t floatN_t bits unsigned-integer signed-integer IEE754 float 8 16 unsigned short short ??"half" 32 unsigned int float 64 unsigned long long double 128 ?? "Long double" "quad" ??*/ but as you can see I am yet to decide upon a math library. Original Question: Recommendation for a small math library with Straight forward naming convention. Does anyone know of any small C libraries with straightforward naming conventions? This is what im using right now: typedef unsigned short UInt16; typedef short Int16; typedef unsigned UInt32; typedef int Int32; typedef float Float32; typedef unsigned long UInt64; typedef long int Int64; typedef double Float64; What do you use??
0
0
0
0
1
0
The formula for half vector is (Hv) = (Lv + Vv) / |Lv+Vv|, where Lv is light vector, and Vv is view vector. Am I doing this right in Python code? Vvx = 0-xi # view vector (calculating it from surface points) Vvy = 0-yi Vvz = 0-zi Vv = math.sqrt((Vvx * Vvx) + (Vvy * Vvy) + (Vvz * Vvz)) # normalizing Vvx = Vvx / Vv Vvy = Vvy / Vv Vvz = Vvz / Vv Lv = (1,1,1) # light vector Hn = math.sqrt(((1 + Vvx) * (1 + Vvx)) + ((1 + Vvy) * (1 + Vvy)) + ((1 + Vvz) * (1 + Vvz))) Hv = ((1 + Vvx) / Hn, (1 + Vvy) / Hn, (1 + Vvz) / Hn) # half-way vector
0
0
0
0
1
0
Why are the outcomes different for first and first1? I'm guessing it has to do with the limit for the Long type. long seconds = System.currentTimeMillis(); long first = (seconds / (1000*60*60*24))/365; long first1 = seconds / (1000*60*60*24*365); System.out.println(first); System.out.println(first1); Thanks!
0
0
0
0
1
0
How can I prove that n! is not in O(n^p) for any constant natural number p? And is (n k)(n choose k) in O(n^p), for all k?
0
0
0
0
1
0
I was reading stuffs about pattern recognition. Recently I want to make a survey of methods to evaluate similarities of vectors. As far as I know, there are Euclidean distances, Mahalanobis distances and Cosine Distance. Can anyone present some more names or keywords to search?
0
0
0
1
0
0
I need to find the complexity of the current recurrence: T(n) = 1/(T(n-1) + 1) + 1 thanks in advance for any idea or link with useful information
0
0
0
0
1
0
I search for Math editors for writing formulas in asp.net I want something like exist in http://math.stackexchange.com , Could any suggest a free good one ?
0
0
0
0
1
0
Let Os be a partially ordered set, and given any two objects O1 and O2 in Os, F(O1,O2) will return 1 if O1 is bigger than O2, -1 if O1 is smaller than O2, 2 if they are incomparable, and 0 if O1 is equal to O2. I need to find the subset Mn of elements is Os that are the minimum. That is for each A in Mn, and for each B in Os, F(A,B) is never equal to 1. It is not hard to do, but I am convinced it could be done in a more pythonic way. The fast and dirty way is: def GetMinOs(Os): Mn=set([]) NotMn=set([]) for O1 in Os: for O2 in Os: rel=f(O1,O2) if rel==1: NotMn|=set([O1]) elif rel==-1: NotMn|=set([O2]) Mn=Os-NotMn return Mn In particular I am not happy with the fact that I am essentially going through all the elements N^2 times. I wonder if there could be a dynamic way. By "dynamic" I don't mean merely fast, but also such that once something is discovered being not a possible in the minimum, maybe it could be taken off. And doing all this in a pythonic, elegant way
0
0
0
0
1
0
I want to compute the moment of inertia of a (2D) concave polygon. I found this on the internet. But I'm not very sure how to interpret the formula... Formula http://img101.imageshack.us/img101/8141/92175941c14cadeeb956d8f.gif 1) Is this formula correct? 2) If so, is my convertion to C++ correct? float sum (0); for (int i = 0; i < N; i++) // N = number of vertices { int j = (i + 1) % N; sum += (p[j].y - p[i].y) * (p[j].x + p[i].x) * (pow(p[j].x, 2) + pow(p[i].x, 2)) - (p[j].x - p[i].x) * (p[j].y + p[i].y) * (pow(p[j].y, 2) + pow(p[i].y, 2)); } float inertia = (1.f / 12.f * sum) * density; Martijn
0
0
0
0
1
0
I am looking for a clean way to list the (8 bit) integers whose binary representation is not the same as another integer up to rotation and reflection. For example the list will probably start as 0 1 (2=10b is skipped because you can rotate the bits in 1, therefore all powers of 2 are skipped. Also every number except 0 will be odd) 3=11b 5=101b 7=111b 9=1001b 11=1011b (so 13=1101b will be skipped because 11010000b is a reflection of 1101b which can then be rotated to the right 4 times ) . . . Also ideally how could this be generalized to numbers with different numbers of bits, (16, 32, or just n) and other bases beside 2.
0
0
0
0
1
0
When representing a mathematical matrix, rotations are performed as follows: http://en.wikipedia.org/wiki/Rotation_matrix#Basic_rotations Rx(θ) = 1 0 0 0 cos θ -sin θ 0 sin θ cos θ Ry(θ) = cos θ 0 sin θ 0 1 0 -sin θ 0 cos θ Rz(θ) = cos θ -sin θ 0 sin θ cos θ 0 0 0 1 However, I've discovered that Direct3D uses the transpose of these rotation matrices. In my app I have a generic Matrix class which uses the standard mathematical rotation representations. With a simple rotation about 1 axis, it is easy to convert to a Direct3D matrix, as you can just do the transposition. However, if you rotate about x, y and then z you cannot simply get the transposed matrix. My question is, how can I convert a mathematical matrix in to a Direct3D matrix? Here is an example: Matrix matrix; matrix.RotateX(1.0f); matrix.RotateY(1.0f); matrix.RotateZ(1.0f); Mathematical matrix = m_11 0.29192656 float m_12 -0.45464867 float m_13 0.84147096 float m_14 0.00000000 float m_21 0.83722234 float m_22 -0.30389664 float m_23 -0.45464867 float m_24 0.00000000 float m_31 0.46242565 float m_32 0.83722234 float m_33 0.29192656 float m_34 0.00000000 float m_41 0.00000000 float m_42 0.00000000 float m_43 0.00000000 float m_44 1.0000000 float Direct3D matrix = _11 0.29192656 float _12 0.45464867 float _13 -0.84147096 float _14 0.00000000 float _21 -0.072075009 float _22 0.88774973 float _23 0.45464867 float _24 0.00000000 float _31 0.95372111 float _32 -0.072075009 float _33 0.29192656 float _34 0.00000000 float _41 0.00000000 float _42 0.00000000 float _43 0.00000000 float _44 1.0000000 float Edit: Here are some examples of individual rotations. X-Axis rotation by 1 radian My matrix class: 1.0000000 0.00000000 0.00000000 0.00000000 0.00000000 0.54030228 -0.84147096 0.00000000 0.00000000 0.84147096 0.54030228 0.00000000 0.00000000 0.00000000 0.00000000 1.0000000 Direct3D: 1.0000000 0.00000000 0.00000000 0.00000000 0.00000000 0.54030228 0.84147096 0.00000000 0.00000000 -0.84147096 0.54030228 0.00000000 0.00000000 0.00000000 0.00000000 1.0000000 As you can see, the Direct3D matrix is exactly the transpose of my matrix class (my class gives the same results as the examples given by Wikipedia at the top of this question).
0
0
0
0
1
0
I'm trying to solve a problem I've got on my homework. How can I check if a value is within a range, e.g. 1 ≤ value ≤ 31, without using if, switch, or any other control structure, in Java?
0
0
0
0
1
0
I'm in need of floating point calculations for C# that can correctly store up to maybe 500 digits/decimals. Is there any built-in-type for this, do I have to create it myself, any library available or what is the best way to go? Thanks
0
0
0
0
1
0
Hi I want to use MALLET's topic modeling but can i provide my own tokenizer or tokenized version of the text documents when i import the data into mallet? I find MALLET's tokenizer inadequate for my usage...
0
1
0
0
0
0
I work in GIS with VBA. I have a geometric network that contains 2 layer River (polyline) and Hydrometry station (Point). I want to find the closest Point to the selected River, but I want that distance to be measured on the network, not the direct distance. How can I code this in VBA?
0
0
0
0
1
0
I have a "box" made out of two three-dimensional vectors. One for the front-lower-left corner and one for the back-upper-right corner. Are there any simple way to check if a third three-dimensional vector is anywhere inside this "box"? First i wrote simething like (psuedo): p = pointToCompare; a = frontLowerLeft; b = backUpperRight; if(p.x >= a.x && p.x <= b.x && p.y >= a.y ... But that does only work if all coordinates are positive, which they won't always be. Should i do something like the above, or are there any better/simpler way to do this calculation? If you would like to know, this is the Vector and it's method i'm using: http://www.jmonkeyengine.com/doc/com/jme/math/Vector3f.html
0
0
0
0
1
0
I would like some guidance on how to split a string into N number of separate strings based on a arithmetical operation; for example string.length()/300. I am aware of ways to do it with delimiters such as testString.split(","); but how does one uses greedy/reluctant/possessive quantifiers with the split method? Update: As per request a similar example of what am looking to achieve; String X = "32028783836295C75546F7272656E745C756E742E657865000032002E002E005C0" Resulting in X/3 (more or less... done by hand) X[0] = 32028783836295C75546F X[1] = 6E745C756E742E6578650 x[2] = 65000032002E002E005C0 Dont worry about explaining how to put it into the array, I have no problem with that, only on how to split without using a delimiter, but an arithmetic operation
0
0
0
0
1
0
We are building a database of scientific papers and performing analysis on the abstracts. The goal is to be able to say "Interest in this topic has gone up 20% from last year". I've already tried key word analysis and haven't really liked the results. So now I am trying to move onto phrases and proximity of words to each other and realize I'm am in over my head. Can anyone point me to a better solution to this, or at very least give me a good term to google to learn more? The language used is python but I don't think that really affects your answer. Thanks in advance for the help.
0
1
0
0
0
0
I'm building an Asteroids Game for a class assignement. To finish it I need a line-intersection algorithm/code. I found one that works, but i do not understand the math behind it. How does this work? point* inter( point p1, point p2, point p3, point p4) { point* r; //p1-p2 is the first edge. //p3-p4 is the second edge. r = new point; float x1 = p1.x, x2 = p2.x, x3 = p3.x, x4 = p4.x; float y1 = p1.y, y2 = p2.y, y3 = p3.y, y4 = p4.y; //I do not understand what this d represents. float d = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4); // If d is zero, there is no intersection if (d == 0) return NULL; // I do not understand what this pre and pos means and // how it's used to get the x and y of the intersection float pre = (x1*y2 - y1*x2), pos = (x3*y4 - y3*x4); float x = ( pre * (x3 - x4) - (x1 - x2) * pos ) / d; float y = ( pre * (y3 - y4) - (y1 - y2) * pos ) / d; // Check if the x and y coordinates are within both lines if ( x < min(x1, x2) || x > max(x1, x2) || x < min(x3, x4) || x > max(x3, x4) ) return NULL; if ( y < min(y1, y2) || y > max(y1, y2) || y < min(y3, y4) || y > max(y3, y4) ) return NULL; cout << "Inter X : " << x << endl; cout << "Inter Y : " << y << endl; // Return the point of intersection r->x = x; r->y = y; return r; }
0
0
0
0
1
0
I'm building a wheel menu control. The idea is you spin the wheel until the item you want to act on is in view, then you click on it or whatever. I'm trying to figure out how to translate the user's mouse movements (x & y) into the number of degrees to spin the wheel. I can implement it all, I just am missing the math to do the conversion. Any help or pointers are appreciated!
0
0
0
0
1
0
Ok, so I'm doing the power method in python. Basically, the equation revolves around multiplying a matrix A by a vector (y) like this: for i in range(0, 100): y = mult(matrix,y) y = scalarMult(y, 1.0/y[0][0]) Then you multiply the vector y by 1/(the first element in y). Now, if the matrix is sparse or has a zero in just the right spot, you will get a zero for the first element in a. None of my googling skills have yielded a modification to the power method to avoid this. For those interested, I'm trying to solve for the eigenvalues of a matrix; and my code works as long as there aren't too many zeros.
0
0
0
0
1
0
I've tried asking this before on the OpenNLP sourceforge page, but it is still sadly languishing in the Help forums: I have a treebank and I would like to train a model based on it. There was some code lying around using ParserME but that class doesn't seem to exist anymore. It looks like its been possibly replaced by TreebankParser but I can't seem to find any train tools in there. Is there a way of doing this? Any hints welcome
0
1
0
0
0
0
I have the next code, which gets a number, I need to split that number in to parts, firstPart should be the whole number without the last digit, and the secondPart should be only the last digit of the original number. public Boolean verificationNumberFiscalId(String fiscalId) { // Trying to do a better wa yto do it Integer firstPart = fiscalId.length()-1; Integer secondPart = ??????????; // My old logic String NitValue = ""; for (Integer i = 0; i < fiscalId.length()-1; i++) { NitValue = fiscalId.substring(i,1); } Integer actualValueLength = fiscalId.length()-1; String digitoVerificador = fiscalId.substring(actualValueLength,1); return this.generateDigitoVerification(NitValue) == digitoVerificador; } /** * @param nit * @return digitoVerificador * @comment: Does the math logic */ public String generateDigitoVerification(String nit) { Integer[] nums = { 3, 7, 13, 17, 19, 23, 29, 37, 41, 43, 47, 53, 59, 67, 71 }; Integer sum = 0; String str = String.valueOf(nit); for (Integer i = str.length() - 1, j=0; i >= 0; i--, j++) { sum += Character.digit(str.charAt(i), 10) * nums[j]; } Integer dv = (sum % 11) > 1 ? (11 - (sum % 11)) : (sum % 11); return dv.toString(); } Could you suggest me a better way to do it please? Thank you!
0
0
0
0
1
0
We have a predefined set of packaging material available (read: boxes). We have a set of object that need to be packaged in one of these boxes. We know the dimensions of each packaging material. We know the dimensions of each object. We know no more than one box will be used. Now the most basic approach would probably be: calculate volume of combined products and take the box that is the closest match to this value (never below though). But this does not take into account the different shapes/dimensions of objects. So one would also have to add the requirement that the box at the very least can contain the largest object (of all the objects given) dimensions wise. We're looking at a way of figuring out how we can loop through each product, virtually put it in the box, and then proceed with the space remaining (taking into account an object can fit into this space in various ways).
0
0
0
0
1
0
I get a return value from a web service in minutes, for example 538 minutes. I need to break this down in hours and minutes. What is the fastest way, in .net code and also VB6 code (two apps use the service) to convert this from minutes to HH:mm? Thanks
0
0
0
0
1
0
What is the easiest way to achieve: a => 1, b => 0, c=> 3 a => 0, b => 10, c=> 1 Sum a => 1, b =>10, c=>4 and Minus a => -1, b=> 10, c=> -2 I hope my examples make it clear... If you have any questions please leave a comment
0
0
0
0
1
0
I wouldn't call myself a master regarding regex, i pretty much just know the basics. I've been playing around with it, but i can't seem to get the desired result. So if someone would help me, i would really appreciate it! I'm trying to check wether unwanted words exist in a string. I'm working on a math project, and i'm gonna be using eval() to calculate the string, so i need to make sure it's safe. The string may contain (just for example now, i'll add more functions later) the following words: (read the comments) floor() // spaces or numbers are allowed between the () chars. If possible, i'd also like to allow other math functions inside, so it'd look like: floor( floor(8)*1 ). It may contain any digit, any math sign (+ - * /) and dots/commas (,.) anywhere in the string Just to be clear, here's another example: If a string like this is passed, i do not want it to pass: 9*9 + include('somefile') / floor(2) // Just a random example on something that's not allowed Now that i think about it, it looks kind of complicated. I hope you can at least give me some hints. Thanks in advance, -Anthony Edit: This is a bit off-topic, but if you know a better way of calculating math functions, please suggest it. I've been looking for a safe math class/function that calculates an input string, but i haven't found one yet.
0
0
0
0
1
0
I have a simple problem that deals with math operators. Suppose I have something like 3//4 4 -- 3 Would the result be 12 for the first one and 1 for the second one?
0
0
0
0
1
0
What is the difference between the two pieces of pseudo-code? // Multiplying a matrix by the difference between each frame float difference = current - previous; // Time since previous frame float angle = difference / 500; matrix rotation; rotation.RotateX(angle); rotation.RotateY(angle); worldMatrix *= rotation; // Note multiply // Multiplying a matrix by the difference between current and start float difference = current - start; // Time since first frame float angle = difference / 500; matrix rotation; rotation.RotateX(angle); rotation.RotateY(angle); worldMatrix = rotation; // Note assignment There are only very minor differences between each piece of code, but lead to big visual differences. The input looks like this: Frame 1: Rotation = 1 radian worldMatrix *= rotation; Frame 2: Rotation = 1 radian worldMatrix *= rotation; etc... Frame 1: Rotation = 1 radian worldMatrix = rotation; Frame 2: Rotation = 2 radians worldMatrix = rotation; etc...
0
0
0
0
1
0
Present value is the value on a given date of a future payment or series of future payments, discounted to reflect the time value of money and other factors such as investment risk. Present value calculations are widely used in business and economics to provide a means to compare cash flows at different times on a meaningful "like to like" basis. http://en.wikipedia.org/wiki/Present_value What would be the best way to tackle this in an Objective-C function? double retire62 = [benefit62.text doubleValue] * [yearlyReturn.text doubleValue] *12* [lblAgeExpectancy.text doubleValue]; double retire66 = [benefit66.text doubleValue] * [yearlyReturn.text doubleValue] *12* [lblAgeExpectancy.text doubleValue]; double retire70 = [benefit70.text doubleValue] * [yearlyReturn.text doubleValue] *12* [lblAgeExpectancy.text doubleValue]; Im just not familiar with Present Value/
0
0
0
0
1
0
This is an interview question. "Given an array of numbers and another number, work out whether the array of numbers can be manipulated using standard mathematical techniques to equal the other number given. e.g. given 5 and 10, can you make 50? 5 * 10 = 50, so yes". (Let's assume only arithmetic operations for simplicity). I would propose to use a brute-force search (with some branch and bound). Does it make sense ?
0
0
0
0
1
0
I have the language {a^i b^j c^k | i,j,k>=0 & i>j & j>k} I began by assuming some m is picked for me, such that a string z = a^m b^(m-1) c^(m-2) Then the string is split up into (z =) uvwxy so that vx are not empty and #(vwx)<=m Then when I get to pick an "i" I get confused. Say I pick i=1 then I have: uv^1wx^1y and I'm not entirely sure where to go from that because to me it looks like I could pick a vwx that IS in the language. Any suggestions?
0
0
0
0
1
0
I'm looking to convert Pinyin where the tone marks are written with accents (e.g.: Nín hǎo) to Pinyin written in numerical/ASCII form (e.g.: Nin2 hao1). Does anyone know of any libraries for this, preferably PHP? Or know Chinese/Pinyin well enough to comment? I started writing one myself that was rather simple, but I don't speak Chinese and don't fully understand the rules of when words should be split up with a space. I was able to write a translator that converts: Nín hǎo. Wǒ shì zhōng guó rén ==> Nin2 hao3. Wo3 shi4 zhong1 guo2 ren2 But how do you handle words like the following - do they get split up with a space into multiple words, or do you interject the tone numbers within the word (if so, where?) : huā shíjiān, wèishénme, yuèláiyuè, shēngbìng, etc.
0
1
0
0
0
0
I have a simple question. I'm doing some light crawling so new content arrives every few days. I've written a tokenizer and would like to use it for some text mining purposes. Specifically, I'm using Mallet's topic modeling tool and one of the pipe is to tokenize the text into tokens before further processing can be done. With the amount of text in my database, it takes a substantial amount of time tokenizing the text (I'm using regex here). As such, is it a norm to store the tokenized text in the db so that tokenized data can be readily available and tokenizing can be skipped if I need them for other text mining purposes such as Topic modeling, POS tagging? What are the cons of this approach?
0
1
0
0
0
0
I'm working on a 2D game in XNA based around flocking. I've implemented Craig Reynold's flocking technique and now I want to dynamically assign a leader to the group to guide it towards a target. To do this, I want to find a game agent that does not have any other agents in front of it and make it the leader but I'm unsure of the maths for this. Currently I have: Vector2 separation = agentContext.Entity.Position - otherAgent.Entity.Position; float angleToAgent = (float) Math.Atan2(separation.Y, separation.X); float angleDifference = Math.Abs(agentContext.Entity.Rotation - angleToAgent); bool isVisible = angleDifference >= 0 && angleDifference <= agentContext.ViewAngle; agentContext.ViewAngle is a radians values which I have played with to try and get the right effect but this mostly results in all agents being assigned as leaders. Can anyone point me in the right direction to detect if an entity is within a "cone" of view of another entity?
0
1
0
0
0
0
i have a csv file with data like this: -0.0889 4.53 -0.0449 2.25 -0.013 -3 0.0304 -4.28 0.0669 -2.03 0.1332 -1.72 And it goes on and on. I need a solution to plot it as a not connected points on simple 2D chart and save it as png file to see if data is organized by a clearly visible pattern.
0
0
0
0
1
0
I was wondering if anyone knows a way to convert scary looking maths equations (without being able to understand them) into pseudocode so I can implement it into Java? If anyone knows of a tool that could help me understand this equation that would be great. Radon Transform Thanks for any help!
0
0
0
0
1
0
In my code: Vector2 colCircle = new Vector2(); colCircle = new Vector2((R * Math.Sin(D)), -(R * Math.Cos(D))); While: R = 22.627 D = 89.214 When checked on my calculator, the X value is correct, but the Y value should be -0.310 but in program it is -7.134. Any ideas why?
0
0
0
0
1
0
I have 3 images. 1.jpg, 2.jpg, 3.jpg. I want to distribute them into three img elements randomly (on window refresh, the three images' positions will change). How do I use Math.random() here? Thanks. <img src='' id='img1' /> <img src='' id='img2' /> <img src='' id='img3' />
0
0
0
0
1
0
I want to produce a natural number (a positive integer between 0 and x) by using lcg_value(). This is what I can see from the actual source code for the function: /* * combinedLCG() returns a pseudo random number in the range of (0, 1). * The function combines two CGs with periods of * 2^31 - 85 and 2^31 - 249. The period of this function * is equal to the product of both primes. */ Now, how would I turn that float into a natural number so that I do not lose information/entropy. Currently I just do it like this: $number = pow(2,31) * lcg_value(); However, I have a feeling in my gut that it's not perfect. How about 2^62? Or perhaps 2^31-334? Or 2^62-334? I don't know.
0
0
0
0
1
0
Assume you're given a circle with the line AB containing its center O, such that A and B are on the circle (OA=OB=radius). A tangent t is drawn on the point A, and I should calculate the mapping of certain points (a,b,c,d...) of the circle to the points on the tangent (at, bt, ct, dt, ...) such that the distance Aa (the distance along the circle) is the same as the distance Aat (the distance along the tangent) (and the same for the distances Ab, Ac, Ad). But, here, certain constraint should be considered: those points of the circle (among (a, b, c, d)) that are from one side of the circle from A to B should be placed on one side of the tangent (the nearer), and those from the other side of the circle form A to B should be placed on the other side. Basically, the circle should be split at B, and then mapped to the tangent. I hope this explanation is sufficient enough. It should be noted that I have information about coordinates of A, B, O, a, b, c, d. I supposed to calculate (at, bt, ct, dt). For solving this problem, I have two approaches, but I'm not sure how I could make sure they always work correctly. 1) I calculate the equation of the tangent at point A. Then for each point (a, b, c, d) I calculate the distance from A (along the circle), and use these distances for calculating (at, bt, ct, dt...) along the tangent. What I dont know here is how to calculate the distances from A to (a, b, c, d). The problem is the 'proper side' determination, meaning how should I determine whether the point should be mapped on one side of the tangent or the other. What would be the way to determine this. 2) I calculate the equation of the tangent at point A. Then for each point (a, b, c, d) I calculate the distance from A (along the circle), and use these distances for calculating (at, bt, ct, dt...) along the tangent. To determine the 'proper side' of a given point, I might use the projection of that point to the tangent. But, even with this, how I know 'which side is which'? Perhaps there are much simpler ways to do this. Any suggestion on how to do this is welcome. In case I was not precise enough, I'll elaborate.
0
0
0
0
1
0
I am trying to create a function that generates a random integer out of the bytes I get from /dev/urandom. I am doing this in PHP and it currently looks like: public static function getRandomInteger($min, $max) { // First we need to determine how many bytes we need to construct $min-$max range. $difference = $max-$min; $bytesNeeded = ceil($difference/256); $randomBytes = self::getRandomBytes($bytesNeeded); // Let's sum up all bytes. $sum = 0; for ($a = 0; $a < $bytesNeeded; $a++) $sum += ord($randomBytes[$a]); // Make sure we don't push the limits. $sum = $sum % ($difference); return $sum + $min; } Everything works great except that I think it's not calculating the values exactly fair. For example, if you want to have a random value between 0 and 250, it receives one byte and mods it with 250 so the values of 0-6 are more likely to appear than the values of 7-250. What should I do to fix this?
0
0
0
0
1
0
My highschool years are far behind and I'm having trouble remembering how to isolate the "a" variable in this equation : ln(20) = ln(a) + 3 * b b = 0.4605 From this website (last section, at the very bottom http://mathonweb.com/help_ebook/html/expoapps_3.htm) : "Back-substituting b into either of the previous equations gives ln (a) = 4.377, and anti-logging gives a = 79.6" I know this is fairly simple and I just need a quick help! Thanks a lot for your time Joel
0
0
0
0
1
0
I'm doing some experiments with opengl in c for linux. I've got the following function that would draw a circle given those parameters. I've included #include <stdlib.h> #include <math.h> #include <GL/gl.h> #include <GL/glut.h> However when I compile: gcc fiver.c -o fiver -lglut I get: /usr/bin/ld: /tmp/ccGdx4hW.o: undefined reference to symbol 'sin@@GLIBC_2.2.5' /usr/bin/ld: note: 'sin@@GLIBC_2.2.5' is defined in DSO /lib64/libm.so.6 so try adding it to the linker command line /lib64/libm.so.6: could not read symbols: Invalid operation collect2: ld returned 1 exit status The function is the following: void drawCircle (int xc, int yc, int rad) { // // draw a circle centered at (xc,yc) with radius rad // glBegin(GL_LINE_LOOP); // int angle; for(angle = 0; angle < 365; angle = angle+5) { double angle_radians = angle * (float)3.14159 / (float)180; float x = xc + rad * (float)cos(angle_radians); float y = yc + rad * (float)sin(angle_radians); glVertex3f(x,0,y); } glEnd(); } Does anyone know what's wrong?
0
0
0
0
1
0
Recently I've studied the backpropagation network and have done some manual exercise. After that, I came up with a question( maybe doesn't make sense): is there any thing important in following two different replacement methods: 1. Incremental Training: weights are immediately updated once all the delta Wij's are known and before presenting the next training vector. 2. Batch Training: delta Wij's are computed and stored for each exemplar training vector. However, the delta Wij's are not immediately used to update the weights. Weight updating is done at the end of a training epoch. I've googled for a while but haven't found any results.
0
0
0
1
0
0
I have a simple Android app that does some math on 2 numbers that the user inputs and returns the result. Currently I have a 'calculate' button that needs to be pressed to do the math and return the value. How can I get rid of this button and just get the app to run the math after the uses has changed either one of the 2 numbers? Many thanks.
0
0
0
0
1
0
Lets say that I have a math function that is defined recursively. Like so: T(1)(x) = 1 T(n)(x) = 2x*T(n-1)(x)-1 So: T(1)(x) = 1 T(2)(x) = 2x*1-1 = 2x-1 T(3)(x) = 2x*(2x-1)-1 = 4x^2 - 2x - 1 /* and so on... */ Basically, I know how to write a program that will count T(15)(x) if the x is given. Thats not a problem. What I wonder, however is - how to write a program that will give me a polynomial for like T(10)(x) (one looking something like: 16x^4 + 3x^3 ...). In the nutshell: How can I recursively count the math expression, but using x as a variable (not set). Any help would be greatly appreciated, Paul
0
0
0
0
1
0
I am a hobbyist programming for an embedded application. The application requires speed. I would like to determine whether or not a certain variable (call it "X") has passed a certain percentage (call it "Y") of another variable (call it "Z"). X, Y, and Z can all change at runtime. Since I need speed I would like to do this using integer math as opposed to float, which incurs a speed penalty. Are there any tricks for doing this? I am a self trained programmer so please excuse me if this is a well known problem with a well known solution. Thank you!
0
0
0
0
1
0
While Mahjong (the actual game, not Mahjong solitare) is fairly simple in terms of basic rules and gameplay, setting objectives for the AI to transition to aim for certain end game goals seems fairly complex. Is anyone aware of any papers, research, or other materials related to this topic?
0
1
0
0
0
0
Is there an easy way to find the number of edges, faces and vertices in a polygon (say decagon or hendecagon). Is this data available as part of a java library or should it be manually derived from the wiki data.
0
0
0
0
1
0
I'm trying to process a CSV file that has as in each row a text field with the name of organization and position of an individual within that organization as unstructured text. This field is usually a mess of text like this: Assoc. Research Professor Dept. Psychology Univ. California Santa Barbara I need to pull out the position and the organization name. For the position, I use preg_match for a series of about 60 different regular expressions for the different professions, and I think it works pretty well (my guess is that it catches about 80%). But, I'm having trouble catching the organization name. I have a MySQL table with roughly 16,000 organization names that I can perform a simple preg_match for, but due to common misspellings and abbreviations, it's only catching about 30% of the organizations. For example, my database has University of California Santa Barbara But the CSV file might have any of the options: Univ Cal Santa Barbara University Cal-Santa Barbara University California-Santa Barbara Cal University, Santa Barbara I need to process several hundred thousand records, and I can't spend the time to correct 70% of the records that are currently not being processed correctly or painstakingly create multiple aliases for each organization. What I would like to be able to do is to catch small differences (such as the small misspellings, hyphens versus spaces, and common abbreviations), and, if still no matches are found, to ideally recognize an organizational name and create a new record for it. What libraries or tools in Python or PHP would allow to perform a similarity match that would have a broader reach? Would NLTK in Python catch misspellings? Is it possible to use AlchemyAPI to catch misspelled organizations? So far I've only been able to use it to catch correctly spelled organizations Since I'm comparing a short string (the organization name) to a longer string (that includes the name plus extraneous information) is there any hope in using PHP's similar_text function? Any help or insight would be appreciated.
0
1
0
0
0
0
Hi I know that blind convex hull has o(n^4) but I have never seen its code! Is there any site that has its code? thanks
0
0
0
0
1
0
How can I calculate a pie slice bounding rectangle. Radius (r), center point (x0, y0) , StartAngle (a0), EndAngle (a1) and drawDirection (clockwise or counterclockwise) variables are known.
0
0
0
0
1
0
I'm being quite dim - I can't figure out what should probably be a fairly trivial trig problem. Given cartesian coordinates (x, y, z), I would like to determine a new coordinate given a direction (x, y and z angles) and a distance to travel. class Cartesian() { int x = 0; int y = 0; int z = 0; int move (int distance, int x_angle, int y_angle, int z_angle) { x += distance * //some trig here y += distance * //some trig here z += distance * //some trig here } } Ie, I want to move a given distance from the origin in a given direction, and need the coordinates of the new position. This is actually for a JavaScript application, but I just need a bit of psuedocode to help me out. Thanks
0
0
0
0
1
0
For common MoveTo(x0, y0), ArcTo(x1, y1, x2, y2, radius) methods; After a drawing process how can i calculate box rectangle for drawn path with known x0, y0, x1, y1, x2, y2 and radius values ?
0
0
0
0
1
0
How can I recognize the height and the width of a human body in an image?
0
1
0
0
0
0
I have a set of three (or more) known variables that are related to the input of a process. I also have the (measured) results of the process, in this case the time it took for the process to complete. In order to be able to give an estimated duration and create a progress indicator based on the input, i would need to find the relation (if any) between the variables and the results. What is the best way to determine if there is a relation, and if a relation exists to create a formula. I have a number of data sets to work with (input variable values and resulting time). Any suggestions or links related to this? A hint on how to solve this using code or a pointer to some theory would be helpful. Some added background: The process consists of a number of files to be processed (the main input) with an additional secondary input consisting of another set of (reference) files directly related to the main input's contents. Currently the progress is indicated by showing the overall file progress (related to total number of main inputs) combined with the in-file progress based on the position in the contents of the current input file. Since the overall time required per file (set) can be rather long (depending on the contents) I would like to add some kind of "time left" or "expected finish time" indicator. The actual code consists of a merge of a subset of data from a list (Excel format) with XML files into a legacy format file. The "time consuming" part is the parsing of the Excel files, but this is greatly affected by the actual size of the file, the number of items that need to be processed and the number of files that need to be created as output. In some cases a large file results in one output whereas in other cases a small file can result in a large number of outputs. Since a lot of file-access is performed a secondary factor (that is hard to put into numbers) are the number of identical processes running at the same time. The idea is to be able to give an estimated throughput based on the input.
0
0
0
0
1
0
Welcome! I very enjoyed programming artificial intelligence in my studies - neural networks, expert machines and other. But in work I develop mainly web applications. And now I think about returning to such programming, maybe in hobby, or maybe in work. Are there areas where AI is commonly used in applications development and programmer with such skills can search work? Or maybe I can sold some ideas to my boss and use AI to extend some of our applications. What are you experience and ideas with using AI in applications?
0
1
0
0
0
0
Is it possible to calculate a math function f(x) that in a string. Something like this: $function = '2x+3'; $x = 4; math_function($function, $x); //Shoud produce 11 I can't find a library for tasks like this on PHP.net or with Google, but I don't think I am the first one that wants this?
0
0
0
0
1
0
I want know which programming language provides good number of libraries to program a web bot? Something like crawling a web page for data. Say I want fetch weather for weather.yahoo.com website. Also will the answer be same for a AI desktop bot?
0
1
0
0
0
0
I want to draw a variable number of equidistant points on a HTML5 canvas element, using JavaScript. How do I calculate the X/Y position of each point? EDIT: I want the distance from one point to its direct neighbours and to the edges of the canvas to be the same. If I had an 8px x 8px canvas and 4 points, the distace from a point to it's direct neighbours and to the edges of the canvas would be 2px. But what if i had an uneven number of points and not a square canvas? (i think an image might help to understand my problem a little better)
0
0
0
0
1
0
I want to use the Berkeley Aligner for some MT research I'm doing, since, apparently, it beats GIZA++ pretty handily (a 32% alignment error reduction in some reported results). For the most part the outputs in the Berkeley Aligner "examples" directory look like what Moses does to GIZA++ output files (i.e., paired aligned word indices), but there are some funny looking "-P"s after certain pairs. I can't for the life of me find any documentation of what these "-P" annotations are supposed to signify (certainly not in the Berkeley Aligner "documentation" directory). For clarity, I'll give a little illustrative example. Suppose you have the sentences: "Jean plâit à Marie" and "Marie likes Jean". French is the source language and English is the target language. The words "Jean" (indices 0 and 2, resp.) and "Marie" (indices 3 and 0, resp.) are aligned in both sentences, and "plâit" and "à " (French indices 1 and 2, resp.) are aligned with "like" (English index 1). In Moses-post-processed GIZA++ output, this would be denoted by a list of source-target index pairs: 0-2 1-1 2-1 3-0 Berkeley Aligner produces files that pretty much resemble this, but some index pairs have a -P on them (e.g., you might see something like 1-1-P). What the heck does this mean? Can I safely remove these -P annotations and get a GIZA++-via-Moses style alignment, or should I be doing something more (e.g., multiplying them out into a series of aligned index pairs, or what have you)?
0
1
0
0
0
0
I have two vectors defining two separate points in a three-dimensional space. One is static at the origin (0.0f, 0.0f, 0.0f) and the other one will be moving slowly. From this data i need to get a (three-dimensional) direction vector that describes the direction from the moving points current position to the origin. The moving point will be a directional light (3D game) that always myst face the origin. I don't require any code, just basic information on how to calculate the vector.
0
0
0
0
1
0
I experienced this phenomenon in Python first, but it turned out that it is the common answer, for example MS Excel gives this. Wolfram Alpha gives an interesting schizoid answer, where it states that the rational approximation of zero is 1/5. ( 1.0 mod 0.1 ) On the other hand, if I implement the definition by hand it gives me the 'right' answer (0). def myFmod(a,n): return a - floor(a/n) * n What is going on here. Do I miss something?
0
0
0
0
1
0
Someone somewhere has had to solve this problem. I can find many a great website explaining this problem and how to solve it. While I'm sure they are well written and make sense to math whizzes, that isn't me. And while I might understand in a vague sort of way, I do not understand how to turn that math into a function that I can use. So I beg of you, if you have a function that can do this, in any language, (sure even fortran or heck 6502 assembler) - please help me out. prefer an analytical to iterative solution EDIT: Meant to specify that its a cubic bezier I'm trying to work with.
0
0
0
0
1
0
I have huge dictionaries that I manipulate. More than 10 Million words are hashed. Its is too slow and some time it goes out of memory. Is there a better way to handle these huge data structure ?
0
1
0
0
0
0
How would someone implement mathematical formulae in Java? What I mean, the user inputs a string with multiple variables. Like a simple quadratic formula: x^2 + 5x + 10. Or in Java: (Math.pow(x,2)) + (x * 5) + 10. The user would then enter that and then the program would solve for x. I will be using the BeanShell Interpreter class to interpret the string as an equation. But how would I solve for x?
0
0
0
0
1
0
It’s been days that I’m working on a project which I have to use convex hull in it, and specific method of graham scan. The problem has been solved till the place I want to sort the points. So the story is that I have collected bunch of points which they are from the type Point and their coordinates are relatives. Mean they come from the mouse event x and y. So I have collected the mouse positions as x and y of the points. And I want to find the angle related to the pivot point. Does anyone have a piece of code to calculate that angle? Many and many thanks, the image below is what I need:
0
0
0
0
1
0
So the idea is that a computer agent would be programmed in two layers, the conscious and unconscious. The unconscious part is essentially a set of input and output devices, which I typically think of as sensors (keyboard, temperature, etc. to the limit of your imagination) and output methods (screen and speakers notably in the case of a home PC, but again to the limit of your imagination). Sensors can be added or removed at anytime, and this layer provides two main channels to the conscious layer, an single input and a single output. Defining what kind of information travels between these two layers is sort of difficult, but the basic idea is that the conscious part is constantly receiving signals (of various levels of abstraction) from the output of the unconscious part, and the conscious part can send whatever it wants down to the unconscious layer through the input channel. The conscious layer initially knows little to nothing, it is just being completely blasted by inputs from the unconscious layer, and it knows how to send signals back, though it knows nothing about how any particular signal will affect the unconscious part. The conscious part has a large amount of storage space and processing power, however, it is all volatile memory. Now for the question. I would like for the conscious part of the system to "grow" in that it has no idea what it can do, it just knows it can send signals, and so it starts out by sending signals down the pipe and seeing how that affects the sensor data it receives back. The dead end is that the computer is not initially trying to satisfy a goal. It is just sending signals around. To think of it like a baby being born, they need food, or sleep or to be moved out of the sun, etc. The sensory inputs of the baby are fed to its brain, which then decides to try making use of its outputs in order to get what it needs. What kind of natural need can a computer have? What have I tried? Thinking specifically about how a baby becomes hungry, I certainly haven't read any research on cat scans perform on crying hungry children or anything, but I thought perhaps a particular signal comes from the unconscious with growing speed constantly which is only satiated when the signals sent back cause the baby to eat. The conscious brain's job would be to minimize the rate at which each type of signal comes in at. In other words, the "instinct" of the computer is to limit the rate of each signal coming in. What other "instincts" could there be? The problem with this analogy of course is, computers don't need to eat. Or at least I haven't been able to translate eating to something a computer needs. Outside of the scope of this question The end goal of this is to teach a computer who knows nothing except how it interacts with the world to play tic-tac-toe. So another idea I had was to supply a button you could press to manually stimulate the rate of a particular signal entering the conscious when it does something bad or manually soothe the rate of a particular signal when it does good.
0
1
0
0
0
0
I am adding values held within an array but the sum is +1 what it actually should be. //update totalscore uint newTotalScore; for (uint i=0; i< [bestscoresArray count] ; i++) { newTotalScore += [[bestscoresArray objectAtIndex:i] intValue]; } totalscore = newTotalScore; //output l1bestscore=15900, l2bestscore=7800, l3bestscore=81000, l4bestscore=81000, l5bestscore=0, l6bestscore=0, l7bestscore=0, l8bestscore=0, l9bestscore=0, l10bestscore=0, totalscore=185701 As you can see the totalscore output is 185701 but the sum of all values is 185700. Would anyone have any ideas why this is occurring? Thanks, Mark
0
0
0
0
1
0
Having trouble finding a solution for my situation here. Sorry if this has been answered before but I couldn't find one that worked for me. Problem: Trying to test if a user session has been active for longer than the timeout limit. I am trying to use the session start time and the current system time and subtract them and if the result is greater than the timeout var - kill the session. So: for (LogSession logSession : sessionLogList) { Calendar sessionStartTime = logSession.getStartTime(); Calendar currentSysTime = Calendar.getInstance(); currentSysTime.setTime(currentSysTime.getTime()); Calendar activeTime = Calendar.getInstance(); activeTime.setTime(sessionStartTime.getTime()); activeTime.add(activeTime.getTime(), - currentSysTime.getTime()); if ( activeTime.getTime() > timeoutLimit) { // Do something } } I am obviously getting an error message on the activeTime.add line but am unsure of the needed approach here. Any help would be great thanks. Timeout is currently set to 15 minutes but is a global variable that can be changed.
0
0
0
0
1
0
I'm searching a space of vectors of length 12, with entries 0, 1, 2. For example, one such vector is 001122001122. I have about a thousand good vectors, and about a thousand bad vectors. For each bad vector I need to locate the closest good vector. Distance between two vectors is just the number of coordinates which don't match. The good vectors aren't particularly nicely arranged, and the reason they're "good" doesn't seem to be helpful here. My main priority is that the algorithm be fast. If I do a simple exhaustive search, I have to calculate about 1000*1000 distances. That seems pretty thick-headed. If I apply Dijkstra's algorithm first using the good vectors, I can calculate the closest vector and minimal distance for every vector in the space, so that each bad vector requires a simple lookup. But the space has 3^12 = 531,441 vectors in it, so the precomputation is half a million distance computations. Not much savings. Can you help me think of a better way? Edit: Since people asked earnestly what makes them "good": Each vector represents a description of a hexagonal picture of six equilateral triangles, which is the 2D image of a 3D arrangement of cubes (think generalized Q-bert). The equilateral triangles are halves of faces of cubes (45-45-90), tilted into perspective. Six of the coordinates describe the nature of the triangle (perceived floor, left wall, right wall), and six coordinates describe the nature of the edges (perceived continuity, two kinds of perceived discontinuity). The 1000 good vectors are those that represent hexagons that can be witnessed when seeing cubes-in-perspective. The reason for the search is to apply local corrections to a hex map full of triangles...
0
0
0
0
1
0
I randomly came up with a data set with 3 examples {1,2,3.5} I tried to use the following two clustering techniques: 1.Hierarchical clustering with q=2 and Ө =1.1 2.Sequential Clustering. No matter using which clustering technique,I always came up with the following two clusters {1,2} and {3.5} Is this correct?It is quite surprising to see that using two completely different clustering technique,the result is the same.
0
1
0
1
0
0
Is it possible to get different result in different browsers with some math operation? E.g. something like that if(vote!=0)total_reiting = Math.round((full_reiting/vote)*100)/100; var star_widht = full_reiting*17/vote; $('#raiting_votes').width(star_widht); $('#raiting_info b').append(total_reiting); Mb its bettter to use back-end calculation? Or its better in any case to hadle logic on beck-end?
0
0
0
0
1
0
Possible Duplicate: Convert a number range to another range, maintaining ratio So I have a function that returns values within 0 and 255 and I need to convert these values to something between -255 and 255 So 200 would be roughly 145, 150 would be roughly 45 and so on.. I have looked at Convert a number range to another range, maintaining ratio but the formulas there won't work. Any other formula I could use?
0
0
0
0
1
0
I'm not seeing the result I expect with Math.Round. return Math.Round(99.96535789, 2, MidpointRounding.ToEven); // returning 99.97 As I understand MidpointRounding.ToEven, the 5 in the thousandths position should cause the output to be 99.96. Is this not the case? I even tried this, but it returned 99.97 as well: return Math.Round(99.96535789 * 100, MidpointRounding.ToEven)/100; What am I missing Thanks!
0
0
0
0
1
0
I have this function to limit a rotation to the range from 0.0 to 360.0: private float ClampRotation( float rotation ) { while( rotation < 0.0f ) rotation += 360.0f; while( rotation >= 360.0f ) rotation -= 360.0f; return rotation; } This functions works great and it probably can't be more efficient, but I'm just wondering if there are a native Java function that can do the same? The closest I get is Math.min/max, but it doesn't work as this. A rotation of -10.0 should output 350.0 and not 0.0 as min/max would do.
0
0
0
0
1
0
I'm interested in writing certain software that uses machine learning, and performs certain actions based on external data. However I've run into problem (that was always interesting to me) - how is it possible to write machine learning software that issues orders or sequences of orders? The problem is that as I understand it, neural network gets bunch on inputs, and "recalls" output based on results of previous trainings. Instantly (well, more or less). So I'm not sure how "issuing orders" could fit into that system, especially when actions performed by system affect the system with certain delay. I'm also a bit unsure how is it possible to train this thing. Examples of such system: 1. First person shooter enemy controller. As I understand it, it is possible to implement neural network controller for the bot that will switch bot behavior strategies(well, assign priorities to them) based on some inputs (probably something like health, ammo, etc). But I don't see a way to make higher-order controller, that could issue sequence of commands like "go there, then turn left". Also, bot's actions will affect variables that control bot's behavior. I.e. shooting reduces ammo, falling from heights reduces health, etc. 2. Automated market trader. It is certainly possible to make system that will try to predict the next market price of something. However, I don't see how is it possible to make system that would issue order to buy something, watch the trend, then sell it back to gain profit/cover up losses. 3. Car driver. Again, (as I understand it) it is possible to make system that will maintain desired movement vector based on position/velocity/torque data and results of previous training. However I don't see a way to make such system (learn to) perform sequence of actions. I.e. as I understood it, neural net is technically a matrix - you give it input, it produces output. But what about generating sequences of actions that could change environment program operates in? If such tasks are not entirely suitable for neural networks, what else could be used? P.S. I understand that the question isn't exactly clear, and I suspect that I'm missing some knowledge. So I'll appreciate some pointers (i.e. books/resources to read, etc).
0
0
0
1
0
0
I want to be able to orient something toward the mouse on an HTML5 canvas. But when I use Math.atan2 and the other trig functions, the directions get messed up. It rotates in the opposite direction that it should and it's usually off by 90 degrees. It will probably be easier if you see it for yourself. Here's the javascript: var mouseX=0; var mouseY=0; var canvas = document.getElementById("world"); var context = canvas.getContext("2d"); function mouseMoveHandler(event) { mouseX = event.clientX; mouseY = event.clientY; } function windowResizeHandler() { canvas.width = window.innerWidth; canvas.height = window.innerHeight; } function loop() { // Clear Screen context.clearRect(0,0,canvas.width,canvas.height); // Calculate the angle to the mouse a = Math.atan2(mouseX-canvas.width/2,mouseY-canvas.height/2); // Draw a line in the direction of the mouse context.beginPath(); context.fillStyle = "#000000"; context.moveTo(canvas.width/2+10, canvas.height/2); context.lineTo(canvas.width/2-10, canvas.height/2); context.lineTo(canvas.width/2+Math.cos(a)*100, canvas.height/2+Math.sin(a)*100); context.fill(); } document.addEventListener('mousemove', mouseMoveHandler, false); window.addEventListener('resize', windowResizeHandler, false); windowResizeHandler(); setInterval(this.loop, 1000 / 30 ); And here's the HTML: <!DOCTYPE html> <html> <head> <title>Test</title> </head> <body> <canvas id='world'></canvas> <script type="text/javascript" src="test.js"></script> </body> </html> You can see it in action here: http://sidefofx.com/projects/stackOverflowQuestion/ How can I make the line point in the direction of the mouse?
0
0
0
0
1
0
I am making a program in which two players face each other in "combat", each player have a skill level, represented by a number between 1 and 100, this number is used to determine which player is better so for example if player A has 50 and player B has 100 then B has 50% more chances of winning the combat, What would be a good way of getting this number knowing the skill level of both players? I tried different ways, for example adding both skill levels and throwing a selecting a random number in this range if the number is less than a player skill then he wins however i am not sure if this is a good way, I think the probability is off. I also tried to use rules, for example if they have the same skill then is 50% (anyone can win) if one is half the other then is 25% chances for the lower player and so on but this gets complicated fast. Any pointers on how to do this calculation? Thank you in advance for your help -hei
0
0
0
0
1
0
Ideally, they would have the following characteristics: They can be completed in just an evening of coding. It will not require a week or more to get interesting results. That way, I can feel like I've learned and accomplished something in just one (possibly several hour long) sitting. The problems are from the real world, or they are at least toy versions of a real world problems. If the problem requires data to test the solution, there are real-world datasets readily available, or it is trivial to generate interesting test data myself. It is easy to evaluate how good of a job I've done. When I test my solution, it will be clear from the results that I've accomplished something nontrivial, either by simple inspection, or by a quantifiable measure of the quality of the results.
0
1
0
1
0
0
I am trying to do the following with weka's MultilayerPerceptron: Train with a small subset of the training Instances for a portion of the epochs input, Train with whole set of Instances for the remaining epochs. However, when I do the following in my code, the network seems to reset itself to start with a clean slate the second time. mlp.setTrainingTime(smallTrainingSetEpochs); mlp.buildClassifier(smallTrainingSet); mlp.setTrainingTime(wholeTrainingSetEpochs); mlp.buildClassifier(wholeTrainingSet); Am I doing something wrong, or is this the way that the algorithm is supposed to work in weka? If you need more information to answer this question, please let me know. I am kind of new to programming with weka and am unsure as to what information would be helpful.
0
0
0
1
0
0
max(float('nan'), 1) evaluates to nan max(1, float('nan')) evaluates to 1 Is it the intended behavior? Thanks for the answers. max raises an exception when the iterable is empty. Why wouldn't Python's max raise an exception when nan is present? Or at least do something useful, like return nan or ignore nan. The current behavior is very unsafe and seems completely unreasonable. I found an even more surprising consequence of this behavior, so I just posted a related question.
0
0
0
0
1
0
I'm trying to take the square root of a matrix. That is find the matrix B so B*B=A. None of the methods I've found around gives a working result. First I found this formula on Wikipedia: Set Y_0 = A and Z_0 = I then the iteration: Y_{k+1} = .5*(Y_k + Z_k^{-1}), Z_{k+1} = .5*(Z_k + Y_k^{-1}). Then Y should converge to B. However implementing the algorithm in python (using numpy for inverse matrices), gave me rubbish results: >>> def denbev(Y,Z,n): if n == 0: return Y,Z return denbev(.5*(Y+Z**-1), .5*(Z+Y**-1), n-1) >>> denbev(matrix('1,2;3,4'), matrix('1,0;0,1'), 3)[0]**2 matrix([[ 1.31969074, 1.85986159], [ 2.78979239, 4.10948313]]) >>> denbev(matrix('1,2;3,4'), matrix('1,0;0,1'), 100)[0]**2 matrix([[ 1.44409972, 1.79685675], [ 2.69528512, 4.13938485]]) As you can see, iterating 100 times, gives worse results than iterating three times, and none of the results get within a 40% error margin. Then I tried the scipy sqrtm method, but that was even worse: >>> scipy.linalg.sqrtm(matrix('1,2;3,4'))**2 array([[ 0.09090909+0.51425948j, 0.60606061-0.34283965j], [ 1.36363636-0.77138922j, 3.09090909+0.51425948j]]) >>> scipy.linalg.sqrtm(matrix('1,2;3,4')**2) array([[ 1.56669890+0.j, 1.74077656+0.j], [ 2.61116484+0.j, 4.17786374+0.j]]) I don't know a lot about matrix square rooting, but I figure there must be algorithms that perform better than the above?
0
0
0
0
1
0
I am trying to find the easiest way to add, subtract a scalar value with a opencv 2.0 cv::Mat class. Most of the existing function allows only matrix-matrix and matrix-scalar operations. I am looking for a scalar-matrix operations. I am doing it currently by creating a temporary matrix with the same scalar value and doing required arithmetic operation. Example below.. Mat M(Size(100,100), CV_8U); Mat temp = Mat::ones(100, 100, CV_8U)*255; M = temp-M; But I think there should be better/easier ways to do it. Any suggestions ?
0
0
0
0
1
0
I am crawling news websites and want to extract News Title, News Abstract (First Paragraph), etc I plugged into the webkit parser code to easily navigate webpage as a tree. To eliminate navigation and other non news content I take the text version of the article (minus the html tags, webkit provides api for the same). Then I run the diff algorithm comparing various article's text from same website this results in similar text being eliminated. This gives me content minus the common navigation content etc. Despite the above approach I am still getting quite some junk in my final text. This results in incorrect News Abstract being extracted. The error rate is 5 in 10 article i.e. 50%. Error as in Can you Suggest an alternative strategy for extraction of pure content, Would/Can learning Natural Language rocessing help in extracting correct abstract from these articles ? How would you approach the above problem ?. Are these any research papers on the same ?. Regards Ankur Gupta
0
1
0
0
0
0
I have 52 items which I randomly insert into a database with the help of the php rand function. Each item has an ID from 1 - 52, and also has a value. Every 13 items has a value of 1 - 13. E.g. Items 1 - 13 have values of 1 - 13, while items 14 - 26 also have values 1 - 13, and so on until the last item, 52. How would I ensure that the value is correct upon insertion to the database? I would imagine the modulus is involved? I guess this is more of a math question than database!
0
0
0
0
1
0
I have a list of items heading that are all in INTEGER (yes the heading is 0 to 120 int) value but when I am reading them they are all in float, so in between there is a conversion being done that I am not aware of (code not open so I can't check it myself but I need to update the xml and for that i must know how to convert it). What I wanted to find out here is what sort of conversion do I have to do in order to get out of the float a matching int for it as the examples OBJECT A and B. First example is OBJECT A which has the floating heading 57 but has the int heading 109. Second example is OBJECT B which has the floating heading 168 but has the int heading 26. The floating is 0 to 360 and the int is 0 to 120. Initially i was think about radians but there are 2 incosistences first is that OBJECT A is 57 having the int 109 so I would not be able to apply a converting formula to it I belive, second is that if I am not mistaken radians is up to 180. I am really intrigued to understand why it has that integer representing a degree and how it is being converted to such... PS: By the way I posted this in mathematics first before posting here but they requested it would be more suitable here. UPDATE WITH MORE SAMPLES: F I 168 26 57 109 180 30 165 25 45 105 0 90 318 99 348 86 240 50 204 38 345 85 F for Float I for INT
0
0
0
0
1
0
Here is my formula, Not getting the right output.... I am looking for the monthly payment someone would have to contribute (with a rate of return %) to get their "Future Value"!! I am doing something wrong.. I believe it is really simple.. Thanks. //set default input text var loanText = 100000; var interestText = 10; var yearsText = 1; //restrict the input boxes to numbers and symbols loan_txt.restrict = "0-9\\."; interest_txt.restrict = "0-9\\."; years_txt.restrict = "0-9\\."; // calculate_mc.onRollOver = function(){ this.gotoAndPlay("over"); } calculate_mc.onRollOut = function(){ this.gotoAndPlay("out"); } calculate_mc.onRelease = function(){ if (loan_txt.text!="" && interest_txt.text!="" && years_txt.text!=""){ loanPayments(); }else{ monthly_txt.text = "Please fill in all fields"; } } // loan_txt.onSetFocus = function() { if (loan_txt.text == loanText) { loan_txt.text = ""; } }; loan_txt.onKillFocus = function() { if (loan_txt.text == "") { loan_txt.text = loanText; } }; interest_txt.onSetFocus = function() { if (interest_txt.text == interestText) { interest_txt.text = ""; } }; interest_txt.onKillFocus = function() { if (interest_txt.text == "") { interest_txt.text = interestText; } }; years_txt.onSetFocus = function() { if (years_txt.text == yearsText) { years_txt.text = ""; } }; years_txt.onKillFocus = function() { if (years_txt.text == "") { years_txt.text = yearsText; } }; loanPayments = function(){ var loanAmount = loan_txt.text; var interestRate = (interest_txt.text)/100; var years = years_txt.text; var downPayment = 0; var monthRate = interestRate/12; var numPayments = years*12; var prin = loanAmount - downPayment; monthPayment = Math.floor((prin*monthRate)/(1-Math.pow((1+monthRate),(1*numPayments)))*100)/100; //form.NumberOfPayments.value=NumPayments var getDec = String(monthPayment).indexOf("."); var add0s = ""; if(String(monthPayment).length +getDec == 2){ add0s = "0"; }else if(String(monthPayment).length +getDec == 1){ add0s = "00"; } trace(add0s); trace(monthPayment); monthly_txt.text = "$"+monthPayment+add0s; }
0
0
0
0
1
0
So, does int random = (int) Math.ceil(Math.random() * 5); return a value of 0,1,2,3,4 rather than 1,2,3,4,5? I have tried to test this, but it never seems to hit 0 or 5 =x
0
0
0
0
1
0
Can someone offer a suggestion on where to find a dictionary word list with frequency information? Ideally, the source would be English words of the North American variety.
0
1
0
0
0
0