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 a sentence, for example John Doe moved to New York last year. Now I split the sentence into the single words and I get: array('John', 'Doe', 'moved', 'to', 'New', 'York', 'last', 'year') That's quite easy. But then I want to combine the single words to get all the composed terms. It doesn't if the composed terms make sense, I want to get all of them, though. The result of that operation should look like this: John, Doe, John Doe, moved, Doe moved, John Doe moved, to, moved to, Doe moved to ... The words should be composed to terms to a limit of k parts. In the example above, the limit is 3. So a term can contain 3 words at most. The problem: How could I code the composition in PHP? It would be great if I had a function which gets a sentence as the input and gives an array with all terms as the output. I hope you can help me. Thanks in advance!
0
1
0
0
0
0
I asked a question similar to this one a couple of weeks ago, but I did not ask the question correctly. So I am re-asking here the question with more details and I would like to get a more AI oriented answer. I have a list representing products which are more or less the same. For instance, in the list below, they are all Seagate hard drives. Seagate Hard Drive 500Go Seagate Hard Drive 120Go for laptop Seagate Barracuda 7200.12 ST3500418AS 500GB 7200 RPM SATA 3.0Gb/s Hard Drive New and shinny 500Go hard drive from Seagate Seagate Barracuda 7200.12 Seagate FreeAgent Desk 500GB External Hard Drive Silver 7200RPM USB2.0 Retail GE Spacemaker Laudry Mazda3 2010 Mazda3 2009 2.3L For a human being, the hard drives 3 and 5 are the same. We could go a little bit further and suppose that the products 1, 3, 4 and 5 are the same and put in other categories the product 2 and 6. In my previous question, someone suggested to me to use feature extraction. It works very well when we have a small dataset of predefined descriptions (all hard drives), but what about all the other kind of description? I don't want to start to write regex based feature extractors for all the descriptions my application could face, it doesn't scale. Is there any machine learning algorithm that could help me to achieve this? The range of description that I can get is very wide, on line 1, it could be a fridge, and then on the next line, a hard drive. Should I try to take the Neural Network path? What should be my inputs? Thank you for the help!
0
0
0
1
0
0
Is there any library that can be used for analyzing (nlp) simple english text. For example it would be perfect if it can do that; Input: "I am going" Output: I, go, present continuous tense
0
1
0
0
0
0
I'm looking for books and resource to teach myself linear algebra to be used in 3D graphics programming. I prefer practical approaches to teaching over theoretical (even though math is what, 99.99% theory?) ones, so the dream resource for me would be a book that tackles linear algebra as it's used with 3D graphics programming from a practical perspective.
0
0
0
0
1
0
I am working on a pong game and I am working on the mechanism to move the ball. If I add 1 to x the ball moves 1 pixel to the right, if i add 1 to y the ball moves 1 pixel to the bottom. What if I want to move the ball at a certain angle how can 1 calculate the coordinates.
0
0
0
0
1
0
My question arises from the post "Plain English Explanation of Big O". I don't know the exact meaning for logarithmic complexity. I know that I can make a regression between the time and the number of operations and calculate the X-squared value, and determine so the complexity. However, I want to know a method to determine it quickly on paper. How do you determine logarithmic complexity? Are there some good benchmarks?
0
0
0
0
1
0
I have a large number of text files (1000+) each containing an article from an academic journal. Unfortunately each article's file also contains a "stub" from the end of the previous article (at the beginning) and from the beginning of the next article (at the end). I need to remove these stubs in preparation for running a frequency analysis on the articles because the stubs constitute duplicate data. There is no simple field that marks the beginning and end of each article in all cases. However, the duplicate text does seem to formatted the same and on the same line in both cases. A script that compared each file to the next file and then removed 1 copy of the duplicate text would be perfect. This seems like it would be a pretty common issue when programming so I am surprised that I haven't been able to find anything that does this. The file names sort in order, so a script that compares each file to the next sequentially should work. E.G. bul_9_5_181.txt bul_9_5_186.txt are two articles, one starting on page 181 and the other on page 186. Both of these articles are included bellow. There is two volumes of test data located at [http://drop.io/fdsayre][1] Note: I am an academic doing content analysis of old journal articles for a project in the history of psychology. I am no programmer, but I do have 10+ years experience with linux and can usually figure things out as I go. Thanks for your help FILENAME: bul_9_5_181.txt SYN&STHESIA ISI the majority of Portugese words signifying black objects or ideas relating to black. This association is, admittedly, no true synsesthesia, but the author believes that it is only a matter of degree between these logical and spontaneous associations and genuine cases of colored audition. REFERENCES DOWNEY, JUNE E. A Case of Colored Gustation. Amer. J. of Psycho!., 1911, 22, S28-539MEDEIROS-E-ALBUQUERQUE. Sur un phenomene de synopsie presente par des millions de sujets. / . de psychol. norm, et path., 1911, 8, 147-151. MYERS, C. S. A Case of Synassthesia. Brit. J. of Psychol., 1911, 4, 228-238. AFFECTIVE PHENOMENA — EXPERIMENTAL BY PROFESSOR JOHN F. .SHEPARD University of Michigan Three articles have appeared from the Leipzig laboratory during the year. Drozynski (2) objects to the use of gustatory and olfactory stimuli in the study of organic reactions with feelings, because of the disturbance of breathing that may be involved. He uses rhythmical auditory stimuli, and finds that when given at different rates and in various groupings, they are accompanied by characteristic feelings in each subject. He records the chest breathing, and curves from a sphygmograph and a water plethysmograph. Each experiment began with a normal record, then the stimulus was given, and this was followed by a contrast stimulus; lastly, another normal was taken. The length and depth of breathing were measured (no time line was recorded), and the relation of length of inspiration to length of expiration was determined. The length and height of the pulsebeats were also measured. Tabular summaries are given of the number of times the author finds each quantity to have been increased or decreased during a reaction period with each type of feeling. The feeling state accompanying a given rhythm is always complex, but the result is referred to that dimension which seemed to be dominant. Only a few disconnected extracts from normal and reaction periods are reproduced from the records. The author states that excitement gives increase in the rate and depth of breathing, in the inspiration-expiration ratio, and in the rate and size of pulse. There are undulations in the arm volume. In so far as the effect is quieting, it causes decrease in rate and depth of 182 JOHN F. SHEPARD breathing, in the inspiration-expiration ratio, and in the pulse rate and size. The arm volume shows a tendency to rise with respiratory waves. Agreeableness shows
0
1
0
0
0
0
I am writing a game for gameboy advance and I am implementing basic AI in the form of a binary search tree. There is 1 human player and 1 computer player. I need to figure out a way of telling how aggressive the human player is being in attacking the computer. The human will push a button to attack (and must be in a certain radius of the computer), so my first thought was to see how big the number of attacks was compared to the number of iterations my main while loop had gone through. This seems like a poor way to do it though, because that number will depend on the frame rate, which can fluctuate. Does anyone have an idea for a better way to do this?
0
1
0
0
0
0
I have a unit vector, a distance and a coordinate and I would like to calculate the new coordinate given by adding the distance onto the coordinate in the given direction. How do I do this?
0
0
0
0
1
0
working with cygwin and writing a script to show my my current ip address minus 2. For some reason it is giving me the follwing error: ")syntax error: invalid arithmetic operator (error token is " this is the script I am using. $ cat test3.sh #!/bin/bash # function IPADDRESS { v=$4 echo $1.$2.$3.$((v-2)) } ADDRESS=$(ipconfig | grep Address | cut -f2 -d :) # echo $ADDRESS IPADDRESS ${ADDRESS//\./ } any help or suggestion is apprieciated!
0
0
0
0
1
0
Can a double (of a given number of bytes, with a reasonable mantissa/exponent balance) always fully precisely hold the range of an unsigned integer of half that number of bytes? E.g. can an eight byte double fully precisely hold the range of numbers of a four byte unsigned int? What this will boil down to is if a two byte float can hold the range of a one byte unsigned int. A one byte unsigned int will of course be 0 -> 255.
0
0
0
0
1
0
Given a list of points that form a simple 2d polygon oriented in 3d space and a normal for that polygon, what is a good way to determine which points are specific 'corner' points? For example, which point is at the lower left, or the lower right, or the top most point? The polygon may be oriented in any 3d orientation, so I'm pretty sure I need to do something with the normal, but I'm having trouble getting the math right. Thanks!
0
0
0
0
1
0
I need to calculate modulus with large number like : <?php $largenum = 95635000009453274121700; echo $largenum % 97; ?> It's not working... because $largenum is too big for an int in PHP. Any idea how to do this ?
0
0
0
0
1
0
How to convert an equation into formulas for individual variables? I am thinking about a math equations like: c^2 = a^2 + b^2 I would like to have a function that could process any formula, and give me the individual variable formulas. The above equation would produce the following: a = (c^2 - b^2)^0.5 b = (c^2 - a^2)^0.5 c = (a^2 + b^2)^0.5 I would also like to start with: a = (c^2 - b^2)^0.5 and output: b = (c^2 - a^2)^0.5 c = (a^2 + b^2)^0.5 I have looked at expression trees, but I am having trouble visualizing how this will work. I would like a .NET (C#, VB.NET, or F#) solution. Any ideas? Something like: public string[] GetFormulas(string equation) { ... } Thanks.
0
0
0
0
1
0
For example, given a matrix: 01|02|03|04|05 06|07|08|09|10 11|12|13|14|15 And knowing that the matrix is 5x3, is there a way that if given the value '7', that we can know it is in row 2? The case is that the matrix is always ordered from 1 to n, starting from 0. Lastly, the matrix is stored linearly in a zero based array.
0
0
0
0
1
0
I am trying to solve a tricky math problem, in a cocos2d for iphone context. Basically I have a roullette wheel which is rotating over time. I want to have a Sprite latch onto the wheel at certain points (like compass ordinal points N, S, E, W) and bounce off at all other points. I have the image of the wheel rotating, and just need to solve the part where I can test for whether a sprite has intersected with the circle at the right point on the circle as it is rotating. I think this question is going in the right direction, but I can't get my head around it. Can anyone help explain? Best way to find a point on a circle closest to a given point
0
0
0
0
1
0
I'd like to know what are the most recurrent in a given text or group of text (pulled from a database) in ruby. Does anyone know what are the best practices?
0
1
0
0
0
0
I've written a C++ matrix template class. It's parameterized by its dimensions and by its datatype: template<int NRows, int NCols, typename T> struct Mat { typedef Mat<NRows, NCols, T> MyType; typedef T value_type; typedef const T *const_iterator; typedef T *iterator; enum { NumRows = NRows }; enum { NumCols = NCols }; T m_data[NRows * NCols]; // ... Lot's of operations and functions ... // Some overloads typedef Mat<2, 1, int> Vec2i; typedef Mat<2, 1, float> Vec2f; typedef Mat<3, 1, float> Vec3f; typedef Mat<4, 1, unsigned char> Vec4ub; typedef Mat<4, 4, float> Mat44f; typedef Vec3f Vector; typedef Vec4ub Color; typedef Vec2f LonLat; It's a fantastic little class that handles lots of vector arithmetic and linear algebra. Also, it is able to interface easily with both low level code (OpenGL) and high level code (PID and Kalman filters). Its design seems sound to me, but that's not what this question is about. This class has one dreadful flaw: it is a dread to use in the debugger. Because it is a struct that contains an array, there is always that one annoying level of indirection when examining variables in Xcode (and I assume in VisualStudio). This is further aggravated by the fact that Xcode sometimes fails to follow chains of pointers correctly and I can't examine the values at all. This happens if I have, say, a vector of these objects. I realize that I could perhaps customize the debugger to somehow work with my type. But I was wondering if there is perhaps a different way to store the data of my Matrix so that it has better "debugability"? This is more of a "use your imagination" type question than one looking for a best-practices design. I'm just curious what alternative class layouts could be used while still maintaining the generic nature of the code.
0
0
0
0
1
0
Twitter, Google, Amazon, del.icio.us etc. all give you a lot of data to play with, all for free. There's also a lot of textual data available through initiatives like Project Gutenberg. And that, it seems, is just the tip of the iceberg. I have been wondering how you could use this data for fun. I'm a first year IT student, so I have no knowledge of statistics, machine learning, collaborative filtering etc. My interest in this area was piqued by the book Programming Collective Intelligence by Toby Segaran, and now I want to take a deeper look at what you can do with data. I don't know where to start. Any ideas? I have also been pondering whether I should go and buy something like Paradigms of Artificial Intelligence Programming. Is it worth the trip across the city?
0
1
0
1
0
0
I'm combing a webapp's log file for statements that stand out. Most of the lines are similar and uninteresting. I'd pass them through Unix uniq, however that filters nothing, as all the lines are slightly different: they all have a different timestamp, similar statements might print a different user ID, etc. What's a way and/or tool to get just the lines that are notably different from any other? (But, again, not precise duplicates) I was thinking about playing with Python's difflib but that seems geared toward diffing two files, rather than all pairs of lines in the same file. [EDIT] I assumed the solution would give a uniqueness score for each line. So by "notably different" I meant, I choose a threshold that the uniqueness score must exceed for any line to be included in the output. Based on that, if there are other viable ways to define it, please discuss. Also, the method doesn't have to have 100% accuracy and recall. [/EDIT] Examples: I'd prefer answers that are as general purpose as possible. I know I can strip away the timestamp at the beginning. Stripping the end is more challenging, as its language may be absolutely unlike anything else in the file. These sorts of details are why I shied from concrete examples before, but because some people asked... Similar 1: 2009-04-20 00:03:57 INFO com.foo.Bar - URL:/graph?id=1234 2009-04-20 00:04:02 INFO com.foo.Bar - URL:/graph?id=asdfghjk Similar 2: 2009-04-20 00:05:59 INFO com.baz.abc.Accessor - Cache /path/to/some/dir hits: 3466 / 16534, 0.102818% misses 2009-04-20 00:06:00 INFO com.baz.abc.Accessor - Cache /path/to/some/different/dir hits: 4352685 / 271315, 0.004423% misses Different 1: 2009-04-20 00:03:57 INFO com.foo.Bar - URL:/graph?id=1234 2009-04-20 00:05:59 INFO com.baz.abc.Accessor - Cache /path/to/some/dir hits: 3466 / 16534, 0.102818% misses In the Different 1 case, I'd like both lines returned but not other lines like them. In other words, those 2 lines are distinct types (then I can later ask for only statistically rare line types). The edit distance is much bigger between those two, for one thing.
0
1
0
0
0
0
I am attempting to rotate some text within a label. I have a cusom label which allows me to have control over the text rendering process. protected override void OnPaint ( PaintEventArgs pe ) { Graphics g = pe.Graphics; g.RotateTransform( angle ); g.drawString( text ); g.ResetTransform(); } The problem I am having is that the rotation appears to occur aroundthe origin of the control i.e. co-ordinates (0,0). Is there a method to allow the text to rotate about the center of the control rather than the oragin? I am aware of the function 'g.RotateTransform( )' so one possible solution would be to rotate the text and then translate it to the centre of the control. If this is the only way to manage the job, is there a generic manner which I can caluclate the transfor to ensure that the text is in the centre of the control? Thanks
0
0
0
0
1
0
I am having a hard time to find a way to detect if two words has the same rhyme in English. It has not to be the same syllabic ending but something closer to phonetically similarity. I can not believe in 2009 the only way of doing it is using those old fashioned rhyme dictionaries. Do you know any resources (in PHP would be a plus) to help me in this painful task? Thank you. Your hints were all really hepful. I will take some time to investigate it. Anyway, more info about DoubleMetaPhone can be found here in a proper PHP code (the other one is an extension). There are interesting information about MethaPhone function and doublemetaphone in Php.net. They specially alert about how slow double metaphone is compared with metaphone (something like 100 times slower).
0
1
0
0
0
0
I have a file with the following values: for 3 threads: Average time taken for API1 is: 19097.7 nanoseconds. Average time taken for API2 is: 19173.1 nanoseconds. Average time taken for API2 is: 19777.7 nanoseconds. Average time taken for API2 is: 19243.1 nanoseconds. Average time taken for API1 is: 19737.7 nanoseconds. Average time taken for API2 is: 19128.1 nanoseconds. for 5 threads: Average time taken for API1 is: 19097.7 nanoseconds. Average time taken for API2 is: 19173.1 nanoseconds. Average time taken for API2 is: 19777.7 nanoseconds. ... I wish to calculate the sum of the 1API lines and the 2API lines, and sum them. Another requirement is that i also want to figure out for each thread on a separate basis. Is there a way to do this using perl, sed, awk or just shell scripts? What I can current get is: cat result | grep API1 | awk {'print $7'}
0
0
0
0
1
0
In 32 bit integer math, basic math operations of add and multiply are computed implicitly mod 2^32, meaning your results will be the lowest order bits of the add or multiply. If you want to compute the result with a different modulus, you certainly could use any number of BigInt classes in different languages. And for values a,b,c < 2^32 you could compute the intermediate values in 64 bit long ints and use built in % operators to reduce to the right answe But I've been told that there are special tricks for efficiently computing a*b mod C when C is of the form (2^N)-1 or (2^N)+1, that don't use 64 bit math or a BigInt library and are quite efficient, more so than an arbitrary modulus evaluation, and also properly compute cases which would normally overflow a 32 bit int if you were including the intermediate multiplication. Unfortunately, despite hearing that such special cases have a fast evaluation method, I haven't actually found a description of the method. "Isn't that in Knuth?" "Isn't that somewhere on Wikipedia?" are the mumblings I've heard. It apparently is a common technique in random number generators which are doing multiplies of a*b mod 2147483647, since 2147483647 is a prime number equal to 2^31 -1. So I'll ask the experts. What's this clever special case multiply-with-mod method that I can't find any discussion of?
0
0
0
0
1
0
With reference to this programming game I am currently building. alt text http://img12.imageshack.us/img12/2089/shapetransformationf.jpg To translate a Canvas in WPF, I am using two Forms: TranslateTransform (to move it), and RotateTransform (to rotate it) [children of the same TransformationGroup] I can easily get the top left x,y coordinates of a canvas when its not rotated (or rotated at 90deg, since it will be the same), but the problem I am facing is getting the top left (and the other 3 points) coordinates. This is because when a RotateTransform is applied, the TranslateTransform's X and Y properties are not changed (and thus still indicate that the top-left of the square is like the dotted-square (from the image) The Canvas is being rotated from its center, so that is its origin. So how can I get the "new" x and y coordinates of the 4 points after a rotation? [UPDATE] alt text http://img25.imageshack.us/img25/8676/shaperotationaltransfor.jpg I have found a way to find the top-left coordinates after a rotation (as you can see from the new image) by adding the OffsetX and OffsetY from the rotation to the starting X and Y coordinates. But I'm now having trouble figuring out the rest of the coordinates (the other 3). With this rotated shape, how can I figure out the x and y coordinates of the remaining 3 corners? [EDIT] The points in the 2nd image ARE NOT ACCURATE AND EXACT POINTS. I made the points up with estimates in my head. [UPDATE] Solution: First of all, I would like to thank Jason S for that lengthy and Very informative post in which he describes the mathematics behind the whole process; I certainly learned a lot by reading your post and trying out the values. But I have now found a code snippet (thanks to EugeneZ's mention of TransformBounds) that does exactly what I want: public Rect GetBounds(FrameworkElement of, FrameworkElement from) { // Might throw an exception if of and from are not in the same visual tree GeneralTransform transform = of.TransformToVisual(from); return transform.TransformBounds(new Rect(0, 0, of.ActualWidth, of.ActualHeight)); } Reference: http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/86350f19-6457-470e-bde9-66e8970f7059/
0
0
0
0
1
0
Bulls & Cows is a game for two players in which each one has a secret number with 4 non-repeating digits, and each one tries to guess the other number. For instance, let´s say my secret number is 1576. If my opponent says the number 1234, i would answer: 1F, because the digit 1 is in my secret number and in the same position. If my opponent says the number 7890, i would answer: 1P, because the digit 7 is in my secret number and in different position. ETC. Here it is explained. Well, as a hobby, I wish to implement a computer player that tryes to guess my number, but I don't know where to start, any ideas? Is there something already done on this game? Is out there any C# Implementation?
0
1
0
0
0
0
Say i'm trying to evaluate the Polynomial: x^2 + 1 Using the Fast Fourier transform method for evaluating co-efficients. Now i can change this into matrix/vector form using the co-effcient as inputs for the fast fourier transform: so: x^2 + 1 = <1, 0, 1, 0> This is done by using the coefficient value e.g 1 = 1, 0x^1 = 0, X^2 = 1 and so on Now we get to the bit where i'm totally confused. I'm meant to use the vandermonde matrix :Vandermonde matrix ~ Wiki to evaluate these values into FFT Form using the matrix: 1 1 1 1 1 i-1-i 1-1 1-i 1-i 1 i The output of fft(1,0,1,0) is (2,0,2,0) Now thats the step i don't quite understand, how did we use that matrix to get (2,0,2,0)?
0
0
0
0
1
0
I want to use a data structure for sorting space-time data (x,y,z,time). Currently a processing algorithm searches a set of 4D (x,y,z,time) points, given a spherical (3d) spacial radius and a linear (1d) time radius, marking for each point, which other points are within those radii. The reason is that after processing, I can ask any 4D point for all of its neighbours in O(1) time. However in some common configurations of space and time radii, the first run of the algorithm takes about 12 hours. Believe it or not, that's actually fast compared to what exists in our industry. Nevertheless, I want to help speed up the initial runs and so I want to know: Is a kd-tree suitable for 4D space-time data? Note that I am not looking for implementations of nearest-neighbour search or k-nearest-neighbours search. More Info: An example dataset has 450,000 4D points. Some datasets are time-dense so ordering by time certainly saves processing, but still leads to many distance checks. Time is represented by Excel-style dates, with typical ranges between 30,000-39,000 (approximate). The space ranges are sometimes higher values, sometimes lower values, but the range between each space co-ordinate is similar to time (e.g. maxX-minX ~ maxT-minT). Even more info: I thought I'd add some more slightly irrelevant data in case anybody has dealt with a similar dataset. Basically I'm working with data that represents space-time events that are recorded and corroborated by multiple sensors. Error is involved, so only events that meet an error threshold are included. The time span of these datasets ranges between 5-20 years of data. For the really old data (>8 years old), the events were often very spacially dense for two reasons: 1) there were relatively few sensors available back then, and 2) the sensors were placed close together so that nearby events could be properly corroborated with low error. Further events could be recorded, but they had too high an error For the newer data (<8 years old), the events are often very time dense, for the inverse reasons: 1) there are usually many sensors available, and 2) the sensors are placed at regular intervals over a larger distance. As a result, the datasets cannot typically be said to be only time-dense or only spacially dense (except in the case of datasets that contain only new data). Conclusion I clearly should be asking more questions on this site. I will be testing out several solutions over the next while which will include the 4d kd-tree, a 3d kd-tree followed by time distance check (suggested by Drew Hall), and the current algorithm I have. Also, I have been suggested another data structure called TSP (time space partitioning) tree, which uses an octree for space and a bsp on each node for time, so I may test that as well. Assuming I remember, I'll be sure to post some profiling benchmarks on different time/space radii configurations. Thanks all
0
0
0
0
1
0
Been Googling around without finding much at all, so does anyone know of a class or library that helps you parse any sort of language, like a Domain Specific Language (I'm creating one, so I'm flexible in what the syntax and format can be) into either PHP code or some helpful struct or a class hiearchy or ... ? Anything goes at this point. :) I want to experiment with parsing text files into tokens, building up a small grammar and syntax library to express things like Business Natural Languages.
0
1
0
0
0
0
Does anyone know how can I calculate pi (π) in VB?
0
0
0
0
1
0
The following will ensure that any large numbers will only be precise to the hundredths place (related to this answer): public function round( sc:Number ):Number { sc = sc * 100; sc = Math.floor( sc ); sc = sc / 100; return sc; } What is the optimal way to round my numbers to the precision of .05? Is there something clever to be done with bit-shifting to get this result? For example, I would like: 3.4566 = 3.45 3.04232 = 3.05 3.09 = 3.1 3.32 = 3.3
0
0
0
0
1
0
I need to reverse a function with hard Math operations, I'm asking here to check if it's even possible, eventually for help. public static UInt32 Func_4(UInt32 P, UInt32 X, UInt32 G) { UInt64 result = 1; UInt64 mult = G; if (X == 0) return 1; while (X != 0) { if ((X & 1) != 0) result = (mult * result) % P; X = X >> 1; mult = (mult * mult) % P; } return (UInt32)result; } By "Reversing" I mean this: I know G, I know P, I know the result. I need X. I tried to translate it again this morning while my mind was clear, but I failed. Is it even possible? Thank you in advance.
0
0
0
0
1
0
what is substraction and summation using successors , can any one show me an example for that i know how to do it the normal way . /* sub(X, Y, Z) ---subtraction */ sub(X, Y, Z) :- add(Y, Z, X).
0
1
0
0
0
0
I am trying to force 64 bit long integers on OS X 10.5.6. running on an Apple MacBook Intel Core 2 Duo. Here is my c code: #include<stdio.h> int main() { long a = 2147483647; /*== 2^32 - 1*/ long aplus1; printf("a== %d. sizeof(a) == %d ", a, sizeof(a)); aplus1 = a+1; printf("aplus1 = %d ", aplus1); } Compiling without any switches yields the following: $ gcc testlong.c -o testlong ;./testlong a== 2147483647. sizeof(a) == 4 aplus1 = -2147483648 Compiling with the -m64 switch yields: $ gcc testlong.c -o testlong -m64; ./testlong a== 2147483647. sizeof(a) == 8 aplus1 = -2147483648 So the second version is apparently using 64 bit storage, but still generates the overflow error, although 2^32 should be well within the range of a 64 bit integer. Any ideas? I would prefer a solution that can be forced from a gcc option rather than requiring me to change multiple lines of source code (my actual problem is not the above example specifically, rather I need to force long integer arithmetic in a more general situation).
0
0
0
0
1
0
I am hoping for insight into what looks like a partial multiplication. #define LOW(x) ((x)&0xffffffff) #define HIGH(x) ((x)>>32) unsigned long long NotMultiply(unsigned long long x, unsigned long long y) { return HIGH(x)*HIGH(y) + LOW(x)*LOW(y); } This function is iterated multiple times, as follows: unsigned long long DoBusyWork( unsigned long long x, unsigned long long y, int n) { while (n--) x = NotMultiply(x,y); return x; } Are there any shortcuts for calculating this result ? What about for the case where x == y? Any links to more information would help..
0
0
0
0
1
0
I want to use the math constants, such as M_PI and M_E, in Visual C++ 2008. I assumed they were defined in the cmath header.
0
0
0
0
1
0
I'm working on building intelligence around link propagation, and because I need to deal with many short URL services where a reverse-lookup from an exact URL address is required, I need to be able to resolve multiple approximate versions of the same URL. An example would be a URL like http://www.example.com?ref=affil&hl=en&ct=0 Of course, changing GET params in certain circumstances can refer to a completely different page, especially if the GET params in question refer to a profile or content ID. But a quick parse of the page would quickly determine how similar the pages were to each other. Using a bit of machine learning, it could quickly become clear which GET params don't effect the content of the pages returned for a given site. I'm assuming a service to send a URL and get a list of very similar URLs could only be offered by the likes of Google or Yahoo (or Twitter), but they don't seem to offer this feature, and I haven't found any other services that do. If you know of any services that do cluster together groups of almost identical URLs in the aforementioned way, please let me know. My bounty is a hug.
0
0
0
1
0
0
I'm writing a MiPS program that will examine a list of 15 test scores. And it is going to input from the terminal. The passing criterion is the score of 50. The outputs to the terminal will include the scores in each category and the number of students passing and failing. I should use input prompts and output statement. Please I need some help, just need some advice how to do it. main: li $t1,15 #load 15 into $t1 la $a1,array #load a pointer to array into $a1 I have a loop: addi $t1,$t1,-1 li $v0,4 la $a0,prompt syscall
0
0
0
0
1
0
EDIT: Now a Major Motion Blog Post at http://messymatters.com/sealedbids The idea of rot13 is to obscure text, for example to prevent spoilers. It's not meant to be cryptographically secure but to simply make sure that only people who are sure they want to read it will read it. I'd like to do something similar for numbers, for an application involving sealed bids. Roughly I want to send someone my number and trust them to pick their own number, uninfluenced by mine, but then they should be able to reveal mine (purely client-side) when they're ready. They should not require further input from me or any third party. (Added: Note the assumption that the recipient is being trusted not to cheat.) It's not as simple as rot13 because certain numbers, like 1 and 2, will recur often enough that you might remember that, say, 34.2 is really 1. Here's what I'm looking for specifically: A function seal() that maps a real number to a real number (or a string). It should not be deterministic -- seal(7) should not map to the same thing every time. But the corresponding function unseal() should be deterministic -- unseal(seal(x)) should equal x for all x. I don't want seal or unseal to call any webservices or even get the system time (because I don't want to assume synchronized clocks). (Added: It's fine to assume that all bids will be less than some maximum, known to everyone, say a million.) Sanity check: > seal(7) 482.2382 # some random-seeming number or string. > seal(7) 71.9217 # a completely different random-seeming number or string. > unseal(seal(7)) 7 # we always recover the original number by unsealing.
0
0
0
0
1
0
So here's my challenge. I have a spreadsheet that looks like this: prod_id | pack | value | durable | feat | ease | grade | # of ratings 1 75 85 99 90 90 88 1 2 90 95 81 86 87 88 9 3 87 86 80 85 82 84 37 4 92 80 68 67 45 70 5 5 93 81 94 93 90 90 4 6 93 70 60 60 70 70 1 Each product has individual grade criteria (packaging - ease of use), an overall average grade, and number of ratings the product received. The entire data set I have places 68% of the products within the 80-89 grade range. I need to have the grades recalculated to take into account the number of ratings for the product, so products that fall far below the total average number of ratings are ranked lower (and receive a lower grade). Basically a product with a grade of 84 and 100 ratings should rank higher than a product with a grade of 95 with only 5 ratings. I hope this makes sense, thanks for any help in advance!
0
0
0
0
1
0
What are some C/c++ Machine learning libraries that supports clustering of multi dimensional data? (for example K-Means) So far I have come across SGI MLC++ http://www.sgi.com/tech/mlc/ OpenCV MLL I am tempted to roll-my-own, but I am sure pre-existing ones are far better performance optimized with more eyes on code.
0
0
0
1
0
0
Is there an algorithm that can calculate the digits of a repeating-decimal ratio without starting at the beginning? I'm looking for a solution that doesn't use arbitrarily sized integers, since this should work for cases where the decimal expansion may be arbitrarily long. For example, 33/59 expands to a repeating decimal with 58 digits. If I wanted to verify that, how could I calculate the digits starting at the 58th place? Edited - with the ratio 2124679 / 2147483647, how to get the hundred digits in the 2147484600th through 2147484700th places.
0
0
0
0
1
0
I'm working on a cross language information retrieval that takes queries in english and searches documents in Russian. To evaluate this system it would be nice to have a collection of russian documents to search through. Does anyone out there know of a collection of documents I can search or websites from which I can easily scrape together a bunch of russian documents (aside from wikipedia)? Documents can be about anything though it would be nice if they were in some specific area of human knowledge (CS, architecture, engineering, art, literature analysis, whatever...)
0
1
0
0
0
0
I am writing a MiPS program that will examine a list of 15 test scores. And it is going to input from the terminal.Well, the passing criterion is the score of 50. the ouptuts to the terminal will include the scores in each category and the number of students passing and failing. with input prompts and output statements...Below is the program i wrote but it didnt work....Please i need....i dont know if i m doing it wrong.. .globl main .text main: li $t0, 0 #counter for passing grades la $t1, pass #pointer for pass array li $t2, 0 #counter for failing grades la $t3, fail #pointer for pass array li $t4, 0 #overall counter li $t5, 0 li $t6, 0 loop: li $v0, 4 #system call for print string la $a0, prompt #load string syscall li $v0, 5 #system call for read integer syscall #read integer bltu $v0, 50, else #if $v0 < 50 branch to else (failing grade) sw $v0, 0($t1) #store word in pass array addi $t1, $t1, 4 #t1 = t1 + 4 (increment pass pointer) addi $t0, $t0, 1 #t0 = t0 + 1 (increment pass counter) b l_end #branch over else statement else: sw $v0, 0($t3) #store word in fail array addi $t3, $t3, 4 #t3 = t3 + 4 (increment fail pointer) addi $t2, $t2, 1 #t1 = t1 + 1 (increment fail counter) l_end: addi $t4, $t4, 1 #increment overall counter bltu $t4, 15, loop #if t4 <= 15 branch to loop output counts li $v0, 4 #system call for print string la $a0, o_pasc #load string syscall #output "Number of Passing Scores: la $v0, 1 #system call for print integer add $a0, $t0, 0 #load value of pass counter into $a0 syscall #output value li $v0, 4 #system call for print string la $a0, o_fasc #load string syscall #output "Number of Failing Scores: " la $v0, 1 #system call for print string add $a0, $t2, 0 #load value of fail counter into $a0 syscall #output value output passing scores li $v0, 4 #setup output la $a0, o_pass #setup text syscall #output string o_pass la $t1, pass #load address of pass pointer to t1 lw $a0, 0($t1) #load word at $t1 into $a0 li $v0, 1 #system call for print integer loop_a: bleu $t0, $t5, lp_a_end #if t0 <= t5 branch to lp_a_end syscall #output single score li $v0, 4 #system call for print string la $a0, o_coma #load string syscall #ouput comma and space li $v0, 1 #setup output addi $t1, $t1, 4 #move pointer down by 1 word lw $a0, 0($t1) #move word at pointer into $a0 addi $t5, $t5, 1 #add 1 to counter b loop_a #branch to top lp_a_end: output failing scores la $t5, 0 #clear t5 (counter) li $v0, 4 #setup output la $a0, o_fail #setup text syscall #output string o_fail la $t3, fail #load address for fail pointer into $t3 lw $a0, 0($t3) #load word at mem addy $t3 into $a0 li $v0, 1 #system call for print integer loop_b: bleu $t2, $t5, lp_b_end #if t2 <= t5 branch to lp_a_end syscall #output single score li $v0, 4 #system call for print string la $a0, o_coma #load string syscall #output comma and space li $v0, 1 #setup output addi $t3, $t3, 4 #move pointer down by 1 word lw $a0, 0($t3) #load word from mem addy $t3 to $a0 addi $t5, $t5, 1 #add 1 to counter b loop_b #branch to top lp_b_end: end li $v0, 4 #setup output la $a0, o_brk #setup text syscall #output line break li $v0, 10 #loads 10 to $v0 syscall #ends program
0
0
0
0
1
0
I have a C++ application in which I need to compare two values and decide which is greater. The only complication is that one number is represented in log-space, the other is not. For example: double log_num_1 = log(1.23); double num_2 = 1.24; If I want to compare num_1 and num_2, I have to use either log() or exp(), and I'm wondering if one is easier to compute than the other (i.e. runs in less time, in general). You can assume I'm using the standard cmath library. In other words, the following are semantically equivalent, so which is faster: if(exp(log_num_1) > num_2)) cout << "num_1 is greater"; or if(log_num_1 > log(num_2)) cout << "num_1 is greater";
0
0
0
0
1
0
I'm looking for a culturally-sensitive way to properly insert a noun into a sentence while using the appropriate article (a/an). It could use String.Format, or possibly something else if the appropriate way to do this exists elsewhere. For example: Base Sentence: "You are looking at a/an {0}" This should format to: "You are looking at a carrot" or "You are looking at an egg." I'm currently doing this by manually checking the first character of the word to be inserted and then manually inserting "a" or "an." But I'm concerned that this might limit me when the application is localized to other languages. Is there a best practice for approaching this problem? RESOLUTION: It appears that the problem is complicated to the point that there does not exist a utility or framework to solve this problem in the way I originally phrased. It appears that the best solution (in my situation) is to store the article in the database along with the noun so that the translators can have the level of control they need. Thanks for all of the suggestions!
0
1
0
0
0
0
The German website nandoo.net offers the possibility to shorten a news article. If you change the percentage value with a slider, the text changes and some sentences are left out. You can see that in action here: http://www.nandoo.net/read/article/299925/ The news article is on the left side and tags are marked. The slider is on the top of the second column. The more you move the slider to the left, the shorter the text becomes. How can you offer something like that? Are there any algorithms which you can use to achieve that? My idea was that their algorithm counts the number of tags and nouns in a sentence. Then the sentences with fewest number of tags/nouns are left out. Could that be true? Or do you have another idea? I hope you can help me. Thanks in advance!
0
1
0
0
0
0
We are supposed to calculate e^x using this kind of formula: e^x = 1 + (x ^ 1 / 1!) + (x ^ 2 / 2!) ...... I have this code so far: while (result >= 1.0E-20 ) { power = power * input; factorial = factorial * counter; result = power / factorial; eValue += result; counter++; iterations++; } My problem now is that since factorial is of type long long, I can't really store a number greater than 20! so what happens is that the program outputs funny numbers when it reaches that point .. The correct solution can have an X value of at most 709 so e^709 should output: 8.21840746155e+307 The program is written in C++.
0
0
0
0
1
0
Let's say you have access to an email account with the history of received emails from the last years (~10k emails) classified into 2 groups genuine email spam How would you approach the task of creating a neural network solution that could be used for spam detection - basically classifying any email either as spam or not spam? Let's assume that the email fetching is already in place and we need to focus on classification part only. The main points which I would hope to get answered would be: Which parameters to choose as the input for the NN, and why? What structure of the NN would most likely work best for such task? Also any resource recommendations, or existing implementations (preferably in C#) are more than welcome Thank you EDIT I am set on using neural networks as the main aspect on the project is to test how the NN approach would work for spam detection Also it is a "toy problem" simply to explore subject on neural networks and spam
0
0
0
1
0
0
Before everyone jumps on me for outsourcing my homework, my question is not a question on my homework. I'm just having a problem getting some stuff to draw properly. I'm trying to draw lines perpendicular to a plane. I know the three points in space the make up the plane. From those coordinates I can calculate vectors and get the normal vector of the plane. Using the coordinates from the center of the three points and the normal vector I can draw a line perpendicular to the plane. My problem is that the length of that line is tied to the normal vector because I'm just adding the vector to the coordinates to get two points to draw a line on. Without using some hideous brute-force code how do I draw a line of fixed length given any point in 3D space and any vector. (I'm asking here because I don't know terms to use to search on google, my textbook doesn't have anything dealing with this, and my professor isn't going to be available before this is due.)
0
0
0
0
1
0
I'm witnessing a strange behavior in a .net program : Console.WriteLine(Int64.MaxValue.ToString()); // displays 9223372036854775807, which is 2^63-1, as expected Int64 a = 256*256*256*127; // ok Int64 a = 256*256*256*128; // compile time error : //"The operation overflows at compile time in checked mode" // If i do this at runtime, I get some negative values, so the overflow indeed happens. Why do my Int64's behaves as if they were Int32's, although Int64.MaxValue seems to confirm they're using 64 bits ? If it's relevant, I'm using a 32 bit OS, and the target platform is set to "Any CPU"
0
0
0
0
1
0
What are some good tips and/or techniques for optimizing and improving the performance of calculation heavy programs. I'm talking about things like complication graphics calculations or mathematical and simulation types of programming where every second saved is useful, as opposed to IO heavy programs where only a certain amount of speedup is helpful. While changing the algorithm is frequently mentioned as the most effective method here,I'm trying to find out how effective different algorithms are in the first place, so I want to create as much efficiency with each algorithm as is possible. The "problem" I'm solving isn't something thats well known, so there are few if any algorithms on the web, but I'm looking for any good advice on how to proceed and what to look for. I am exploring the differences in effectiveness between evolutionary algorithms and more straightforward approaches for a particular group of related problems. I have written three evolutionary algorithms for the problem already and now I have written an brute force technique that I am trying to make as fast as possible. Edit: To specify a bit more. I am using C# and my algorithms all revolve around calculating and solving constraint type problems for expressions (using expression trees). By expressions I mean things like x^2 + 4 or anything else like that which would be parsed into an expression tree. My algorithms all create and manipulate these trees to try to find better approximations. But I wanted to put the question out there in a general way in case it would help anyone else. I am trying to find out if it is possible to write a useful evolutionary algorithm for finding expressions that are a good approximation for various properties. Both because I want to know what a good approximation would be and to see how the evolutionary stuff compares to traditional methods.
0
0
0
0
1
0
I am working on a roguelike in my (very little) free time. Each level will basically be a few rectangular rooms connected together by paths. I want the paths between rooms to be natural-looking and windy, however. For example, I would not consider the following natural-looking: B X X X XX XX XX AXX I really want something more like this: B X XXXX X X X X AXXXXXXXX These paths must satisfy a few properties: I must be able to specify an area inside which they are bounded, I must be able to parameterize how windy and lengthy they are, The lines should not look like they started at one path and ended at the other. For example, the first example above looks as if it started at A and ended at B, because it basically changed directions repeatedly until it lined up with B and then just went straight there. I was hoping to use A*, but honestly I have no idea what my heuristic would be. I have also considered using a genetic algorithm, but I don't know how practical that method might end up. My question is, what is a good way to get the results I want? Please do not just specify a method like "A*" or "Dijkstra's algorithm," because I also need help with a good heuristic.
0
1
0
0
0
0
I'll try to explain this problem the best way i can with code: double power = 5000; //picked up 5 power ups, now need to increase power by 10% per powerup power += 5 * (power * .10); //later on...ran into 5 power downs need to decrease power back to initial hp power -= 5 * (power * .10);//7500 - 3750 -- doesn't work So what i need is a scaleable solution that gets back to the original value using only the count. Any ideas?
0
0
0
0
1
0
Its friday, and in local time the clock is 3.22pm, so my brain wont give me a solution, so i ask: Im trying to write a function/algorithm in Actionscript 3.0 that gives me the most average positions of x number of positions along a path of y number of available positions. Y is always larger than X of course. The background is, I got a map, with for example 50 possible placements of objects (along a path). But i only got 32 objects to place along this path, but i want their placements to be as average/even along that path as possible. So that it for example won't be a big gap at the end. My avaiable positions are at the moment stored in an array with point values. If you just do totalPos/wantedPos and floor it, it will be a "ugly" gap at the end, any ideas? EDIT: I wanted to add the function incase anyone else wants it: function place (x : uint, y : uint ) : Array { var a : Array = new Array(); var s : Number = y / x; var c : Number = 0; for (var i : Number = 0; i<x; i++) { c++; var pos : Number = Math.round(i * s); a.push(posArray[pos]); } return a; } Assumes you have an array posArray with the possible positions already...
0
0
0
0
1
0
I was wondering if there is any good and clean object-oriented programming (OOP) implementation of Bayesian filtering for spam and text classification? This is just for learning purposes.
0
1
0
0
0
0
How could I go about keeping track of the number of times a word appears in a textfile? I would like to do this for every word. For example, if the input is something like: "the man said hi to the boy." Each of "man said hi to boy" would have an occurrence of 1. "the" would have an occurence of 2. I was thinking of keeping a dictionary with word/occurrence pairs but I'm not sure how to implement this in C. A link to any similar or related problems with a solution would be great. EDIT: To avoid rolling out my own hash table I decided to learn how to use glib. Along the way I found an excellent tutorial which walks through a similar problem. http://bo.majewski.name/bluear/gnu/GLib/ch03s03.html I am awestruck by the number of different approaches, and in particular the simplicity and elegance of the Ruby implementation.
0
1
0
0
0
0
If I use relative frequency to estimate the probability of an event, how good is my estimate based on the number of experiments? Is standard deviation a good measure? A paper/link/online book would be perfect. http://en.wikipedia.org/wiki/Frequentist
0
0
0
0
1
0
Suppose I have the following: A region defined by minimum and maximum latitude and longitude (commonly a 'lat-long rect', though it's not actually rectangular except in certain projections). A circle, defined by a center lat/long and a radius How can I determine: Whether the two shapes overlap? Whether the circle is entirely contained within the rect? I'm looking for a complete formula/algorithm, rather than a lesson in the math, per-se.
0
0
0
0
1
0
What is meant by the statement that functional programs are "more tractable mathematically"?
0
0
0
0
1
0
The typical FFT for audio looks pretty similar to this, with most of the action happening on the far left side http://www.flight404.com/blog/images/fft.jpg He multiplied it by a partial sine wave to get it to the bottom, but the article isn't too specific on this part of it. It also seems like a "good enough" modification of the dataset, rather than one based on some property. I understand that human hearing is better suited to the higher frequencies, thus, most music will have amplified bass and attenuated treble so that both sound to us as being of relatively equal strength. My question is what modification needs to be done to the FFT to compensate for this standard falloff? for(i = 0; i < fft.length; i++){ fft[i] = fft[i] * Math.log(i + 1); // does, eh, ok but the high // end is still not really "loud" // enough } EDIT :: http://en.wikipedia.org/wiki/Equal-loudness_contour I came across this article, I think it might be the direction to head in, but there still might be some property of an FFT that needs to be counteracte.
0
0
0
0
1
0
I'm an artist involved with building various sorts of computer controlled machines. I've started prototyping a gimble-based XY painting machine and have realized that the maths needed are out of my reach. I'm a decent enough programmer but not strong in math- esp. 3D math. To get a sense of what I'm needing to do, it might be helpful to look at the rig: Early prototype: http://roypardi.com/gimble/gimbleSmall.MOV (small video) http://roypardi.com/gimble/gimbleLarge.mov (larger video) The two inner rings represent the X/Y axes and are controlled by stepper motors. I want to be able to use both raster images and vector data (gcode). So I need to be able to address a point in 2D space on the paper/from my data and have the gimble figure out what orientation it needs to be at in order to get there (i.e. how much to step each motor). I've been searching out 2D > 3D projection, Euler angles, etc. but I'm out of my depth. Any pointers, pushes in the right direction, or code snippets would be most welcome. I can make sense of most programming languages.
0
0
0
0
1
0
I've got an agent that takes in states and returns actions, while keeping an internal representation of the utility of state/action pairs. I've also got an environment that takes in actions and returns state/reward pairs. I need to be able to set the agent up with a start state and then continuously go from agent -(action)-> environment -(state, reward)-> agent -(action)->... However, the internal states (which need to be updated every iteration) need to stay private (that is, within the agent or the environment). This means that I can't simply call environment as a function within the agent using state and action as arguments. I'm somewhat of a Haskell noobie, so I'm not even sure if this is possible.
0
1
0
0
0
0
I am considering parsing simple math equations by compiling from source at runtime. I have heard that there are security considerations that I should be aware of before using this approach, but I can’t find any info on this. Thanks C# .net 2.0, winforms
0
0
0
0
1
0
I've the following code in PHP which works fine (returns more or less 10 results each time it runs): function GetAboutTenRandomNumbers() { $result = array(); for ($i = 0; $i < 240; $i++) { if (Chance(10, 240) === true) { $result[] = $i; } } echo '<pre>'; print_r($result); echo '</pre>'; return $result; } And the Chance() function goes as follows: function Chance($chance, $universe = 100) { $chance = abs(intval($chance)); $universe = abs(intval($universe)); if (mt_rand(1, $universe) <= $chance) { return true; } return false; } Now, I want to randomly split those 10 (on average) results in the 4 following segments: the first one having a probability of 10% * 10 = 1 the second one having a probability of 20% * 10 = 2 the third one having a probability of 30% * 10 = 3 the fourth one having a probability of 40% * 10 = 4 As you can see the sum of all segments (1 + 2 + 3 + 4) equals 10, so I've coded the following function to do this. function GetAboutTenWeightedRandomNumbers() { $result = array(); // Chance * 10% for ($i = 0; $i < 60; $i++) { if (Chance(10 * 0.1, 240) === true) { $result[] = $i; } } // Chance * 20% for ($i = 60; $i < 120; $i++) { if (Chance(10 * 0.2, 240) === true) { $result[] = $i; } } // Chance * 30% for ($i = 120; $i < 180; $i++) { if (Chance(10 * 0.3, 240) === true) { $result[] = $i; } } // Chance * 40% for ($i = 180; $i < 240; $i++) { if (Chance(10 * 0.4, 240) === true) { $result[] = $i; } } echo '<pre>'; print_r($result); echo '</pre>'; return $result; } The problem is I've run the GetAboutTenWeightedRandomNumbers function dozens of times and the result is much more lower than the result returned by the GetAboutTenRandomNumbers function. I'm sure that I'm making a fundamental math mistake, I suspect where but I don't know how to solve it.
0
0
0
0
1
0
I've been looking around a bit and can't seem to find just what I"m looking for. I've found "canonical formulas," but what's the best way to use these? Do I have to scale every single vertex down? Or is there a better way? A formula would really help me out, but I'm also looking for an explanation about the near and far z planes relative the viewer's position
0
0
0
0
1
0
I'm writing some children's Math Education software for a class. I'm going to try and present problems to students of varying skill level with randomly generated math problems of different types in fun ways. One of the frustrations of using computer based math software is its rigidity. If anyone has taken an online Math class, you'll know all about the frustration of taking an online quiz and having your correct answer thrown out because your problem isn't exactly formatted in their form or some weird spacing issue. So, originally I thought, "I know! I'll use an expression parser on the answer box so I'll be able to evaluate anything they enter and even if it isn't in the same form I'll be able to check if it is the same answer." So I fire up my IDE and start implementing the Shunting Yard Algorithm. This would solve the problem of it not taking fractions in the smallest form and other issues. However, It then hit me that a tricky student would simply be able to enter most of the problems into the answer box and my expression parser would dutifully parse and evaluate it to the correct answer! So, should I not be using an expression parser in this instance? Do I really have to generate a single form of the answer and do a string comparison?
0
0
0
0
1
0
How would one implement shuffle for the "Celestial Jukebox"? More precisely, at each time t, return an uniform random number between 0..n(t), such that there are no repeats in the entire sequence, with n() increasing over time. For the concrete example, assume a flat-rate music service which allows playing any song in the catalog by a 0 based index number. Every so often, new songs are added which increase range of index numbers. The goal is to play a new song each time (assuming no duplicates in the catalog). an ideal solution would be feasible on existing hardware - how would I shoehorn a list of six million songs in 8MB of DRAM? Similarly, the high song count exacerbates O(n) selection timings. -- For an LCG generator, given a partially exhausted LCG on 0..N0, can that be translated to a different LCG on 0..N1 (where N1 > N0), that doen't repeat the exhausted sequence. -- Checking if a particular song has already been played seems to rapidly grow out of hand, although this might be the only way ? Is there an efficient data structure for this?
0
0
0
0
1
0
Duplicate When should I use double instead of decimal? .. and many more... We use the C# and SQL Server decimal datatypes throughout our apps because of their accuracy. Never had any of those irritating problems where the total doesn't add up to the detail, etc. I was wondering why double and float exist at all given their inaccuracy
0
0
0
0
1
0
If I have a large set of data that describes physical 'things', how could I go about measuring how well that data fits the 'things' that it is supposed to represent? An example would be if I have a crate holding 12 widgets, and I know each widget weighs 1 lb, there should be some data quality 'check' making sure the case weighs 13 lbs maybe. Another example would be that if I have a lamp and an image representing that lamp, it should look like a lamp. Perhaps the image dimensions should have the same ratio of the lamp dimensions. With the exception of images, my data is 99% text (which includes height, width, color...). I've studied AI in school, but have done very little outside of that. Are standard AI techniques the way to go? If so, how do I map a problem to an algorithm? Are some languages easier at this than others? Do they have better libraries? thanks.
0
1
0
0
0
0
Can someone explain mathematical induction to prove a recursive method? I am a freshmen computer science student and I have not yet taken Calculus (I have had up through Trig). I kind of understand it but I have trouble when asked to write out an induction proof for a recursive method.
0
0
0
0
1
0
I have the following Perl script that generates a string based on a number: my @chars; push @chars, map(chr, 48..57), map(chr, 97..122); my $c = $#chars+1; for (0..50) { my $string; my $l = $_ / $c; my $i = int $l; my $r = ($l - $i) * $c; $string .= $chars[$r]; while ($i > 0) { $l = $i / $c; $i = int $l; $r = ($l - $i) * $c; $string .= $chars[$r]; } print "$string "; } When I run this I get the following output: 0 1 2 3 4 ... z 01 01 21 21 41 41 61 61 81 91 91 b1 b1 d1 d1 What am I missing? Thankful for any help!
0
0
0
0
1
0
I have the matrix system: A x B = C A is a by n and B is n by b. Both A and B are unknown but I have partial information about C (I have some values in it but not all) and n is picked to be small enough that the system is expected to be over constrained. It is not required that all rows in A or columns in B are over constrained. I'm looking for something like least squares linear regression to find a best fit for this system (Note: I known there will not be a single unique solution but all I want is one of the best solutions) To make a concrete example; all the a's and b's are unknown, all the c's are known, and the ?'s are ignored. I want to find a least squares solution only taking into account the know c's. [ a11, a12 ] [ c11, c12, c13, c14, ? ] [ a21, a22 ] [ b11, b12, b13, b14, b15] [ c21, c22, c23, c24, c25 ] [ a31, a32 ] x [ b21, b22, b23, b24, b25] = C ~= [ c31, c32, c33, ?, c35 ] [ a41, a42 ] [ ?, ?, c43, c44, c45 ] [ a51, a52 ] [ c51, c52, c53, c54, c55 ] Note that if B is trimmed to b11 and b21 only and the unknown row 4 chomped out, then this is almost a standard least squares linear regression problem.
0
0
0
0
1
0
Behind the tables and tables of raw data, how does Wolfram Alpha work? I imagine there are various artificial intelligence mechanisms driving the site but I can't fathom how anyone would put something like this together. Are there any explanations that would help a programmer understand how something like this is created? Does the knowledge base learn on its own or is it taught very specific details in a very organized manner? What kind of structure and language is used to store this type of data? Obviously this is a huge question and can't fully be answered here but some of the general concepts would be nice to know so I can build off of them and do my own research.
0
1
0
1
0
0
I want to know the first double from 0d upwards that deviates by the long of the "same value" by some delta, say 1e-8. I'm failing here though. I'm trying to do this in C although I usually use managed languages, just in case. Please help. #include <stdio.h> #include <limits.h> #define DELTA 1e-8 int main() { double d = 0; // checked, the literal is fine long i; for (i = 0L; i < LONG_MAX; i++) { d=i; // gcc does the cast right, i checked if (d-i > DELTA || d-i < -DELTA) { printf("%f", d); break; } } } I'm guessing that the issue is that d-i casts i to double and therefore d==i and then the difference is always 0. How else can I detect this properly -- I'd prefer fun C casting over comparing strings, which would take forever. ANSWER: is exactly as we expected. 2^53+1 = 9007199254740993 is the first point of difference according to standard C/UNIX/POSIX tools. Thanks much to pax for his program. And I guess mathematics wins again.
0
0
0
0
1
0
I'm trying to construct a contrapositive for the following statement: If A is 0 or B is 0, then A*B is 0. Here is my attempt: If A*B is not 0, then A is not 0 or B is not 0. The original statement is true, but the contrapositive is false since both A and B must be non-zero in order for A*B to be non-zero... am I doing something wrong?
0
0
0
0
1
0
I'm trying to make it so that no matter how far apart two objects are they'll both remain on screen. I'm using JOGL, but that shouldn't matter as I just need help with the math. This is what I have so far: float distance = (float) ((Math.sqrt((p1.x - p2.x) + (p1.y - p2.y)))); float camx = (float)((p1.x + p2.x) * 0.5); float camy = (float)((p1.y + p2.y) * 0.5); float camz = (float) (distance * 5); What is the math I need so the Z zooms in and out correctly?
0
0
0
0
1
0
What is a good algorithm to determine the necessary fraction needed to add/sub to the number in order to round it to the nearest integer without using the inbuilt ceiling or floor funcitons? Edit: Looking for a mathematical number trick to figure out the part needed to round the number to the nearest integer. The more primitive the math operations the better. Please avoid using other's procedures. 0.5 can be taken eitherway, whatever suits your method. This is NOT my homework question, nor am I going to use this anywhere.
0
0
0
0
1
0
If I know the number number y and know that 2^x=y, how do I compute x?
0
0
0
0
1
0
I need a function which takes a line (known by its coordinates) and return a line with same angle, but limited to certain length. My code gives correct values only when the line is turned 'right' (proven only empirically, sorry). Am I missing something? public static double getAngleOfLine(int x1, int y1, int x2, int y2) { double opposite = y2 - y1; double adjacent = x2 - x1; if (adjacent == Double.NaN) { return 0; } return Math.atan(opposite / adjacent); } // returns newly calculated destX and destY values as int array public static int[] getLengthLimitedLine(int startX, int startY, int destX, int destY, int lengthLimit) { double angle = getAngleOfLine(startX, startY, destX, destY); return new int[]{ (int) (Math.cos(angle) * lengthLimit) + startX, (int) (Math.sin(angle) * lengthLimit) + startY }; } BTW: I know that returning arrays in Java is stupid, but it's just for the example.
0
0
0
0
1
0
Right now i have return 'Heads' if Math.random() < 0.5 Is there a better way to do this? Thanks edit: please ignore the return value and "better" means exact 50-50 probability.
0
0
0
0
1
0
Related to my previous question, is there some realistic chance to extract surveillance camera positions out of google streetview pictures by means of computer vision algorithms? I'm no expert in that area. But it should be easier than face detection and the like.
0
1
0
1
0
0
What are eigen values, vectors and expansions and as an algorithm designer how can I use them? EDIT: I want to know how YOU have used it in your program so that I get an idea. Thanks.
0
0
0
0
1
0
I was thinking about how in the probably distant future many people think that we wont rely on physical input (i.e. keyboard) as much because the technology that reads brain waves (which already exists to some extent) will be available. Kinda scares me....anyway, I while I was daydreaming about this, the idea came to me that: what if a programmer could implement logic in their code to accurately predict the users intentions and then carry out the intended operation with no need for human interaction. I am not looking for anything specific, I'm just a little curious as to what anyone's thoughts are.
0
1
0
0
0
0
The related questions that appear after entering the title, and those that are in the right side bar when viewing a question seem to suggest very apt questions. Stack Overflow only does a SQL search for it and uses no special algorithms, said Spolsky in a talk. What algorithms exist to give good answers in such a case. How do U do database search in such a case? Make the title searchable and search on the keywords or search on tags and those questions with many votes on top?
0
1
0
0
0
0
CUMIPMT(Rate,NumberOfPayments,PresentValue,StartPeriod,EndPeriod,Type).? plz tell me a step by step guide how this formula works.
0
0
0
0
1
0
How to find whether a line intercepted in a polygon
0
0
0
0
1
0
Given a function y = f(A,X): unsigned long F(unsigned long A, unsigned long x) { return ((unsigned long long)A*X)%4294967295; } How would I find the inverse function x = g(A,y) such that x = g(A, f(A,x)) for all values of 'x'? If f() isn't invertible for all values of 'x', what's the closest to an inverse? (F is an obsolete PRNG, and I'm trying to understand how one inverts such a function). Updated If A is relatively prime to (2^N)-1, then g(A,Y) is just f(A-1, y). If A isn't relatively prime, then the range of y is constrained... Does g( ) still exist if restricted to that range?
0
0
0
0
1
0
I need to manage lists with find-command. Suppose the lists have random names in non-distinct lists (ie their intersection is not empty set). How can I do: A \ B find files in the list A except the files in the list B A intersection B find files common to the lists A and B Please, consult here. A union B find all files in the two lists EXAMPLES $ find . | awk -F"/" '{ print $2 }' .zcompdump .zshrc .bashrc .emacs $ find ~/bin/FilesDvorak/.* -maxdepth 0 | awk -F"/" '{ print $6 }' .bashrc .emacs .gdbinit .git I want: A \ B: .zcompdump .zshrc A Intersection B: .bashrc .emacs A Union B: .zcompdump .zshrc .bashrc .emacs .bashrc .emacs .gdbinit .git A try for the Intersection When I save the outputs to separate lists, I cannot understand why the command does not take the common things, ie the above intersection: find -f all_files -and -f right_files . Questions emerged from the question: find ~/bin/FilesDvorak/.* -maxdepth 0 -and ~/.PAST_RC_files/.* Please, consult for recursive find Click here! find ~/bin/FilesDvorak/.* -maxdepth 0 -and list
0
0
0
0
1
0
I'm computing the ordinate y of a point on a line at a given abscissa x. The line is defined by its two end points coordinates (x0,y0)(x1,y1). End points coordinates are floats and the computation must be done in float precision for use in GPU. The maths, and thus the naive implementation, are trivial. Let t = (x - x0)/(x1 - x0), then y = (1 - t) * y0 + t * y1 = y0 + t * (y1 - y0). The problem is when x1 - x0 is small. The result will introduce cancellation error. When combined with the one of x - x0, in the division I expect a significant error in t. The question is if there exist another way to determine y with a better accuracy ? i.e. should I compute (x - x0)*(y1 - y0) first, and divide by (x1 - x0) after ? The difference y1 - y0 will always be big.
0
0
0
0
1
0
This can be broken down into a simple trio of equations: a + b = 3 b + c = 5 a + c = 4 How can I best approximate the values? Note, I'll have many more such totals and variables in real applications. Particularly, I want to find if its possible to usefully approximate the cost of food by item lists and totals from grocery receipts. I assume if I can figure out costs, there will be varying ranges of accuracy I can expect, so an extra would be knowing how likely the approximation is to be correct and within what range the price must be. EDIT: I just don't see this getting an answer I'm comfortable with, because I failed to properly frame the question in the first place.
0
0
0
0
1
0
How can I find prime numbers through bit operations in C++?
0
0
0
0
1
0
In my 3D application I store object's position in a vector and it's rotation around the origin in a quaternion. I need to rotate the object around a vector with an arbitrary origin. I tried converting the position - vectorOrigin and the rotation into a matrix, rotating the matrix and then extracting the position and rotation as a vector and a quaternion from the resulting matrix. The position comes up ok, but the rotation remains constant (the object rotates around the given vector but it always faces in the same direction). Is my method wrong or do I have a bug?
0
0
0
0
1
0
Do the below without any conditional or comparison operator. if (Number <= 0) { Print '0'; } else { print Number; } thanks..
0
0
0
0
1
0
My drive has DMG-blocks. The sum of their sizes is strictly below 47GB. I have 11 DVDs, each of the size 4.7GB. I want to use as small amount of DVDs as possible, without using compressing (the problem may be superflous, since it considers the most optimal combinations in terms of DMG-files. You can think it in terms of compressed files, if you want.). You can see that the DMG-files have arbitrary sizes. So many solutions are possible. find . -iname "*.dmg" -exec du '{}' \; 3&> /dev/null 1026064 ./Desktop/Desktop2.dmg 5078336 ./Desktop/Desktop_2/CS_pdfs.dmg 2097456 ./Desktop/Desktop_2/Signal.dmg 205104 ./Dev/things.dmg 205040 ./Dev/work.dmg 1026064 ./DISKS/fun.dmg 1026064 ./DISKS/school.dmg 1026064 ./DISKS/misc.dmg 5078336 ./something.dmg The files in DVDs can have an arbitrary order. For example, CS_pdfs.dmg and Signal.dmg do not need to be on the some disk. So how can you find the way to use as small amount of DVDs as possible?
0
0
0
0
1
0
I was glancing through the contents of Concrete Maths online. I had at least heard most of the functions and tricks mentioned but there is a whole section on Special Numbers. These numbers include Stirling Numbers, Eulerian Numbers, Harmonic Numbers so on. Now I have never encountered any of these weird numbers. How do they aid in computational problems? Where are they generally used?
0
0
0
0
1
0
Ok so I have to prove the following sequent: (p -> r) ^ (q -> r) |- p ^ q -> r I understand why that is clearly correct and I also understand the rules of natural deduction. What I don't understand is how I go about proving it. Here is the model answer provided: 1. (p -> r) ^ (q -> r) |- p ^ q -> r premise 2. p ^ q assumption 3. p ^e 2 4. p -> r ^e 1 5. r ->e 4,3 6. p ^ q -> r ->i 2,5 (e = elimination / i = introduction). Could someone provide me with a link or a 'dumbed-down' explanation? I feel like I am missing a simple concept that is causing this to be hard to understand... ? For example, on line 4, why does it require the p from line 3 to remove the ->, where as in line 3, you can remove the ^ q without using a q? I am sure this is quite straight forward but it doesn't seem to make sense to me... ?
0
0
0
0
1
0
I'd like a floor function with the syntax int floor(double x); but std::floor returns a double. Is static_cast <int> (std::floor(x)); guaranteed to give me the correct integer, or could I have an off-by-one problem? It seems to work, but I'd like to know for sure. For bonus points, why the heck does std::floor return a double in the first place?
0
0
0
0
1
0
I have a simple object that allows you to assign three properties (x,y,z) (lets call this object a "point", because that is what it is). I then have a second object with a method that accepts two instances of the first object, and returns the distance between the two "points" in three dimensional space. I also need a method that will accept two "points" and a double, representing distance traveled (from the first "point" parameter used) that returns a "point" object with its x,y,z coordinates. I'm ok with everything except the calculation of the point coordinates that are on the original line between the two points supplied, that is at a certain distance from the first point. "point" object: public class POR { private double PORX; private double PORY; private double PORZ; public double X { get { return PORX; } set { PORX = value; } } public double Y { get { return PORY; } set { PORY = value; } } public double Z { get { return PORZ; } set { PORZ = value; } } public POR(double X, double Y, double Z) { PORX = X; PORY = Y; PORZ = Z; } I'm then using : public double PorDistance(POR por1, POR por2) { return Math.Round(Math.Sqrt( Math.Pow((por1.X - por2.X),2) + Math.Pow((por1.Y - por2.Y),2) + Math.Pow((por1.Z - por2.Z),2)),2); } to return the distance between those two points I need something like public POR IntersectPOR (POR por1, POR por2, double distance) { } where distance is the distance traveled from por1 towards por2.
0
0
0
0
1
0
I am doing a behind the curtains 3d simulation while rendering the world in my 2d isometric engine. I've never done an isometric engine before, and my matrix math is rusty in general so I am having problems. I have a projection matrix, which in its simplest form is this: 0.7 0.35 0 0 -0.87 0 -0.71 0.35 1 A couple of signs are flipped because my engines coordinate system is 0,0 in the top left, with +X to the right/east and +Z to the south. Now, the inverse of that is: 1.4080 0.5670 0.0000 0.0000 -1.1490 0.0000 1.0000 0.8050 1.0000 Now, these matrices mostly work. For instance WC: 500,0,500 = Screen: -1.44, 350, 500 (X and Y are correct) WC: 0,0,500 = Screen: -355, 175, 500 (X and Y are correct again) But, now if you need to go the other way, you no longer have that handy Z value, so Screen: -1.44, 350, 0 = WC: -2, -402.97, 0 (So, garbage.) And lots more - as soon as I no longer have that Z value, I can't retrieve the world coords from the screen coords. What's the workaround here? EDIT I should point out that the point of the unproject is to get a ray for mouse picking.. It seems like it's just my misperception of what I was doing that was screwing me up here.
0
0
0
0
1
0