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 have to do some work with Q Learning, about a guy that has to move furniture around a house (it's basically that). If the house is small enough, I can just have a matrix that represents actions/rewards, but as the house size grows bigger that will not be enough. So I have to use some kind of generalization function for it, instead. My teacher suggests I use not just one, but several ones, so I could compare them and so. What you guys recommend? I heard that for this situation people are using Support Vector Machines, also Neural Networks. I'm not really inside the field so I can't tell. I had in the past some experience with Neural Networks, but SVM seem a lot harder subject to grasp. Are there any other methods that I should look for? I know there must be like a zillion of them, but I need something just to start. Thanks
0
1
0
0
0
0
Is there a way to use poiter arithmetic on a large malloc block, so you can assign multiple structs or primitive data types to that area already allocated? I'm writing something like this but it isnt working (trying to assign 200 structs to a 15000byte malloc area): char *primDataPtr = NULL; typedef struct Metadata METADATA; struct Metadata { . . . };/*struct Metadata*/ . . . primDataPtr = (void*)(malloc(15000)); if(primDataPtr == NULL) { exit(1); } char *tempPtr = primDataPtr; int x; for(x=0;x<200;x++) { METADATA *md = (void*)(primDataPtr + (sizeof(METADATA) * x)); }//end x -for
0
0
0
0
1
0
So I have a very simple game going here..., right now the AI is nearly perfect and I want it to make mistakes every now and then. The only way the player can win is if I slow the computer down to a mind numbingly easy level. My logic is having a switch case statement like this: int number = randomNumber case 1: computer moves the complete opposite way its supposed to case 2: computer moves the correct way How can I have it select case 2 68% (random percentage, just an example) of the time, but still allow for some chance to make the computer fail? Is a switch case the right way to go? This way the difficulty and speed can stay high but the player can still win when the computer makes a mistake. I'm on the iPhone. If there's a better/different way, I'm open to it.
0
1
0
0
0
0
How can you find the sin(i) with Sage? I am trying to do some complex analysis with Sage. The following commands are not working sin(i) sinh(i)
0
0
0
0
1
0
There is another post here about Atan but I dont see any relevant answers: C# - Why Math.Atan(Math.Tan(x)) != x? Isn't Math.Atan the same as tan-1? On my calculator I do: tan-1(1) and i get 45. tan(45) = 1 In C#: Math.Atan(1) = 0.78539816339744828 // nowhere near the 45. Math.Tan(45) = 1.6197751905438615 //1 dp over the < Piover2. Whats happening here?
0
0
0
0
1
0
I am looking at writing a compiler and after I complete something in a "C" style I am looking at adapting it to other models. What are some syntactical constructs you would expect to see in a "natural" programming language? The target platform for this compiler will be the CLR and I am currently using Oslo+MGrammar for the lexer/parser (as you can probably tell this is really just an excuse to play) One of the goals of my project would be to allow programming to feel more like a conversation than structured syntax and demands. Guess I should extend this out a little. One of the ideas I am working with is having a class declaration read like a paragraph. A Dog is a mammal. It may Bark and Run. To Run it uses its feet to move forward. It does Lay. ...would translate too... public class Dog : Mammal{ public Feet Feet { get; set;} public virtual void Bark() {} public virtual void Run() { this.Feet.MoveForward(); } public void Lay(){} }
0
1
0
0
0
0
I remember reading about an automation program for windows that would accept a list of commands like this: press the ok button put "hello world" into the text control press the add button etc etc. Can anyone name this program? A thousand thankyous.
0
1
0
0
0
0
I have a polyline that approximates a curve, and I want to draw it as a smooth curve in PostScript, which supports Bezier curve drawing. To do that, I need to generate two control points between each pair of polyline points. (I can't get the original curve from the source, just the polyline.) I've had some success using cardinal splines from this description, but the parameters there are different from Wikipedia and GDIPlus.DrawCurve, both of which refer to tension. MS has no details, and Wikipedia has incomplete details (cardinal spline ignores x values?). What are the formulas for the control points based on tension?
0
0
0
0
1
0
in this web http://www.fonerbooks.com/interest.htm, it has example to calculate mortgage. for example: the loan = 100.000 interest 5%/year payment : 12.000/month we got this table (on the web, 3rd table) Year Principal Interest Payment One 100,000 5,000 12,000 Two 93,000 4,650 12,000 Three 85,650 4,282.5 12,000 Four 77,932.5 3,896.63 12,000 Five 69,829.13 3,491.46 12,000 Six 61,320.58 3,066.03 12,000 Seven 52,386.61 2,619.33 12,000 Eight 43,005.94 2,150.3 12,000 Nine 33,156.24 1657.81 12,000 Ten 22,814.05 1,140.7 12,000 My question: What is the formula for calculating interest in the X th year. For example: I want to know how much interest I have to pay in the seventh year. What is the formula for calculating from year x to y for example: I want to calculate sum of interest from first year to seventh year.
0
0
0
0
1
0
Could anybody please tell me whether I can perform this integration with FFT in MATLAB? How? Please answer as soon as possible with the details. Suppose there exists 2 rectangular planes, say, input accessed by x1 and y1 variables and the resulting plane is output accessed by tetax and tetay variables. This is the integral in pseudo-code: output(tetax,tetay)=double integral of [input(x1,y1)*exp(-j*k*((tetax*x1)+(tetay*y1)))](dx1)(dy1) where: -1<= x1 <= 1 and -1<= y1 <= 1 tetax and tetay should change so they can span the final rectangular plane. I would really appreciate a prompt and detailed answer.
0
0
0
0
1
0
I implemented Hough Transform in C# this way: List<Point> forme = new List<Point>(); forme.Add(new Point(260, 307)); forme.Add(new Point(268, 302)); forme.Add(new Point(273, 299)); forme.Add(new Point(279, 295)); forme.Add(new Point(285, 292)); forme.Add(new Point(291, 288)); forme.Add(new Point(298, 283)); forme.Add(new Point(305, 280)); forme.Add(new Point(312, 277)); forme.Add(new Point(319, 274)); forme.Add(new Point(325, 271)); forme.Add(new Point(333, 268)); forme.Add(new Point(340, 264)); forme.Add(new Point(350, 259)); forme.Add(new Point(356, 256)); int width = Math.Abs(forme[0].X - forme[forme.Count - 1].X); int height = Math.Abs(forme[0].Y - forme[forme.Count - 1].Y); int halfWidth = width / 2; int halfHeigh = height / 2; double pmax = Math.Sqrt((width * width) + (height * height)); double tmax = Math.PI * 2; // step sizes double dp = pmax / (double)width; double dt = tmax / (double)height; int[,] A = new int[width , height]; // accumulator array foreach (Point p in forme) { for (int Theta = 1; Theta < height; Theta++) { double radius = ((double)(p.X) * Math.Cos(dt * (double)Theta)) + ((double)(p.Y) * Math.Sin(dt * (double)Theta)) ; int k = (int)((radius / pmax) * width); if (k >= 0 && k < width) A[k, Theta]++; } } int goodTheta = 0; int goodRadius = 0; // maxMapIntensity c'est l'intensité maximale int maxMapIntensity = 0; for (int radius = 0; radius < width; radius++) { for (int theta = 0; theta < height; theta++) { if (A[radius, theta] > maxMapIntensity) { maxMapIntensity = A[radius, theta]; goodRadius = radius; goodTheta = theta; } } } So, up to my understanding, i have now found the theta and radius of the intersecting point of all the curves. Then how can i find the real line ? Some claim that I need to find the slope and a point, but it is really not clear to me what to do now. Thanks for help, Jonathan
0
0
0
0
1
0
My objective is to supply 2 image files, and get a true/false response as to whether these 2 files could be the same (within an acceptable degree of certainty). I realize this question falls under artificial intelligence and is much more complex than it appears, so I highly doubt I could (or would even want to) do it myself. What I'm looking for is probably a library or a class. I'm working with PHP. thanks in advance.. All helpful answers/comments get up voted.. Update: I wonder if I'm over-complicating it, and maybe a more general library like imageMagick (imagick) could get it done? Anyone who's more experienced with imageMagick?
0
1
0
0
0
0
I have a particular application that needs to calculate something very specific, and while I excel at logic, math has always been my weak spot. Given a number, say -20, it needs to apply a calculation of a 100 base (that is, the base is 100, not 0. not to be confused with base 100 which would be something else totally). In other words, the math works like this ..., 105, 104, 103, 102, 101, 100, -101, -102, -103, -104, -105, ... Then I need to do the math based on this 100 base figure. So, for example: -140 - 20 = 120 -120 - 20 = 100 -115 - 20 = -105 -110 - 20 = -110 -105 - 20 = -115 100 - 20 = -120 120 - 20 = -140 If it helps, the problem is related to sports odds. In theory, this refers to money (risk $1.40 to win $1.00 on one side, risk $1.00 to win $1.20 on the other, the .20 difference is what casinos call "the juice" or their cut of moving money back and forth.) However, the program is not dealing with real money, it's more of a simulator. My current formula works like this: decimal CalculateSides(decimal side, decimal vig) { decimal newSide = side - vig; newSide = -(newSide < 0) ? newSide + 100 : newSide - 100; return (newSide < 0) ? newSide + 100 : newSide - 100; } While this formula works, I'm not very happy with the conditional +/-, but this is basically the only formula that works for me. Can anyone suggest a way to improve this? Preferably without conditions of +/-? EDIT: When I asked the question, I knew one possible answer was "It's probably best the way you're doing it", and that seems to be the consensus.
0
0
0
0
1
0
Given four binary vectors which represent "classes": [1,0,0,0,0,0,0,0,0,0] [0,0,0,0,0,0,0,0,0,1] [0,1,1,1,1,1,1,1,1,0] [0,1,0,0,0,0,0,0,0,0] What methods are available for classifying a vector of floating point values into one of these "classes"? Basic rounding works in most cases: round([0.8,0,0,0,0.3,0,0.1,0,0,0]) = [1 0 0 0 0 0 0 0 0 0] But how can I handle some interference? round([0.8,0,0,0,0.6,0,0.1,0,0,0]) != [1 0 0 0 0 1 0 0 0 0] This second case should be a better match for 1000000000, but instead, I have lost the solution entirely as there is no clear match. I want to use MATLAB for this task.
0
0
0
1
0
0
Update Just for future reference, I'm going to list all of the statistics that I'm aware of that can be maintained in a rolling collection, recalculated as an O(1) operation on every addition/removal (this is really how I should've worded the question from the beginning): Obvious Count Sum Mean Max* Min* Median** Less Obvious Variance Standard Deviation Skewness Kurtosis Mode*** Weighted Average Weighted Moving Average**** OK, so to put it more accurately: these are not "all" of the statistics I'm aware of. They're just the ones that I can remember off the top of my head right now. *Can be recalculated in O(1) for additions only, or for additions and removals if the collection is sorted (but in this case, insertion is not O(1)). Removals potentially incur an O(n) recalculation for non-sorted collections. **Recalculated in O(1) for a sorted, indexed collection only. ***Requires a fairly complex data structure to recalculate in O(1). ****This can certainly be achieved in O(1) for additions and removals when the weights are assigned in a linearly descending fashion. In other scenarios, I'm not sure. Original Question Say I maintain a collection of numerical data -- let's say, just a bunch of numbers. For this data, there are loads of calculated values that might be of interest; one example would be the sum. To get the sum of all this data, I could... Option 1: Iterate through the collection, adding all the values: double sum = 0.0; for (int i = 0; i < values.Count; i++) sum += values[i]; Option 2: Maintain the sum, eliminating the need to ever iterate over the collection just to find the sum: void Add(double value) { values.Add(value); sum += value; } void Remove(double value) { values.Remove(value); sum -= value; } EDIT: To put this question in more relatable terms, let's compare the two options above to a (sort of) real-world situation: Suppose I start listing numbers out loud and ask you to keep them in your head. I start by saying, "11, 16, 13, 12." If you've just been remembering the numbers themselves and nothing more, and then I say, "What's the sum?", you'd have to think to yourself, "OK, what's 11 + 16 + 13 + 12?" before responding, "52." If, on the other hand, you had been keeping track of the sum yourself while I was listing the numbers (i.e., when I said, "11" you thought "11", when I said "16", you thought, "27," and so on), you could answer "52" right away. Then if I say, "OK, now forget the number 16," if you've been keeping track of the sum inside your head you can simply take 16 away from 52 and know that the new sum is 36, rather than taking 16 off the list and them summing up 11 + 13 + 12. So my question is, what other calculations, other than the obvious ones like sum and average, are like this? SECOND EDIT: As an arbitrary example of a statistic that (I'm almost certain) does require iteration -- and therefore cannot be maintained as simply as a sum or average -- consider if I asked you, "how many numbers in this collection are divisible by the min?" Let's say the numbers are 5, 15, 19, 20, 21, 25, and 30. The min of this set is 5, which divides into 5, 15, 20, 25, and 30 (but not 19 or 21), so the answer is 5. Now if I remove 5 from the collection and ask the same question, the answer is now 2, since only 15 and 30 are divisible by the new min of 15; but, as far as I can tell, you cannot know this without going through the collection again. So I think this gets to the heart of my question: if we can divide kinds of statistics into these categories, those that are maintainable (my own term, maybe there's a more official one somewhere) versus those that require iteration to compute any time a collection is changed, what are all the maintainable ones? What I am asking about is not strictly the same as an online algorithm (though I sincerely thank those of you who introduced me to that concept). An online algorithm can begin its work without having even seen all of the input data; the maintainable statistics I am seeking will certainly have seen all the data, they just don't need to reiterate through it over and over again whenever it changes.
0
0
0
0
1
0
I am asking this question because I know there are a lot of well-read CS types on here who can give a clear answer. I am wondering if such an AI exists (or is being researched/developed) that it writes programs by generating and compiling code all on it's own and then progresses by learning from former iterations. I am talking about working to make us, programmers, obsolete. I'm imagining something that learns what works and what doesn't in a programming languages by trial and error. I know this sounds pie-in-the-sky so I'm asking to find out what's been done, if anything. Of course even a human programmer needs inputs and specifications, so such an experiment has to have carefully defined parameters. Like if the AI was going to explore different timing functions, that aspect has to be clearly defined. But with a sophisticated learning AI I'd be curious to see what it might generate. I know there are a lot of human qualities computers can't replicate like our judgement, tastes and prejudices. But my imagination likes the idea of a program that spits out a web site after a day of thinking and lets me see what it came up with, and even still I would often expect it to be garbage; but maybe once a day I maybe give it feedback and help it learn. Another avenue of this thought is it would be nice to give a high-level description like "menued website" or "image tools" and it generates code with enough depth that would be useful as a code completion module for me to then code in the details. But I suppose that could be envisioned as a non-intelligent static hierarchical code completion scheme. How about it?
0
1
0
1
0
0
Solve this equation for x, (1 + x)^4=34.5 . I am interested in the math libraries you'd use. the equation is MUCH SIMPLER (1 + x)^4=34.5 thanks
0
0
0
0
1
0
I have a 1-dimensional float array of root mean square values, each calculated with the same window length. Let's say RMS = {0, 0.01, 0.4, ... } Now the RMS for a larger window, which can be represented as a range of the original windows, can be calculated as the RMS of the "participating" RMS values from RMS[i] to RMS[i + len]. Here len is the length of the larger window divided by the lenght of the original windows. I'd like to create a rolling window. I want rollingRMS[0] = RMS from 0 to len ... rollingRMS[n] = RMS from n to len+n calculated as efficiently as possible. I know this isn't very hard to crack, but does anyone have ready code for this? EDIT: I asked for sample code, so I guess it would be decent to provide some. The following is based on pierr's answer and is written in C#. It's a bit different from my original question as I realized it would be nice to have the resulting array to have the same size as the original and to have the windows end at each element. // The RMS data to be analysed float[] RMS = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; // The resulting rolling RMS values float[] rollingRMS = new float[RMS.Length]; // Window lenght int len = 3; // Calculate: rollingRMS will hold root mean square from windows which end at // each respective sample in the RMS array. For the first len samples the input // will be treated as zero-padded for (int i = 0; i < RMS.Length; i++) { if (i == 0) rollingRMS[i] = (float)Math.Sqrt((RMS[i] * RMS[i] / len)); else if (i < len) rollingRMS[i] = (float)Math.Sqrt( ( RMS[i] * RMS[i] + len * (rollingRMS[i - 1] * rollingRMS[i - 1]) ) / len); else rollingRMS[i] = (float)Math.Sqrt( ( len * (rollingRMS[i - 1] * rollingRMS[i - 1]) + RMS[i] * RMS[i] - RMS[i - len] * RMS[i - len] ) / len); }
0
0
0
0
1
0
I'm creating an ELIZA-like chatterbot, and I'd like to calibrate it with Omegle, using what the other person type as the input. If it was a regular HTML page, I could parse it and send back the response to some script, but checking the source code, I've noticed that the entire page is created using Javascript, but obfuscates the entire thing. Any idea on how to do that? Thanks!
0
1
0
0
0
0
When attemptiing to solve the below assignment : Using the Arithmetic operators ( +,-,*,/) rearrange four fives to equal the number 1 to 10. Example : 5/5+5-5 =1 ,5/5+5/5=2 I tried in C# without using Linq (I don't know how to proceed further) public void GetDetails() { char[] sym = new char[] { '+', '-', '/', '*' }; int[] AOf5 = new int[] { 5, 5, 5, 5 }; for (int i = 0; i <4; i++) { for (int j = 0; j <4; j++) { for (int k = 0; k <4; k++) { for (int l = 0; l < 4; l++) { int result1 = AOf5[0] + sym[i] + AOf5[1] + sym[j] + AOf5[2] + sym[k] + AOf5[3]; int result2 = AOf5[0] + sym[i] + AOf5[1] + sym[j] + AOf5[2] + sym[l] + AOf5[3]; int result3 = AOf5[0] + sym[i] + AOf5[1] + sym[k] + AOf5[2] + sym[l] + AOf5[3]; .... .... } } } } } I am unable to complete it without linq and using linq.Expecting you help.
0
0
0
0
1
0
This is for a game in a flash AS3 only project. the player controls a character with a gun. By clicking on the screen the gun fires a missile in an arc to the point clicked. Whats the best way to calculate the x and y co-ordinates of the missile for each frame?
0
0
0
0
1
0
It is described as -||xi-xy||^2. So for 2 two dimensional points do I code it like this? - ((x1-x2) + (y1-y2))^2 or -( (x1-x2)^2 + (y1-y2)^2 ) or -(sqrt( (x1-x2)^2 + (y1-y2)^2 )) or some other way?
0
0
0
0
1
0
My integers in Ruby (MRI) refuse to overflow. I've noticed the class change from fixnum to bignum but I'm wondering how this is modeled and what sort of process ruby uses to perform arithmetic on these massive integers. I've seen this behaviour in SCHEME as well as other environments. I ask because I'd like to implement something similar in a C program and would like to know how bignum + bignum reduces to primitive operations. Any pointers?
0
0
0
0
1
0
How would you write SO's Popularity algorithm in MySQL? The algorithm is detailed here: Popularity algorithm. thanks!
0
0
0
0
1
0
I have a list of items. When I create the list each item has equal chance to be selected. But as an item is selected its chance goes down while the others chance goes up. If a new item is added during the process, it should have the highest chance to be selected with its chances falling off as it is selected. I am looking for a good algorithm that can accomplish this is C#. Generalizaed idea: I have 5 items, over time all 5 items will be selected 20% of time time. I am trying to keep the selections a close to that 20% as possible, cutting down on outlyers. If one exists it will be selected more/less to bring it back in line.
0
0
0
0
1
0
I've tried searching for logarithm + objective-c, but all I get is math test pages from teachers, or explanations what a logarithm is ;) I've got some measurements that are like 83912.41234 and others are 32.94232. I need to press down this huge spectrum into something between 0 and 100, and that 32.94232 would habe to be at least something bigger than 2, where the 83912.41234 would be something near 100. So I think a logarithm function will be my friend here. UPDATE: I've came across the math.h file through "Open Quickly" (very nice command in Xcode: SHIFT + CMD + D), and there, big surprise: extern double log ( double ); extern float logf ( float ); extern double log10 ( double ); extern float log10f ( float ); extern double log2 ( double ); extern float log2f ( float ); extern double log1p ( double ); extern float log1pf ( float ); extern double logb ( double ); extern float logbf ( float ); But: No text, no comments. I'm not such a math-freak. So some description would be good, i.e. what kind of logarithm for what case, how the curve looks like, etc... so any great links are highly appreciated!
0
0
0
0
1
0
I've been sitting with a pencil for the better part of the evening trying to recall how to implement a scalable viewport that can navigate a 2D area. It's been a while since I've first heard of it, but I think I've figured it out, I just need to verify. We have a 2D world with a "classic" cartesian coordinate system, x-axis points to the right, y-axis points to the top. In the world area we have a rectangular viewport defined by 2 points Pmin and Pmax, where : Pmin(xmin, ymin), Pmax(xmax, ymax). Those points define viewport's size, location and scale In the world area we have a point P, where Pmin < P(x, y) < Pmax. (P is in the viewport rect) To display the whole damn thing, we've got a canvas (for example) that has an "altered" coordinate system, x-axis points right, y-axis points down. The canvas's size is MaxX and MaxY. The canvas's size is fixed. Now, in order to display point P'(x', y') in the canvas I need to calculate it's position like this : x' = (x - xmin) * Sx, where Sx = MaxX / (xmax - xmin) y' = MaxY - (y - ymin) * Sy, where Sy = MaxY / (ymax - ymin) *please note that y' coord is inverted due to canvas's coordinate system In other words : the above math should take care of displaying a point while taking scale and vieport's position into account. Am I correct ? If not, please prove me wrong.
0
0
0
0
1
0
I have a simple question regarding the Minimax algorithm: for example for the tic-tac-toe game, how do I determine the utility function's for each player plays? It doesn't do that automatically, does it? I must hard-code the values in the game, it can't learn them by itself, does it?
0
1
0
0
0
0
I want to solve x. How can I do it in Scheme? T1-F2=0 F1+T2=GM-Gm Cos(60)(2.5*Gm+x*GM-l*F1)-l*Sin(60)*T1=0 F1=0.1*T1 F2=0.3*T2 M=20 m=80 l=5 My try is: (lambda T1 . ;; T1=F2 (lambda F2 . ;; F2=0.3*T2 (lambda F1 . ;; F1=0.1*T1 (lambda Gm . ( lambda GM . (- ( * 1/2 ( - ( + ( * 2.5 Gm ) ( * x GM ) ) ;; solve x 5 * F1 ) ) ( * ( * 10 1/sqrt(3) ) T1 ) ) ) 80 ) 20 ) ( * 0.1 T1 ) ) ( * 0.3 T2 ) ) F2 ;; ??? F1+T2=GM-Gm
0
0
0
0
1
0
From this site: http://www.toymaker.info/Games/html/vertex_shaders.html We have the following code snippet: // transformations provided by the app, constant Uniform data float4x4 matWorldViewProj: WORLDVIEWPROJECTION; // the format of our vertex data struct VS_OUTPUT { float4 Pos : POSITION; }; // Simple Vertex Shader - carry out transformation VS_OUTPUT VS(float4 Pos : POSITION) { VS_OUTPUT Out = (VS_OUTPUT)0; Out.Pos = mul(Pos,matWorldViewProj); return Out; } My question is: why does the struct VS_OUTPUT have a 4 dimensional vector as its position? Isn't position just x, y and z?
0
0
0
0
1
0
This started suddenly today morning. Original lines were this float angle = (x+90)*(M_PI/180.0); float xx = cosf(angle); float yy = sinf(angle); After putting a breakpoint and hovering cursor.. I get the correct answer for yy as 1. but xx is NOT zero. I tried with cosf(M_PI_2); still no luck.. it was working fine till yesterday.. I did not change any compiler setting etc.. I am using Xcode latest version as of todays date
0
0
0
0
1
0
The negative implication of this is noted in the man page: NOTES Trying to take the absolute value of the most negative integer is not defined. What's the reasoning behind this and what's the best recourse for a person who would like to avoid undefined behavior? Do I have to resort to something like: unsigned uabs(signed val) { return val > 0 ? val : (val == 1U << ((sizeof(val) * 8) - 1)) ? -1U : -val; } (Intentionally hacky to emphasize displeasure with stdlib ;-) Example Say you had a 4-bit signed value (for ease of understanding). unsigned max is 15, signed (positive) max is 7, signed (negative) min is -8, so abs(-8) won't fit into a signed value. Sure, you can represent it as -8, but then division and multiplication with the result don't work as expected.
0
0
0
0
1
0
I just watched a Google tech talk video covering "Polyworld" (found here) and they talk about breeding two neural networks together to form offspring. My question is, how would one go about combining two neural networks? They seem so different that any attempt to combine them would simply form a third, totally unrelated network. Perhaps I'm missing something, but I don't see a good way to take the positive aspects of two separate neural networks and combine them into a single one. If anyone could elaborate on this process, I'd appreciate it.
0
1
0
0
0
0
Okay, so we've got this event. Awesome, right? We've also got a timer with a fixed maximum duration, like one of those rotary kitchen timers. Not exactly awesome, but definitely handy. When the timer goes off, the event occurs, and the timer is reset to some random value between zero and the maximum duration (every value has an equal chance or being selected). The timer is started immediately, and the process continues forever. My question is: what is the effective period of the event? That is, if another repeating event has a fixed period, what would that period have to be for the two events to have an equal number of occurrences over a very large amount of time. I want to say it's half the maximum duration of the timer, but I don't know why, and I wouldn't be surprised if that's wrong.
0
0
0
0
1
0
How to find the minimum perpendicular distance of point from a line in 3D plane? Please give me the logic and I will try to code on myself. Please let me know how to do it in terms of x,y,z that is in terms of coordinate systems. I am finding it a bit difficult to find the right solution which will be easy from a coding point of view. Online solutions are little bit rusty to understand. So please help me. Please note line is given in terms of 3D space equation.
0
0
0
0
1
0
A-B-C-D are 4 points. We define r = length(B-C), angle, ang1 = (A-B-C) and angle ang2 = (B-C-D) and the torsion angle tors1 = (A-B-C-D). What I really need to do is to find the coordinates of C and D provided that I have the new values of r, ang1, ang2 and tors1. The thing is that the points A and B are rigidly connected to each other, and points C and D are also connected to each other by a rigid connector, so to speak. That is the distance (C-D) remains fixed and also distance A-B remains fixed. There is no such rigid connection between the points B and C. We have the old coordinates of the 4 points for some other set of (r,ang1,ang2,tors1) and we need to find the new coordinates when this defining set of variables changes to some arbitrary value. I would be grateful for any helpful comments. Thanks a lot. I'm not allowed to post a picture because I'm a new user :( Additional Info: An iterative solution is not going to be useful because I need to do this in a simulation "plenty of times O(10^6)".
0
0
0
0
1
0
It seems that there is a strong movement for the convergence of mathematics and computer programming languages, this is notably evidenced by the influence of the lambda calculus on modern languages. Most of the time I do not think with mathematics, I think with logic. It seems to me that many of the phenomenon that can be modeled mathematically can be modeled logically as well. I don't think that we'll ever see a purely logical language or a purely mathematical language gain traction for general purpose programming, but I'd like to take an inventory of the benefits of each paradigm. I'd like to know: What are the benefits of modeling programming languages or language features on mathematics? What are the benefits of modeling a language on the principles of formal logic? Can a general purpose language forgo either logic or mathematics? What are some of languages that really show off the benefits of either approach? What hardware features make one approach more attractive than the other?
0
0
0
0
1
0
I want to project a grid on the xz-plane like shown here: To do that, I created a vertex grid with x and z range [-1|1]. In the shader I multiply the xz screen coordinate of a vertex with the inverse of the View-Projection matrix. Then I want to adjust the height, depending on the new world xz coordinates and finally I transform these coordinates back to screenspace by multiplying them with the View-Projection matrix. I dont know why, but I get a very strange plane shown on the screen. Are the mathematical oprations I use correct?
0
0
0
0
1
0
Let's say I have two points in 3D space (a and b) and a fixed axis/unit vector called n. I want to create a rotation matrix that minimizes the euclidan distance between point a (unrotated) and the rotated point b. E.g: Q := matrix_from_axis_and_angle (n, alpha); find the unknown alpha that minimizes sqrt(|a - b*Q|) Btw - If a solution/algorithm can be easier expressed with unit-quaternions go ahead and use them. I just used matrices to formulate my question because they're more widely used. Oh - I know there are some degenerated cases ( a or b lying exactly in line with n ect.) These can be ignored. I'm just looking for the case where a single solution can be calculated.
0
0
0
0
1
0
Anyone who's tried to study mathematics using online resources will have come across these Java applets that demonstrate a particular mathematical idea. Examples: http://www.math.ucla.edu/~tao/java/Mobius.html http://www.mathcs.org/java/programs/FFT/index.html I love the idea of this interactive approach because I believe it is very helpful in conveying mathematical principles. I'd like to create a system for visually designing and publishing these 'mathlets' such that they can be created by teachers with little programming experience. So in order to create this app, i'll need a GUI and a 'math engine'. I'll probably be working with .NET because thats what I know best and i'd like to start experimenting with F#. Silverlight appeals to me as a presentation framework for this project (im not worried about interoperability right now). So my questions are: does anything like this exist already in full form? are there any GUI frameworks for displaying mathematical objects such as graphs & equations? are there decent open source libraries that exposes a mathematical framework (Math.NET looks good, just wondering if there is anything else out there) is there any existing work on taking mathematical models/demos built with maple/matlab/octave/mathematica etc and publishing them to the web?
0
0
0
0
1
0
I have a simple question: given p points (non-collinear) in R^p i find the hyperplane passing by these points (to help clarify i type everything in R): p<-2 x<-matrix(rnorm(p^2),p,p) b<-solve(crossprod(cbind(1,x[,-2])))%*%crossprod(cbind(1,x[,-2]),x[,2]) then, given a p+1^th points not collinear with first p points, i find the direction perpendicular to b: x2<-matrix(rnorm(p),p,1) b2<-solve(c(-b[-1],1)%*%t(c(-b[-1],1))+x2%*%t(x2))%*%x2 That is, b2 defines a p dimensional hyperplane perpendicular to b and passing by x2. Now, my questions are: The formula comes from my interpretation of this wikipedia entry ("solve(A)" is the R command for A^-1). Why this doesn't work for p>2 ? What am i doing wrong ? PS: I have seen this post (on stakeoverflow edit:sorry cannot post more than one link) but somehow it doesn't help me. Thanks in advance, i have a problem implementation/understanding of Liu's solution when p>2: shouldn't the dot product between the qr decomposition of the sweeped matrix and the direction of the hyperplane be 0 ? (i.e. if the qr vectors are perpendicular to the hyperplane) i.e, when p=2 this c(-b[2:p],1)%*%c(a1) gives 0. When p>2 it does not. Here is my attempt to implement Victor Liu's solution. a) given p linearly independent observations in R^p: p<-2;x<-matrix(rnorm(p^2),p,p);x [,1] [,2] [1,] -0.4634923 -0.2978151 [2,] 1.0284040 -0.3165424 b) stake them in a matrix and subtract the first row: a0<-sweep(x,2,x[1,],FUN="-");a0 [,1] [,2] [1,] 0.000000 0.00000000 [2,] 1.491896 -0.01872726 c) perform a QR decomposition of the matrix a0. The vector in the nullspace is the direction im looking for: qr(a0) [,1] [,2] [1,] -1.491896 0.01872726 [2,] 1.000000 0.00000000 Indeed; this direction is the same as the one given by application of the formula from wikipedia (using x2=(0.4965321,0.6373157)): [,1] [1,] 2.04694853 [2,] -0.02569464 ...with the advantage that it works in higher dimensions. I have one last question: what is the meaning of the other p-1 (i.e. (1,0) here) QR vector when p>2 ? -thanks in advance,
0
0
0
0
1
0
I'm considering using a neural network to power my enemies in a space shooter game i'm building and i'm wondering; how do you train neural networks when there is no one definitive good set of outputs for the network?
0
1
0
0
0
0
The following problem has been puzzling me for a couple of days (nb: this is not homework). There exists two geometric sequences that sum to 9. The value of their second term (t2) is 2. Find the common ratio (r) Find the first element (t1) of each The answers to (1) are 2/3 and 1/3 and the answers to (2) are 3 and 6 respectively. Unfortunately, I can't understand how these were derived. In tackling (1) I've tried to apply algebraic substitution to solve for r as follows: t2 = t1*r; since t2 = 2 we have: t1 = 2/r The equation for calculating the sum (S) of a sequence that converges to a limit is given by: S = t1 / (1 - r) So, I tried to plug my value of t1 into S and solve for r as follows: 9 = (2/r) / (1-r) 9(1-r) = 2/r 2/9 = r(1-r) Unfortunately, from this point I get stuck. I need to eliminate one of the r's but I can't seem to be able to. Next, I thought to solve for r using the formula that sums the first 2 terms (S2) of the sequence: S2 = (t1 (1-r^2)) / (1-r) t1 + 2 = (t1 (1-r^2)) / (1-r) but expanding this out I again run into the same problem (can't eliminate one of the r's). So I have 2 questions: What am I doing wrong when deriving r? Once I have one of its values, how I derive the other?
0
0
0
0
1
0
typedef struct Complex{ double real; int img; } Complex; I've seen people use it as a type like: Complex sqrt( double x) { } how do 'real' and 'img' play a role in this type of function? Thanks
0
0
0
0
1
0
Is there a rule of thumb (or set of examples) to determine when to use genetic algorithms as opposed to neural networks (and vice-versa) to solve a problem? I know there are cases in which you can have both methods mixed, but I am looking for a high-level comparison between the two methods.
0
1
0
1
0
0
I've got some C# code that I'm converting to Objective-C. In C# I would call Math.Log(). I'm slowly learning that some people stick to C functions/types and only use NSNumber etc when they need to interop with Cocoa. Is there an equivalent for ObjC/Cocoa, or do I need to drop into C to do this? I need my code to be as accurate as possible because it is part of a calculator. This code needs to run on iPhones if that makes any difference.
0
0
0
0
1
0
I'm working with graphing accelerometer data here, and I'm trying to correct for gravity. To do this, I get the acceleration vector in spherical coordinates, decrease the radius by 1g, and convert back to cartesian. This method is called on a timer every 0.03 seconds: //poll accleration ThreeAxisAcceleration current = self.accelerationData; //math to correct for gravity: float radius = sqrt(pow(current.x, 2) + pow(current.y, 2) + pow(current.z, 2)); float theta = atan2(current.y, current.x); float phi = acos(current.z/radius); //NSLog(@"SPHERICAL--- RADIUS: %.2f -- THETA: %.2f -- PHI: %.2f", radius, theta, phi); radius = radius - 1.0; float newX = radius * cos(theta) * sin(phi); float newY = radius * sin(theta) * sin(phi); float newZ = radius * cos(phi); current = (ThreeAxisAcceleration){newX, newY, newZ}; //end math NSValue *arrayVal = [NSValue value:&current withObjCType:@encode(ThreeAxisAcceleration)]; if ([_dataHistoryBuffer count] > self.bounds.size.width) { [_dataHistoryBuffer removeObjectAtIndex:0]; } [_dataHistoryBuffer addObject:arrayVal]; [self setNeedsDisplay]; Somehow, the addition of the gravity correction is gradually slowing my code horrendously. I find it hard to believe that this amount of math can slow down the program, but yet without it it can still run through my entire display method which is quite lengthy. Are there any options I can consider here to avoid this? Am I missing something or is the math just that slow? I can comment out between the //math and //end math tags and be just fine. Thanks for any help. P.S. incase it may matter, to whom it may interest, I'm programming in cocoa, and this method belongs to a subclass of CALayer, with -drawInContext: implemented.
0
0
0
0
1
0
I created a heuristic (an ANN, but that's not important) to estimate the probabilities of an event (the results of sports games, but that's not important either). Given some inputs, this heuristics tell me what are the probabilities of the event. Something like : Given theses inputs, team B as 65% chances to win. I have a large set of inputs data for which I now the result (games previously played). Which formula/metric could I use to qualify the accuracy of my estimator. The problem I see is, if the estimator says the event has a probability of 20% and the event actually do occurs. I have no way to tell if my estimator is right or wrong. Maybe it's wrong and the event was more likely than that. Maybe it's right, the event as about 20% chance to occur and did occur. Maybe it's wrong, the event has really low chances to occurs, say 1 in 1000, but happened to occur this time. Fortunately I have lots of theses actual test data, so there is probably a way to use them to qualify my heuristic. anybody got an idea?
0
0
0
1
0
0
I'm trying to come up with an elegant way to handle some generated polynomials. Here's the situation we'll focus on (exclusively) for this question: order is a parameter in generating an nth order polynomial, where n:=order + 1. i is an integer parameter in the range 0..n The polynomial has zeros at x_j, where j = 1..n and j ≠ i (it should be clear at this point that StackOverflow needs a new feature or it's present and I don't know it) The polynomial evaluates to 1 at x_i. Since this particular code example generates x_1 .. x_n, I'll explain how they're found in the code. The points are evenly spaced x_j = j * elementSize / order apart, where n = order + 1. I generate a Func<double, double> to evaluate this polynomial¹. private static Func<double, double> GeneratePsi(double elementSize, int order, int i) { if (order < 1) throw new ArgumentOutOfRangeException("order", "order must be greater than 0."); if (i < 0) throw new ArgumentOutOfRangeException("i", "i cannot be less than zero."); if (i > order) throw new ArgumentException("i", "i cannot be greater than order"); ParameterExpression xp = Expression.Parameter(typeof(double), "x"); // generate the terms of the factored polynomial in form (x_j - x) List<Expression> factors = new List<Expression>(); for (int j = 0; j <= order; j++) { if (j == i) continue; double p = j * elementSize / order; factors.Add(Expression.Subtract(Expression.Constant(p), xp)); } // evaluate the result at the point x_i to get scaleInv=1.0/scale. double xi = i * elementSize / order; double scaleInv = Enumerable.Range(0, order + 1).Aggregate(0.0, (product, j) => product * (j == i ? 1.0 : (j * elementSize / order - xi))); /* generate an expression to evaluate * (x_0 - x) * (x_1 - x) .. (x_n - x) / (x_i - x) * obviously the term (x_i - x) is cancelled in this result, but included here to make the result clear */ Expression expr = factors.Skip(1).Aggregate(factors[0], Expression.Multiply); // multiplying by scale forces the condition f(x_i)=1 expr = Expression.Multiply(Expression.Constant(1.0 / scaleInv), expr); Expression<Func<double, double>> lambdaMethod = Expression.Lambda<Func<double, double>>(expr, xp); return lambdaMethod.Compile(); } The problem: I also need to evaluate ψ′=dψ/dx. To do this, I can rewrite ψ=scale×(x_0 - x)(x_1 - x)×..×(x_n - x)/(x_i - x) in the form ψ=α_n×x^n + α_n×x^(n-1) + .. + α_1×x + α_0. This gives ψ′=n×α_n×x^(n-1) + (n-1)×α_n×x^(n-2) + .. + 1×α_1. For computational reasons, we can rewrite the final answer without calls to Math.Pow by writing ψ′=x×(x×(x×(..) - β_2) - β_1) - β_0. To do all this "trickery" (all very basic algebra), I need a clean way to: Expand a factored Expression containing ConstantExpression and ParameterExpression leaves and basic mathematical operations (end up either BinaryExpression with the NodeType set to the operation) - the result here can include InvocationExpression elements to the MethodInfo for Math.Pow which we'll handle in a special manner throughout. Then I take the derivative with respect to some specified ParameterExpression. Terms in the result where the right hand side parameter to an invocation of Math.Pow was the constant 2 are replaced by the ConstantExpression(2) multiplied by what was the left hand side (the invocation of Math.Pow(x,1) is removed). Terms in the result that become zero because they were constant with respect to x are removed. Then factor out the instances of some specific ParameterExpression where they occur as the left hand side parameter to an invocation of Math.Pow. When the right hand side of the invocation becomes a ConstantExpression with the value 1, we replace the invocation with just the ParameterExpression itself. ¹ In the future, I'd like the method to take a ParameterExpression and return an Expression that evaluates based on that parameter. That way I can aggregate generated functions. I'm not there yet. ² In the future, I hope to release a general library for working with LINQ Expressions as symbolic math.
0
0
0
0
1
0
I'm thinking of writing an app to classify movies in an HTPC based on what the family members like. I don't know statistics or AI, but the stuff here looks very juicy. I wouldn't know where to start do. Here's what I want to accomplish: Compose a set of samples from each users likes, rating each sample attribute separately. For example, maybe a user likes western movies a lot, so the western genre would carry a bit more weight for that user (and so on for other attributes, like actors, director, etc). A user can get suggestions based on the likes of the other users. For example, if both user A and B like Spielberg (connection between the users), and user B loves Batman Begins, but user A loathes Katie Holmes, weigh the movie for user A accordingly (again, each attribute separately, for example, maybe user A doesn't like action movies so much, so bring the rating down a bit, and since Katie Holmes isn't the main star, don't take that into account as much as the other attributes). Basically, comparing sets from user A similar to sets from user B, and come up with a rating for user A. I have a crude idea about how to implement this, but I'm certain some bright minds have already thought of a far better solution already, so... any suggestions? Actually, after a quick research, it seems a Bayesian filter would work. If so, would this be the better approach? Would it be as simple as just "normalizing" movie data, training a classifier for each user, and then just classify each movie? If your suggestion includes some brain melting concepts (I'm not experienced in these subjects, specially in AI), I'd appreciate it if you also included a list of some basics for me to research before diving into the meaty stuff. Thanks!
0
0
0
1
0
0
I'm trying to use WolframAlpha to solve for a variable. I have u(k, r) = (900-3k)r^(k-1) and s(n, r) = sum u(k, r), k=1 to n and I want to solve for r with s(5000, r) = -600000000000 I've tried various incantations, but can't seem to get it working. I can't even get s defined to evaluate it. If you care, it is to solve this problem : http://projecteuler.net/index.php?section=problems&id=235
0
0
0
0
1
0
How to implement voice recognition in .NET? I've got a bunch of .mp3s with computer generated voice of relatively high quality. In each .mp3 the voice says some random text and then a sequence of 6-7 digits in English. I'd like to extract those digits as text. Is it possible to implement such a thing in .NET?
0
1
0
0
0
0
I almost have this working however the script is rounding my numbers while I wish to keep both decimals places for a full price instead of being automatically rounded up. My sandbox for this script is here: http://www.zacharydesigns.com/sandbox/calculatorJS2.html and here is the code: <script type="text/javascript"> function update1() { var a = +document.forms['calc'].elements['productOne'].value, b = +document.forms['calc'].elements['productTwo'].value, c = +document.forms['calc'].elements['productThree'].value, productTotal = Math.floor(a/(a+b+c)*399.99); document.forms['calc'].elements['productTotal1'].value = productTotal; return false; } function update2() { var a = +document.forms['calc'].elements['productOne'].value, b = +document.forms['calc'].elements['productTwo'].value, c = +document.forms['calc'].elements['productThree'].value, productTotal = Math.floor(b/(a+b+c)*399.99); document.forms['calc'].elements['productTotal2'].value = productTotal; return false; } function update3() { var a = +document.forms['calc'].elements['productOne'].value, b = +document.forms['calc'].elements['productTwo'].value, c = +document.forms['calc'].elements['productThree'].value, productTotal = Math.floor(c/(a+b+c)*399.99); document.forms['calc'].elements['productTotal3'].value = productTotal; return false; } </script> <form name="calc" action="#"> <table align="center" border="1"><tr><td align="right">Boots: </td> <td align="left"><input type="text" name="productOne" size="5" /> </td> <td colspan="2" align="center"> <input type="button" value="Calculate" onclick="update1();" /> </td> <td align="right">Product Total:</td><td align="left"> <input type="text" name="productTotal1" size="6" readonly="readonly" /></td> </tr> <tr> <td align="right">Bindings: </td> <td align="left"><input type="text" name="productTwo" size="5" /> </td> <td colspan="2" align="center"> <input type="button" value="Calculate" onclick="update2();" /> </td> <td align="right">Product Total:</td><td align="left"> <input type="text" name="productTotal2" size="6" readonly="readonly" /></td> </tr><tr> <td align="right">Boards: </td> <td align="left"><input type="text" name="productThree" size="5" /> </td> <td colspan="2" align="center"> <input type="button" value="Calculate" onclick="update3();" /> </td> <td align="right">Product Total:</td><td align="left"> <input type="text" name="productTotal3" size="6" readonly="readonly" /></td> </tr><tr></tr> </tr> </table></form> Can someone please tell me how I can have math operated on the full number without rounding it?
0
0
0
0
1
0
Is there a good way to do a multithreaded A* search? Single threaded is fairly easy, as given in (for example) Artificial Intelligence: A Modern Approach, but I have not come across a good multithreaded version. Assume a sane language like Java or C# or Lisp where we have thread pools and work blocks, and of course garbage collection.
0
1
0
0
0
0
For my GAE app I need to do some natural language processing to extract the subject and object from an input sentence. Apparently NLTK can't be installed (easily) on GAE so I am looking for another solution. I noticed GAE comes with Antlr3 but from browsing their documentation it solves a different kind of grammar problem. Any ideas?
0
1
0
0
0
0
Is it possible without using exponentiation to have a set of numbers that when added together, always give unique sum? I know it can be done with exponentiation (see first answer): The right way to manage user privileges (user hierarchy) But I'm wondering if it's possible without exponentiation.
0
0
0
0
1
0
Im trying to implement NLP in my project, I need to Tag the words as Person,Location ,Organix=sation etc..If any body knows the logic please let me know.. Regards, Stack
0
1
0
0
0
0
I have around 100 megabytes of text, without any markup, divided to approximately 10,000 entries. I would like to automatically generate a 'tag' list. The problem is that there are word groups (i.e. phrases) that only make sense when they are grouped together. If I just count the words, I get a large number of really common words (is, the, for, in, am, etc.). I have counted the words and the number of other words that are before and after it, but now I really cannot figure out what to do next The information relating to the 2 and 3 word phrases is present, but how do I extract this data?
0
1
0
0
0
0
I have two variables: $qty = 7; $_POST['qty'] = 6; var_dump($qty, $_POST['qty']); // both vars are integers $_SESSION['qty'] = $qty + $_POST['qty']; echo '='.$_SESSION['qty']; This returns: int(7) int(6) =1 (int)$qty, (int)$_POST['qty'] doesn't solve the problem. What am I doing wrong? Update: ... intval($qty) + intval($_POST['qty']); not help. And I notice one more detail. Problem apeear only when $_SESSION['qty'] >= 10: $_SESSION['qty'] = $qty + $_POST['qty']; // $qty = 3, $_POST['qty'] = 6 Return good result ($_SESSION['qty'] = 9). SOLVED Thanks all for your unswers. But problem more not actual (it was a server problem). Anyway +1 to all.
0
0
0
0
1
0
Can I rely on sqrt((float)a)*sqrt((float)a)==a or (int)sqrt((float)a)*(int)sqrt((float)a)==a to check whether a number is a perfect square? Why or why not? int a is the number to be judged. I'm using Visual Studio 2005. Edit: Thanks for all these rapid answers. I see that I can't rely on float type comparison. (If I wrote as above, will the last a be cast to float implicitly?) If I do it like (int)sqrt((float)a)*(int)sqrt((float)a) - a < e How small should I take that e value? Edit2: Hey, why don't we leave the comparison part aside, and decide whether the (int) is necessary? As I see, with it, the difference might be great for squares; but without it, the difference might be small for non-squares. Perhaps neither will do. :-(
0
0
0
0
1
0
Given a 4x4 matrix, what formula could i apply to each (x,y) cell to yield an (x,y) if the matrix was rotated 90 degrees to the right? I tried iterating over each cell but different cells gave different formulas. Given the following matrix of values. 0| | | | | 1| | | | | 2| | | | | 3| | | | | ------------- 0 1 2 3 Rotate the values 90 degrees by moving the value in (x,y) to the (x,y) value in the matching cell using the matrix below: 0 | 0,3 | 0,2 | 0,1 | 0,0 | 1 | 1,3 | 1,2 | 1,1 | 1,0 | 2 | 2,3 | 2,2 | 2,1 | 2,0 | 3 | 3,3 | 3,2 | 3,1 | 3,0 | -------------------------- 0 1 2 3 ie: If cell (0,0) has the value 5, using the translation matrix 5 would move to (3,0). Hard-coding this translation matrix is tedious and error prone, and if the matrix size grows to huge numbers doing this by hand is simply retarded.
0
0
0
0
1
0
Has anyone used the Intel Math Kernel library http://software.intel.com/en-us/intel-mkl/ I am thinking of using this for Random Number generation from a C# application as we need extreme performance (1.6 trillion random numbers per day). Also any advice on minimising the overhead of consuming functions from this c++ code in my c# Monte Carlo simulation. Am about to download the Eval from the site and above and try and benchmark this from my c# app, any help much appreciated. Thanks
0
0
0
0
1
0
I'm generating some statistics for some English-language text and I would like to skip uninteresting words such as "a" and "the". Where can I find some lists of these uninteresting words? Is a list of these words the same as a list of the most frequently used words in English? update: these are apparently called "stop words" and not "skip words".
0
1
0
0
0
0
We have a list of x,y pairs. Every pair represents a point on a 2D space. I want to find the closest point from this list, to a specific point xq,yq. What is the best performance-critical algorithm for this problem? Lisp of points is not going to change; which means I do not need to perform insertion and deletion. I want just to find the nearest neighbor of a target xq,yq point in this set. Edit 1: Thanks to all! As Stephan202 has guessed correctly, I want to do this repeatedly; like a function. An the list is not necessarily sorted (In fact I do not understand how can it be sorted? Like a table with a primary key of 2 columns a and y? If that helps then I will sort it). I will construct the data structure based on the list one time, and then I will use this generated data structure in the function (if this process itself is relevant). Thank you Jacob; It seems that KD-Tree data structure is a good candidate for being the answer (And I feel it is. I will update when I get some relevant results). Edit 2: I have found that, this problem is named "nearest neighbor"! Edit 3: First title was "In Search of an Algorithm (for Spatial-Querying and Spatial-Indexing) (Nearest Neighbor)"; I have chose a new title: "Best Performance-Critical Algorithm for Solving Nearest Neighbor". Since I do not want to perform insertion and deletion operation on my initial data and I want just the nearest one from them to a new point (which is not going to be inserted), I chose to (currently) working on KD-Trees. Thanks to all!
0
0
0
1
0
0
What would be the best way to do the following. Enter a very long number, lets say 500,000 digits long without it going into scientific notation; and then am able to do math with it, like +2 etc.? Thank you in advance. EDIT: It is a 500,000 digit, positive integer.
0
0
0
0
1
0
This is really weird, and I cannot see why this is happening. In the foreach cycle, I am iterating through a class A collection, and for each class, I call the Count() method, where r1 and r2 numbers are generated from range [-1,1]. The problem is that Random.Next returns the same "random" numbers for each instance. When the results for the first instance are 0 and -1, the same ones will be returned from following instances. Please, could you tell me why this is happening? Also, I cannot get different results in each class A instance. This is the code: class a { Random rnd = new Random(); private void Count() { int r1 = rnd.Next(-1, 1); int r2 = rnd.Next(-1, 1); } } class b { List<a> listofA=new list<a>(); foreach (a ACLASS in listofA) { ACLASS.Count(); } }
0
0
0
0
1
0
If you're optimizing for an architecture on which branching is expensive (say the PS3's cell processor), it can be important to be able to determine whether or not you can express a given algorithm without using branches or at least using fewer branches. One pattern that I see a lot in unoptimized code is a bunch of if's used to tweak an index into some array (if the size of the array is odd, bump the index by 1, under some other circumstance, multiply by 2, etc.). So it would be nice if there were a way, given two lists of numbers, to be able to determine whether or not it's possible to write a branchless function transforming one list into the other. For example I recently wanted to know if it was possible to write a branchless function that would transform: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 to: 0, 2, 4, 6, 8, 9, 7, 5, 3, 1 (ascending even followed by descending odd). Technically, I could write a big switch/case function but obviously I'm interested in a function that will follow the pattern for arbitrary sizes. Writing a function to do this transformation is straightforward with branching, but if there's a nonbranching way to do it it's not immediately obvious. So is there a general approach to this sort of problem, or any sort of quick litmus test? Or do you have to come up with proofs on a case by case basis? I could work harder at these sorts of problems but that's pointless if they're literally impossible. I seem to recall reading at some point that there's a formal mathematical word for functions that only use arithmetic without branching, but I can't recall.
0
0
0
0
1
0
If I have a set of tiles (squares) which can be any number and they are to fill a container (rectangle) of an unknown size how do I work out the maximum size of the tiles without having any of them overlap. So if I have 2 tiles and the rectangle is 100 * 100 then the max tile size is 50 * 50. This would also be the max size of tile if there was 3 or 4 tiles for this size of rectanlgle, which just so happens to be a square in this example. If the rectanlge was 100 * 30 and I had 2 tiles, the max size of the square would be 30 * 30, if I have 4 tiles the max size would be 25 * 25. How can I do this programatically without hogging the processor by going through every possible combination. I try to summarise a bit better, I have a: rectangle/bounding box that I need to fill as much as possible without the tiles overlapping. I know the height and width of the rectangle (but this can change during runtime). I have X number of tiles (this can change at run time), these are squares. None of the tiles should overlap, what is the maximum size that each tile can be. They are all to be the same size.
0
0
0
0
1
0
I want to order a result by fieldx * fieldy, for example: Row 1: fieldx = 10 fieldy = 10 Total: 100 Row 2: fieldx = 11 fieldy = 5 Total: 55 Row 1 has to appear first. Couldn't find anything about it. It's for a codeIgniter project, so if there is a solution with that I'm very happy. Thanks!
0
0
0
0
1
0
I'm running a contest on a website and I have 3215 entrants who are eligible for 5x Sony PSPs. I believe the formula to count the odds is totalEntrants - prizes / prizes: (3215-5)/5 = 642 so that's an odds of 642 to 1 of winning - is that right? ( I suck at math ) And in my table which contains 3215 rows in the database I would just select a random row like so? SELECT * from entries WHERE entries.won = 0 ORDER BY RAND() LIMIT 1 Now I have one row, and I need to set the won column to 1 so the entrant can't win again, then run it again? This is my first time doing it so I just want confirmation on if I'm doing it correctly.
0
0
0
0
1
0
I have an I2C device that wants two inputs: a denominator and a numerator. Both are written to separate addresses, so no actual calculation (numerator/denominator) is done. The problem with this is that a divide by zero could occur on the I2C device, so a divide by zero error needs to be checked for. Ideally, exactly the same thing would happen if the dividing were done by the java code. At the moment, I've bodged an unused variable that does the division, but I'm worried it'll get optimized out: public void setKp(int numerator, int divisor) { int zeroCheck = numerator / divisor; //... doesn't use zeroCheck } Surely there's a better way!
0
0
0
0
1
0
If I got a polynomial curve, and I want to find all monotonic curve segments and corresponding intervals by programming. What's the best way to do this... I want to avoid solving equation like f'(x) = 0; Using some nice numerical ways to do this,like bi-section, is preferred. f'(x) expression is available. Thanks. Add additional details. For example, I get a curve in 2d space, and its polynomial is x: f(t) y: g(t) t is [0,1] So, if I want to get its monotonic curve segment, I must know the position of t where its tangent vector is (1,0). One direct way to resolve this is to setup an equation "f'(x) = 0". But I want to use the most efficient way to do this. For example, I try to use recursive ways to find this. Divide the range [0,1] to four parts, and check whether the four tangents projection on vector (1,0) are in same direction, and two points are close enough. If not, continue to divide the range into 4 parts, until they are in same direction in (1,0) and (0,1), and close enough.
0
0
0
0
1
0
I need to represent calculator key presses by the text for the keys to press surrounded by a box. I tried to get away with just the bare key presses (no box) but I got marked down for it because it would appear my assessor is a bit of a pedant. Anyway, a bit of research turned up the likes of \boxit and \fbox. I gave them both a go but \boxit produces nigh on identical results to \fbox. The problem is that the height and baseline of the box varies with the glyphs it contains. Take the following example that represents pressing 5, multiply, x; \documentclass{article} \usepackage{fullpage} \begin{document} \fbox{5} \fbox{$\times$} \fbox{$x$} \end{document} This generates boxes around the content but they're on different baselines and they're all different heights. Given what I've seen of LaTeX thus far I'd say this is definitely possible but CTAN, news groups and google have turned up nothing useful thus far. Any hints?
0
0
0
0
1
0
I'm looking to extract names and places from very short bursts of text example "cardinals vs jays in toronto" " Daniel Nestor and Nenad Zimonjic play Jonas Bjorkman w/ Kevin Ullyett, paris time to be announced" "jenson button - pole position, brawn-mercedes - monaco". This data is currently in a MySQL database, and I (pretty much) have a separate record for each athlete, though names are sometimes spelled wrong, etc. I would like to extract the athletes and locations. I usually work in PHP, but haven't been able to find a library for entity extraction (and I may want to get deeper into some NLP and ML in the future). From what I've found, LingPipe and NLTK seem to be the most recommended, but I can't figure out if either will really suit my purpose, or if something else would be better. I haven't programmed in either Java or Python, so before I start learning new languages, I'm hoping to get some advice on what route I should follow, or other recommendations.
0
1
0
0
0
0
I am looking to create a custom math library for the project I am working on. The project is written in C#, and I am slightly concerned whether C# will be fast enough. The library will have a number of custom math formulas and equasions to be applied to very large data sets. Simulations and matrix operations will be done as well (i.e. Monte Carlo simulations) so it'd have to be fast. One thought is to create the math library in C++ and reference this .dll within the C# project. I am wondering whether it is worth the effort?
0
0
0
0
1
0
how can I change with CSS (-moz-transform) a div that should look like this:
0
0
0
0
1
0
I wrote a tool for polar functions. It lists values from an input range like that: 0 Grad: (0 RAD|1 RES) 20 Grad: (0.349065850398866 RAD|1.3639702342662 RES) 40 Grad: (0.698131700797732 RAD|1.83909963117728 RES) 60 Grad: (1.0471975511966 RAD|2.73205080756888 RES) 80 Grad: (1.39626340159546 RAD|6.67128181961771 RES) 100 Grad: (1.74532925199433 RAD|4.67128181961771 RES) 120 Grad: (2.0943951023932 RAD|0.732050807568878 RES) 140 Grad: (2.44346095279206 RAD|0.16090036882272 RES) 160 Grad: (2.79252680319093 RAD|0.636029765733797 RES) 180 Grad: (3.14159265358979 RAD|1 RES) It is based of the function abs(1 + tan($_[0])); How can I parse such a function from UserInput (Perl syntax) and assign it to a variable? I want to avoid changing the Perl script; making the function dynamic instead of static. Greets and thanks for reading. EDIT: sorry for quadrupelpost.... Thanks for the help, but the following snippet gives wrong values: print("Eingabe: Funktion (phi = $t); PERL syntax!: > "); $iFunktion = <STDIN>; chop($iFunktion); print("Eingabe: Grad Start: > "); $iGradStart = <STDIN>; chop($iGradStart); print("Eingabe: Grad End: > "); $iGradEnd = <STDIN>; chop($iGradEnd); print("Eingabe: Schrittweite: > "); $iSchrittweite = <STDIN>; chop($iSchrittweite); print(" Berechne Funktion von $iGradStart bis $iGradEnd Grad mit einer Schrittweite von $iSchrittweite "); for ($i = $iGradStart; $i < $iGradEnd; $i = $i + $iSchrittweite) { $flRad = &deg2rad($i); #$flResult = &Compute($flRad); $t = $i; $flResult = eval($iFunktion); print("$i Grad: ($flRad RAD|$flResult RES) "); } Input was abs(1 + tan($t)); (additional info, merged from follow-up) print("Eingabe: Grad Start: > "); $iGradStart = <STDIN>; chop($iGradStart); print("Eingabe: Grad End: > "); $iGradEnd = <STDIN>; chop($iGradEnd); print("Eingabe: Schrittweite: > "); $iSchrittweite = <STDIN>; chop($iSchrittweite); print(" from $iGradStart to $iGradEnd Grad with $iSchrittweite "); for ($i = $iGradStart; $i <= $iGradEnd; $i = $i + $iSchrittweite) { $flRad = &deg2rad($i); $flResult = &Compute($flRad); print("$i Grad: ($flRad RAD|$flResult RES) "); } sub Compute { return abs(1 + tan($_[0])); }
0
0
0
0
1
0
I'd like to create a function that calculates the distance between two pairs of lat/longs using the pythag theorem instead of the haversine great-circle formula. Since this will be over relative short distances (3km), I think this version that assumes a flat earth should be OK. How can I do this? I asked the internet and didn't come up with anything useful. :) Thanks. EDIT: Here's what I came up with (seems to be working): def get_dist(lat0, lng0, lat1, lng1) begin d_ew = (lng1.to_f - lng0.to_f) * Math.cos(lat0.to_f) d_ns = (lat1.to_f - lat0.to_f) d_lu = Math.sqrt(d_ew.to_f * d_ew.to_f + d_ns.to_f * d_ns.to_f) d_mi = ((2*Math::PI*3961.3)/360)*d_lu return d_mi rescue Exception => ex logger.debug "[get_dist] An exception occurred: #{ex.message}" return -1 end end
0
0
0
0
1
0
I am working with microtime() to time some scripts, but all the scripts have really quick times, eg 2.1934509277344E-5 how can i get php to display that correctly without e-5? (which i assume is 0.000021934509277344? long time since i did maths...)
0
0
0
0
1
0
I've the following players, each value corresponds to a result in percentage of right answers in a given game. $players = array ( 'A' => array(0, 0, 0, 0), 'B' => array(50, 50, 0, 0), 'C' => array(50, 50, 50, 50), 'D' => array(75, 90, 100, 25), 'E' => array(50, 50, 50, 50), 'F' => array(100, 100, 0, 0), 'G' => array(100, 100, 100, 100), ); I want to be able to pick up the best players but I also want to take into account how reliable a player is (less entropy = more reliable), so far I've come up with the following formula: average - standard_deviation / 2 However I'm not sure if this is a optimal formula and I would like to hear your thoughts on this. I've been thinking some more on this problem and I've come up with a slightly different formula, here it is the revised version: average - standard_deviation / # of bets This result would then be weighted for the next upcoming vote, so for instance a new bet from player C would only count as half a bet. I can't go into specifics here but this is a project related with the Wisdom of Crowds theory and the Delphi method and my goal is to predict as best as possible the next results weighting past bets from several players. I appreciate all input, thanks.
0
0
0
0
1
0
Let's say I have a MySQL table that is something like this: software table: id int name text votes int rating int Where votes would be the number of times someone has voted for that item and rating would be the average of those votes. Example data: id: 0 name: FooBar! votes: 5 rating: 3 Now another user comes along and rates this a 1. How would I caculate the new rating? would be be better to just make another table and enter a new row every time someone votes like id int software_id int score int user_id int and then calculate the re-calculate the average rating every time? I would think it would take a toll on the server. Second question: I'd like to be able to order the software by the highest rated but I don't want a program with an average 5 star rating but only 1 vote to rank higher than a program with an average of 4 with 893 votes. How would I accomplish this?
0
0
0
0
1
0
I'd like to use correlation clustering and I figure R is a good place to start. I can present the data to R as a set of large, sparse vectors or as a table with a pre-computed dissimilarity matrix. My questions are: are there existing R functions to turn this into a hierarchical cluster with agnes that uses correlation clustering? will I have to implement the (admittedly simple) correlation clusteringfunction by hand, if so how do I make it play well with agnes?
0
1
0
0
0
0
Summary: I'm trying to do classification of some images depending on the angles between body parts. I assume that human body consists of 10 parts(as rectangles) and find the center of each part and calculate the angle of each part by reference to torso. And I have three action categories:Handwave-Walking-Running. My goal is to find which test images fall into which action category. Facts: TrainSet:1057x10 feature set,1057 stands for number of image. TestSet:821x10 I want my output to be 3x1 matrice each row showing the percentage of classification for action category. row1:Handwave row2:Walking row3:Running Code: actionCat='H'; [train_data_hw train_label_hw] = tugrul_traindata(TrainData,actionCat); [test_data_hw test_label_hw] = tugrul_testdata(TestData,actionCat); actionCat='W'; [train_data_w train_label_w] = tugrul_traindata(TrainData,actionCat); [test_data_w test_label_w] = tugrul_testdata(TestData,actionCat); actionCat='R'; [train_data_r train_label_r] = tugrul_traindata(TrainData,actionCat); [test_data_r test_label_r] = tugrul_testdata(TestData,actionCat); Train=[train_data_hw;train_data_w;train_data_r]; Test=[test_data_hw;test_data_w;test_data_r]; Target=eye(3,1); net=newff(minmax(Train),[10 3],{'logsig' 'logsig'},'trainscg'); net.trainParam.perf='sse'; net.trainParam.epochs=50; net.trainParam.goal=1e-5; net=train(net,Train); trainSize=size(Train,1); testSize=size(Test,1); if(trainSize > testSize) pend=-1*ones(trainSize-testSize,size(Test,2)); Test=[Test;pend]; end x=sim(net,Test); Question: I'm using Matlab newff method.But my output is always an Nx10 matrice not 3x1. My input set should be grouped as 3 classes but they are grouped to 10 classes. Thanks
0
0
0
1
0
0
In decimal (base 10), 1/3 can only be approximated to 0.33333 repeating. What number is the equivalent in binary that can only be represented as an approximation?
0
0
0
0
1
0
Possible Duplicates: Strange problem comparing floats in objective-C Is JavaScript’s math broken? 1.265 * 10000 = 126499.99999999999 ????? After watching this I discovered that in JavaScript: 0.1 + 0.2 === 0.3 evaluates to false. Is there a way to work around this?
0
0
0
0
1
0
I'm looking for a practical application to use a genetic algorithm for. Some things that have thought of are: Website interface optimization Vehicle optimization with a physics simulator Genetic programming Automatic test case generation But none have really popped out at me. So if you had some free time (a few months) to spend on a genetic algorithms project, what would you choose to tackle?
0
0
0
1
0
0
I want to use a GA to determine the optimal path from A to B, satisfying certain conditions (length, number of turns, etc.) An example of a path is: Up 4, Left 8, Down 3, Right 3, Down 1, Left 10, Up 4, Left 1, Up 3 The problem is, I don't really know a good way to represent information such as this in a good way for use in a GA, especially because paths have a variable length. Does anyone have a good idea how to do something like this?
0
1
0
0
0
0
I'm facing tho following problem: let's say u is a social network user and as such has a list of friends, F(u). a partition is a function F->G, where G is a set of groups such as High-school, university, work, etc'. I need to come up with algorithm to partite F: the input is F and also F(f) for every f in F (the list of friends for each of u's friends). during it's run the algorithm is allowed to ask u questions (for example "what is the best group for some specific user v?"). The amount of question should be kept to minimum (what is minimum is not really a clear number, but I would say 5% of the number of friends seem about right). obviously the resulting partition would not be optimal, but it should be acceptable as a starting point for later refinements. any thoughts would be greatly appreciated edit: no it's not homework. i believe homework would have clearer defined requirements and target function. anyway no, this is actually real world problem i'm facing. also i may have simplified it a bit, but in reality a user could be part of many groups (so it's more like F->P(G), where P(G) is the power group if G), so a better algorithm would be able to do that.
0
0
0
1
0
0
In this Wikipedia article about SVM there are a number of links to different implementations of MATLAB toolboxes for Support Vector Machines. Could anyone suggest which of these is best in terms of speed, ease of use, etc.?
0
0
0
1
0
0
Quaternions are good for interpolate rotations between them. so far so good. If I have a networking game, will it suffice to transfer the rotation as vector3f or should I use a quaternion? To make the game smoother I may have to interpolate between the last sent rotation and the current one. But can I interpolate rotations between two Quaternions which were created from Yaw/Pitch/Roll? Quaternion a = Quaternion.FromYawPitchRoll(x1,y1,z1); Quaternion b = Quaternion.FromYawPitchRoll(x2,y2,z2); a.Interpolate(b, value); // will this work correctly?
0
0
0
0
1
0
The .NET framework's Math functions mostly operate on double precision floats, there are no single precision (float) overloads. When working with single precision data in a high performance scenario this results in unnecessary casting and also calculating functions with more precision than is required, thus performance is affected to some degree. Is there any way of avoiding some of this additional CPU overhead? E.g. is there an open source math library with float overloads that calls underlying FPU instructions directly? (My understanding is that this would require support in the CLR). And actually I'm not sure if modern CPUs even have single precision instructions. This question has been partly inspired by this question about optimizing a sigmoid function: Math optimization in C#
0
0
0
0
1
0
I have been trying to grasp the basics of Support Vector Machines, and downloaded and read many online articles. But still am not able to grasp it. I would like to know, if there are some nice tutorial sample code which can be used for understanding or something, that you can think of, and that will enable me to learn SVM Basics easily. PS: I somehow managed to learn PCA (Principal Component Analysis). BTW, you guys would have guessed that I am working on Machine Learning.
0
0
0
1
0
0
How is the derivative of a f(x) typically calculated programmatically to ensure maximum accuracy? I am implementing the Newton-Raphson method, and it requires taking of the derivative of a function.
0
0
0
0
1
0
According to here, arithmetic-shift will bit-shift left and right. The right shift preserves the sign. Is there any unsigned right-shift operator, which fills the vacated bits with zero instead of the sign bit?
0
0
0
0
1
0
I am using their default POS tagging and default tokenization..and it seems sufficient. I'd like their default chunker too. I am reading the NLTK toolkit book, but it does not seem like they have a default chunker?
0
1
0
0
0
0
From a book of computer simulation, I got this two equation. The first is to calculate correlogram, the second is how to use correlogram to estimate variance. The common approach to estimate variance of observation is often not incorrect in computer simulation because observations are often related. My question is, the value I calculated from my program is very big, so it could not be correct. I think because r[k] is going to get near 0 when k gets greater, the second equation will give a quite large value, so maybe the equation is incorrect? As you asked, here is the whole program (written in Python): @property def autocorrelation(self): n = self.packet_sent mean = self.mean waiting_times = self.waiting_times R = [ sum([(x - mean) ** 2 for x in waiting_times[:-1]]) / n ] #print R for k in range(1, n / 4 + 1): R.append(0) for i in range(0, n - k): R[k] += (waiting_times[i] - mean) * (waiting_times[i + k] - mean) R[k] /= n auto_cor = [r / R[0] for r in R] return auto_cor @property def standard_deviation_wrong(self): '''This must be a wrong method''' s_x = self.standard_deviation_simple auto_cor = self.autocorrelation s = 0 n = self.packet_sent for k, r in enumerate(auto_cor[1:]): s += 1 - (k + 1.0) * r / n #print "%f %f %f" % (k, r, s) s *= 2 s += 1 s = ((s_x ** 2) * s) ** 0.5 return s
0
0
0
0
1
0
I have to include math symbols in my asp.net so whatever the symbols it may be sigma , integral , pie etc..or any how to write or display the Symbols in asp.net it should be UI so when the user click the particular Symbols it will display in the textbox or any editor control.. If anyone have idea let me know...? thanks.
0
0
0
0
1
0
I'm trying to cluster some images depending on the angles between body parts. The features extracted from each image are: angle1 : torso - torso angle2 : torso - upper left arm .. angle10: torso - lower right foot Therefore the input data is a matrix of size 1057x10, where 1057 stands for the number of images, and 10 stands for angles of body parts with torso. Similarly a testSet is 821x10 matrix. I want all the rows in input data to be clustered with 88 clusters. Then I will use these clusters to find which clusters does TestData fall into? In a previous work, I used K-Means clustering which is very straightforward. We just ask K-Means to cluster the data into 88 clusters. And implement another method that calculates the distance between each row in test data and the centers of each cluster, then pick the smallest values. This is the cluster of the corresponding input data row. I have two questions: Is it possible to do this using SOM in MATLAB? AFAIK SOM's are for visual clustering. But I need to know the actual class of each cluster so that I can later label my test data by calculating which cluster it belongs to. Do you have a better solution?
0
0
0
1
0
0
what are some of the things i need to consider when designing this object this is all i can think of int nominator int denominator int sign this object can be used in a math operation
0
0
0
0
1
0
I've written the following: var pages=["[www.facebook.com] Facebook is cool. ","[www.bbc.co.uk] British broadcasting corporation. "]; function findScoreC2(s){ var scores=[]; var percentageScores=[]; var contentsArray=[]; s=s.toLowerCase(); for(i=0;i<pages.length; i++){ contentsArray=pages[i].substring(pages[i].indexOf("]")+1,pages[i].lastIndexOf(" ")); var lowerCaseContents=(pages[i].substring(pages[i].indexOf("]")+1,pages[i].lastIndexOf(" "))).toLowerCase(); scores[i] =(lowerCaseContents.split(s)).length-1 }; percentageScores=(scores[i] / contentsArray[i].length) * 100; var finalArray=[]; for(i=0;i<percentageScores.length;i++){ finalArray.push("{score:"+percentageScores[i]+",index:"+i+"}") }; alert(finalArray); } findScoreC2("facebook"); however, alert(finalArray) alerts to nothing (ie an alert box comes up but it says nothing) when it should alert "{score:33,index:0},{score:0,index:1}". Could anyone enlighten me as to why this might be? Thanks very much
0
0
0
0
1
0