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 would like to retrieve the plural words in different languages in Python. I know that openoffice has an API called uno (import uno) and it should give me this ability using openoffice's language dictionaries, but I could not find any reference to it. As a concrete example, I would something like this: >>> print getPluralOf('table') tables One possibility is to download the dictionary files though this link and write a method to read the dictionary and form the plurals. But i can't believe that this is not available already using uno. I appreciate any help
0
1
0
0
0
0
Possible Duplicate: Mod of negative number is melting my brain! I was wondering if there was a nicer algorithm for what I'm trying to do: wrapIndex(-6, 3) = 0 wrapIndex(-5, 3) = 1 wrapIndex(-4, 3) = 2 wrapIndex(-3, 3) = 0 wrapIndex(-2, 3) = 1 wrapIndex(-1, 3) = 2 wrapIndex(0, 3) = 0 wrapIndex(1, 3) = 1 wrapIndex(2, 3) = 2 wrapIndex(3, 3) = 0 wrapIndex(4, 3) = 1 wrapIndex(5, 3) = 2 I came up with function wrapIndex(i, i_max) { if(i > -1) return i%i_max; var x = i_max + i%i_max; if(x == i_max) return 0; return x; } Is there a nicer way to do this?
0
0
0
0
1
0
I would like to create exclamations for a particular sentence using the java API? e.g. It's surprising == Isn't it surprising! e.g. It's cold == Isn't it cold! Are there any vendors or tools which help you generate exclamations, provided you give a sentence (i.e. the left hand side in the above example). Note: The sentences will be provided by the user and we should be able to get the correct sentence. I am not sure, if this needs to be tagged under other categories EDIT1 Some more examples, I would like this to be as generic as possible e.g. They're late == Aren't they late! e.g. He looks tired == Doesn't he look tired! e.g. That child is dirty == Isn't that child dirty! e.g. It's hot == Isn't it hot!
0
1
0
0
0
0
I have data that spans multiple months and I want to be able to take the average per day and separate it to the appropriate months. For example, say that one data point is 2/9/2010 - 3/8/2010 and the amount is 1500. Then, the query should return 1071.4 for February 2010 and 428.6 for March. I am hoping there is a MySQL statement that will be able to do the computations instead of my PHP logic. Thanks. EDIT (added table definition): start (datetime), end (datetime), use EDIT 2: Here is some dummy data DROP TABLE IF EXISTS `dummy_data`; CREATE TABLE `dummy_data` ( `id` int(11) NOT NULL AUTO_INCREMENT, `start_date` date NOT NULL, `end_date` date NOT NULL, `data` double(15,4) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=8 DEFAULT CHARSET=latin1; -- ---------------------------- -- Records of `dummy_data` -- ---------------------------- BEGIN; INSERT INTO `dummy_data` VALUES ('1', '2010-01-01', '2010-02-02', '200.0000'), ('2', '2010-02-03', '2010-02-25', '250.0000'), ('3', '2010-02-26', '2010-03-08', '300.0000'), ('4', '2010-03-09', '2010-04-12', '210.0000'), ('5', '2010-04-13', '2010-05-10', '260.0000'), ('6', '2010-05-11', '2010-06-15', '310.0000'), ('7', '2010-06-16', '2010-07-20', '320.0000'); COMMIT;
0
0
0
0
1
0
I am basically trying to create a display object transformation manager which will allow me to scale/rotate objects. I am currently trying to figure out how to rotate an object so its corner follows the current x and y of the mouse. I always get confused on the math of things like this. I know how to listen for the events and everything, I just am unsure of how to calculate the amount of rotation to apply. I will probably be rotating via a Matrix so I can rotate the object around its center, rather than the upper-left corner of it. Can anyone who is more skilled with the math of this help me out? IN RESPONSE TO TROBADOUR Your answer is so brilliant that I can't understand it at all. Let me explain what I can grasp and what I can't. Here's a walkthrough of what I do/don't understand: First, save what will be the middle of the image, the so-called registration point around which we will rotate everything: var box:Sprite = new BeautifulSprite(); box.width = box.height = 100; /* ... */ var registrationPoint:Point = new Point(box.x + box.width / 2, box.y + box.height / 2); Am I correct so far? If so, I'll continue. Second, denote the original mouse-down position: var mouseDownPoint:Point = new Point(box.mouseX, box.mouseY); Third, store the "vector." Problem is, I'm not sure of what you mean vector. I am familiar with Vector types in Java and AS3, in that they store a list of values of a certain type. Beyond that, I'm lost. var vector:* = WTF.forReals(); Next, save the distance between registrationPoint and mouseDownPoint. I remember learning about calculating distance between two points way back in high school, so I'm sure I could dig up the formula for distance between two 2d points. var distance:Number = calculateDistance(registrationPoint, mouseDownPoint); I know I'm getting close! Next, to determine the constrained scale, we get the current mouse location, determine its distance to registrationPoint, and divide that by distance. var constrainedScale:Number = calculateDistance(registrationPoint, new Point(mouseX, mouseY)) / distance; My question here is: how do I get values when I don't want them constrained, like scaleX and scaleY? Now, to get the actual rotation around the registration point, I am completely lost. Could you help me out, using the variables I have defined above?
0
0
0
0
1
0
How much of the concepts conveyed in natural language is RDF/OWL able to represent? I'm still learning RDF and other semantic technologies, but as I currently understand it, information is typically represented as triples of the form (subject,predicate,object). So I can imagine how the sentence "Bob has a hat" might be represented. However, how would you represent a more complicated sentence like "Bob, over on 42nd street, will have a job at the Mall after the owner approves"? Are there conventions for tags representing nouns/verbs/ownership/causality/tense/etc? Note, I'm not asking how to automatically convert arbitrary natural language text to RDF (as this currently appears impossible). I'm just trying to understand how RDF might be used to represent the same information that natural language represents.
0
1
0
1
0
0
I have a program which records events that occur with some probability p. After I run it I get k events recorded. How can I calculate how many events there were, recorded or not, with some confidence, say 95%? So for example, after getting 13 events recorded I would like to be able to calculate that there were between 13 and 19 events total with 95% confidence.
0
0
0
0
1
0
I have a set of segments defined by two points. Given a point how can I discover the closest segment to such point? I have already written an algorithm that computes the distance between a point and a segment. Anyway calculating such distance for each segment and then choose the segment with the lowest distance is not really efficient :( Since the segments represent streets this is actually a Reverse GeoCoding problem so I hope there are well-known solutions to this problem... THANKS A LOT!
0
0
0
0
1
0
I'm trying to figure out how to do this. Essentially I have points A and B which I know the location of. I then have point C and point D which I only know the coordinates of C. I know the length of C-D and know that C-D must be parallel to A-B. How could I generally solve for D given A,B,C and length of C-D. alt text http://img706.imageshack.us/img706/4494/imgclr.png
0
0
0
0
1
0
I have: from __future__ import division import nltk, re, pprint f = open('/home/a/Desktop/Projects/FinnegansWake/JamesJoyce-FinnegansWake.txt') raw = f.read() tokens = nltk.wordpunct_tokenize(raw) text = nltk.Text(tokens) words = [w.lower() for w in text] f2 = open('/home/a/Desktop/Projects/FinnegansWake/catted-several-long-Russian-novels-and-the-NYT.txt') englishraw = f2.read() englishtokens = nltk.wordpunct_tokenize(englishraw) englishtext = nltk.Text(englishtokens) englishwords = [w.lower() for w in englishwords] which is straight from the NLTK manual. What I want to do next is to compare vocab to an exhaustive set of English words, like the OED, and extract the difference -- the set of Finnegans Wake words that have not, and probably never will, be in the OED. I'm much more of a verbal person than a math-oriented person, so I haven't figured out how to do that yet, and the manual goes into way too much detail about stuff I don't actually want to do. I'm assuming it's just one or two more lines of code, though.
0
1
0
0
0
0
I have a training set that has input and outputs in this way: Input: 0.832 64.643 0.818 78.843 1.776 45.049 0.597 88.302 1.412 63.458 1.468 49.535 1.985 33.387 2.073 30.279 1.431 55.231 1.116 68.521 1.617 44.362 2.159 66.512 Output: 0 0 1 0 0 1 0 1 0 0 0 1 0 0 1 1 0 0 0 0 1 1 0 0 1 0 0 0 0 1 0 0 1 0 1 0 1 0 0 1 0 0 0 1 0 0 1 0 I need to implement one linear layer neural network that can represent the data set best in MATLAB. What would be the algorithm to do it in MATLAB? The target output is "1 for a particular class that the corresponding input belongs to and "0 for the remaining 2 outputs.
0
1
0
0
0
0
Is there a way to determine if the given message is a spam? For example those who posts on forums and advertise their own sites for various products.
0
1
0
0
0
0
noob here wants to calculate compound interest on iPhone. float principal; float rate; int compoundPerYear; int years; float amount; formula should be: amount = principal*(1+rate/compoundPerYear)^(rate*years) I get slightly incorrect answer with: amount = principal*pow((1+(rate/compoundPerYear)), (compoundPerYear*years)); I'm testing it with rate of .1, but debugger reports .100000001 . Am I doing it wrong? Should I use doubles or special class (e.g., NSNumber)? Thanks for any other ideas! After further research it seems that the NSDecimalNumber class may be just what I need. Now I just have to figure out how to use this bad boy.
0
0
0
0
1
0
I'm going into my third year of studies as an AI student and am planning my third year project. I have been considering a recommendation system of some sort. The motivation for this is to gain an understanding of how people evaluate products (what makes the products desirable) and consequently attempt to build a system that would understand this. Currently my thinking is along the lines of a system that would be able to differentiate between different priorities in peoples' likes and dislikes. For instance a person who is environmentally very aware probably wouldn't want to buy products that are not. So the question is - What things are most in need of repair/development in the modern web AI systems (Google, Amazon, Last.fm and so on). My project is limited to about 6 months but I would be interested to hear any thought on the subject.
0
1
0
0
0
0
I'm playing around with code like this: <s:Button id="test" label="test" transformX="{Math.floor(test.width/2)}" rotationY="20" x="20" y="20" /> The button is rotated on the Y axis and the rotate pivot is in the middle of the button. This will create a button that looks something like this: (source: jeffryhouser.com) The rotated button is, visually, filling a different space than the x, y, height, and width values would you have believe. The "A" value in my image is the height of the button. But, what I want to use for calculation and placement purposes is the B value. Additionally, I'd like to perform similar calculations with the width; getting the width from the top right corner to the bottom left corner. How do I do this? I put together a sample to show off the various approaches for calculating this that people are suggesting. The source code is also available. Nothing is quite working like I'd expect. For example, turn the rotationSlider to 85. The button is effectively invisible, yet all approaches are still giving it height and width.
0
0
0
0
1
0
I am developing an image analysis app and I need to calculate the aspect ratio of a segmented particle. According to http://www.sympatec.com/Science/Characterisation/05_ParticleShape.html the AR is given by (FIG 1) Xfmin/Xfmax. Any suggestion of an algorithm to get this values (Xf)?
0
0
0
0
1
0
I'm wondering what would be the best way to store math constants that are used throughout an entire program? #define PI 3.14159265 #define SPEEDOFLIGHT 2.99792458e8 or enum constants { PI = 3.14159265; SPEEDOFLIGHT = 2.99792458e8; } Thanks
0
0
0
0
1
0
Ive been trying to implement a limit to prevent the user from scaling the image too much in my multitouch zoom app. Problem is, when i set the max zoom level by dumping the matrix, the image starts to translate downward once the overall scale of the image hits my limit. I believe it is doing this because the matrix is still being affected by postScale(theScaleFactorX,theScaleFactorY,myMidpointX,myMidpointY) where theScaleFactorX/Y is the amount to multiply the overall scale of the image (so if the theScaleFatorX/Y is recorded as 1.12, and the image is at .60 of its origional size, the overall zoom is now .67). It seems like some sort of math is going on thats creating this translation, and was wondering if anyone knew what it was so i can prevent it from translating, and only allow the user to zoom back out.
0
0
0
0
1
0
A webapp called StatSheet got funded today (August 4th, 2010) http://techcrunch.com/2010/08/04/former-crunchies-finalist-statsheet-recieves-1-3-million-in-series-a/ They are doing 'automated journalism' - using computers to generate human-looking reports of sports games from the statistics http://www.guardian.co.uk/media/pda/2010/mar/30/digital-media-algorithms-reporting-journalism Does anyone have any insight into what approach/algorithms are being used to do this / how it might be replicated ?
0
1
0
1
0
0
Okay, this bugged me for several years, now. If you sucked in statistics and higher math at school, turn away, now. Too late. Okay. Take a deep breath. Here are the rules. Take two thirty sided dice (yes, they do exist) and roll them simultaneously. Add the two numbers If both dice show <= 5 or >= 26, throw again and add the result to what you have If one is <= 5 and the other >= 26, throw again and subtract the result from what you have Repeat until either is > 5 and < 26! If you write some code (see below), roll those dice a few million times and you count how often you receive each number as the final result, you get a curve that is pretty flat left of 1, around 45° degrees between 1 and 60 and flat above 60. The chance to roll 30.5 or better is greater than 50%, to roll better than 18 is 80% and to roll better than 0 is 97%. Now the question: Is it possible to write a program to calculate the exact value f(x), i.e. the probability to roll a certain value? Background: For our role playing game "Jungle of Stars" we looked for a way to keep random events in check. The rules above guarantee a much more stable outcome for something you try :) For the geeks around, the code in Python: import random import sys def OW60 (): """Do an open throw with a "60" sided dice""" val = 0 sign = 1 while 1: r1 = random.randint (1, 30) r2 = random.randint (1, 30) #print r1,r2 val = val + sign * (r1 + r2) islow = 0 ishigh = 0 if r1 <= 5: islow += 1 elif r1 >= 26: ishigh += 1 if r2 <= 5: islow += 1 elif r2 >= 26: ishigh += 1 if islow == 2 or ishigh == 2: sign = 1 elif islow == 1 and ishigh == 1: sign = -1 else: break #print sign #print val return val result = [0] * 2000 N = 100000 for i in range(N): r = OW60() x = r+1000 if x < 0: print "Too low:",r if i % 1000 == 0: sys.stderr.write('%d ' % i) result[x] += 1 i = 0 while result[i] == 0: i += 1 j = len(result) - 1 while result[j] == 0: j -= 1 pSum = 0 # Lower Probability: The probability to throw this or less # Higher Probability: The probability to throw this or higher print "Result;Absolut Count;Probability;Lower Probability;Rel. Lower Probability;Higher Probability;Rel. Higher Probability;" while i <= j: pSum += result[i] print '%d;%d;%.10f;%d;%.10f;%d;%.10f' % (i-1000, result[i], (float(result[i])/N), pSum, (float(pSum)/N), N-pSum, (float(N-pSum)/N)) i += 1
0
0
0
0
1
0
This may sound like a bit of a rhetorical question, but I ask it here for two reasons: It took me a while to figure out what C++ std::norm() was doing differently from MATLAB/Octave, so others may stumble upon it here. I find it odd to define the norm() function as being something different (though closely related) to what is generally considered to be the norm (or L2-norm, or Euclidean norm, etc., etc.) Specifically the C++ standard library defines norm() for complex numbers to be the square of the modulus (or absolute value), where the modulus is sqrt(a^2 + b^2) when the complex number is in the form a + i*b. This goes against my understanding of the norm, which when specified as the Euclidean norm (which corresponds to the modulus used here), is the square root of the sum of squares. I'll reference Mathworld's definition of the complex modulus. Is this something others have run into? I found it as a result of porting some signal processing code from Octave to C++, and the only other place I found reference to this difference was on the GCC mailing list.
0
0
0
0
1
0
I have to find the set of action of my agent in wumpus. In this case my agent can turn left, turn right and go forward. Now I have one method that can find the adjustcent of my agent. I also have another method that can find the direction of my agent(North,East,West,South) Assuming agent stand at 2,2 position and the current direction is north and I want to go to 2,3 the step are turn right follow by forward. How can i generate this in JAVA. Another example is agent stand at 3,3 and current direction is south and I want to go to 2,3 the step are turn right or turn left 2 times follow by forward. Ps 1. The left up conner is 0,0 and the right down conner is 3,3
0
1
0
0
0
0
The simple algorithm to create a parallel polyline to an existing polyline is simple: you can calculate the normal of each vertex (as the average of the segment's normals) and displace the vertices using the normal with whatever amount you want. However, there's a graphical problem when I try to use this algorithm on a curved polyline, this is, a succession of points which form an arc. When I create the parallel to the arc polyline, everything is fine until I increase the distance enough that projected vertices through their normals create a polyline where advancing from one vertex to another one actually moves in the reverse direction creating a self-intersection. How can I remove such vertices from the parallel polyline efficiently? I've though of comparing the direction of the segments: if the generated segments are not parallel, it means I've reached a point were the parallel polyline intersects itself. However, this doesn't work very well for small segments (a curved polyline will generate even smaller segments) or polylines which originally have degenerate vertices (one vertex equal to the next one).
0
0
0
0
1
0
How do i calculate the neperian logarithm on AS2 ???
0
0
0
0
1
0
.NET 4.0 now has a new data type, System.Numeric.BigInteger. From what I understand, this can hold numbers that have, up to, 1 million digits. Simple arithmetic operations can be performed on this number. What I am wondering is how Microsoft implemented such a thing, given that it would obviously exceed 32-bits and even 64-bits. How does this not overflow?
0
0
0
0
1
0
I am looking for a way given an English text count verb phrases in it in past, present and future tenses. For now I am using NLTK, do a POS (Part-Of-Speech) tagging, and then count say 'VBD' to get past tenses. This is not accurate enough though, so I guess I need to go further and use chunking, then analyze VP-chunks for specific tense patterns. Is there anything existing that does that? Any further reading that might be helpful? The NLTK book is focused mostly on NP-chunks, and I can find quite few info on VP-chunks.
0
1
0
0
0
0
I'm doing a project on mining blog contents and I need help differentiating on which tool to uses. When do I use a parser, when do I use a tagger, and when do I need to use a NER tool? For instance, I want to find out the most talked about topics/subjects between several blogs; do I use a part-of-speech tagger to grab the nouns and do a frequency count? That would probably be insufficient because very generic terms can pop up right? Or do I have a list of categories and these synonyms that I can match on? BTW, I'm using nltk, but am looking at stanford tagger or parser since a couple of dudes said that it was good.
0
1
0
0
0
0
Are there any equally great packages like Python's NTLK in Java world ?
0
1
0
0
0
0
I need to implement some NLP in my current module. I am looking for some good library that can help me here. I came across 'LingPipe' but could not completely follow on how to use it. Basically, we need to implement a feature where the application can decipher customer instructions (delivery instructions) typed in plain english. Eg: Will pick up at 12:00 noon tomorrow Request delivery after 10th June Please do not send before Wednesday Add 10 more units of XYZ to the order
0
1
0
0
0
0
There is a new Open Source poker bot called PokerPirate. I am interested in any creative ways in which a web application could detect/thwart/defeat a poker bot. (This is a purely academic discussion, in the same spirit that PokerPirate was written.)
0
1
0
0
0
0
I don't know very well about RAM and HDD architecture, or how electronics deals with chunks of memory, but this always triggered my curiosity: Why did we choose to stop at 8 bits for the smallest element in a computer value ? My question may look very dumb, because the answer are obvious, but I'm not very sure... Is it because 2^3 allows it to fit perfectly when addressing memory ? Are electronics especially designed to store chunk of 8 bits ? If yes, why not use wider words ? It is because it divides 32, 64 and 128, so that processor words can be be given several of those words ? Is it just convenient to have 256 value for such a tiny space ? What do you think ? My question is a little too metaphysical, but I want to make sure it's just an historical reason and not a technological or mathematical reason. For the anecdote, I was also thinking about the ASCII standard, in which most of the first characters are useless with stuff like UTF-8, I'm also trying to think about some tinier and faster character encoding...
0
0
0
0
1
0
I am looking for a graduation project idea in AI and machine learning field... The idea may require front-end user interface to attract users... I am thinking of how AI and machine learning can help you in daily life..? Any help/hint about new interesting ideas ? Thanks Edit: I am talking about practical ideas that may be used in real life... Not an idea to prove theoretical things... Something like a OS (or an add on in existing one) that adapt with your way of work... or a word processor that helps you collecting information about what you are writing..
0
1
0
1
0
0
Possible Duplicate: Is JavaScript’s Math broken? Why does JS screw up this simple math? console.log(.1 + .2) // 0.3000000000000004 console.log(.3 + .6) // 0.8999999999999999 The first example is greater than the correct result, while the second is less. ???!! How do you fix this? Do you have to always convert decimals into integers before performing operations? Do I only have to worry about adding (* and / don't appear to have the same problem in my tests)? I've looked in a lot of places for answers. Some tutorials (like shopping cart forms) pretend the problem doesn't exist and just add values together. Gurus provide complex routines for various math functions or mention JS "does a poor job" in passing, but I have yet to see an explanation.
0
0
0
0
1
0
Im trying to find out the angle (in degrees) between two 2D vectors. I know I need to use trig but I'm not too good with it. This is what I'm trying to work out (the Y axis increases downward): I'm trying to use this code at the moment, but it's not working at all (calculates random angles for some reason): private float calcAngle(float x, float y, float x1, float y1) { float _angle = (float)Math.toDegrees(Math.atan2(Math.abs(x1-x), Math.abs(y1-y))); Log.d("Angle","Angle: "+_angle+" x: "+x+" y: "+y+" x1: "+x1+" y1: "+y1); return _angle; } These are my results (There constant when providing a constant position, but when I change the position, the angle changes and I can't find any link between the two angles): Position 1: x:100 y:100 x1:50 y1:50 Angle: 45 Position 2: x:92 y:85 x1:24 y1:16 Angle: 44.58 Position 3: x:44 y: 16 x1:106 y1:132 Angle: 28.12 Edit: Thanks everyone who answered and helped me figure out that was wrong! Sorry the title and the question was confusing.
0
0
0
0
1
0
Possible Duplicate: Programming Logic: Finding the smallest equation to a large number. I'm looking for an algorithm that will take an arbitrary number from the Aleph-Null set (all positive integers)(likely to be absolutely enormous) and attempt to simplify it into a computable number (if the computable number takes up less space than the integer value it is trying to represent)(specifically not floating point). Involving tetration/hyperoperators would be optimal. Does anyone know if anything like this exists? I've looked around quite a bit this morning, but have been unable to find anything. C# code would be optimal, but really, it could be in any language Edit: Programming Logic: Finding the smallest equation to a large number : http://mrob.com/pub/ries/index.html looks promising, but I wonder how well it will deal with large numbers, and if it's capable of implementing hyperoperators. I'll try it out.
0
0
0
0
1
0
I was wondering what kind of model / method / technique Trendly might use to achieve this model: [It tries to find the moments where significant changes set in and ignores random movements] Any pointers very welcome! :)
0
0
0
0
1
0
assuming that I know nothing about everything and that I'm starting in programming TODAY what do you say would be necessary for me to learn in order to start working with Natural Language Processing? I've been struggling with some string parsing methods but so far it is just annoying me and making me create ugly code. I'm looking for some fresh new ideas on how to create a Remember The Milk API like to parse user's input in order to provide an input form for fast data entry that are not based on fields but in simple one line phrases instead. EDIT: RTM is todo list system. So in order to enter a task you don't need to type in each field to fill values (task name, due date, location, etc). You can simply type in a phrase like "Dentist appointment monday at 2PM in WhateverPlace" and it will parse it and fill all fields for you. I don't have any kind of technical constraints since it's going to be a personal project but I'm more familiar with .NET world. Actually, I'm not sure this is a matter of language but if it's necessary I'm more than willing to learn a new language to do it. My project is related to personal finances so the phrases are more like "Spent 10USD on Coffee last night with my girlfriend" and it would fill location, amount of $$$, tags and other stuff. Thanks a lot for any kind of directions that you might give me!
0
1
0
0
0
0
I have a large list of files, some of which have dates embedded in the filename. The format of the dates is inconsistent and often incomplete, e.g. "Aug06", "Aug2006", "August 2006", "08-06", "01-08-06", "2006", "011004" etc. In addition to that, some filenames have unrelated numbers that look somewhat like dates, e.g. "20202010". In short, the dates are normally incomplete, sometimes not there, are inconsistently formatted and are embedded in a string with other information, e.g. "Report Aug06.xls". Are there any Perl modules available which will do a decent job of guessing the date from such a string? It doesn't have to be 100% correct, as it will be verified by a human manually, but I'm trying to make things as easy as possible for that person and there are thousands of entries to check :)
0
1
0
0
0
0
I've adapted this from an example that I found on the 'net... function ratio($a, $b) { $_a = $a; $_b = $b; while ($_b != 0) { $remainder = $_a % $_b; $_a = $_b; $_b = $remainder; } $gcd = abs($_a); return ($a / $gcd) . ':' . ($b / $gcd); } echo ratio(9, 3); // 3:1 Now I want it to use func_get_args() and return the ratios for multiple numbers. It looks like a recursive problem, and recursion freaks me out (especially when my solutions infinitely loop)! How would I modify this to take as many parameters as I wanted? Thanks
0
0
0
0
1
0
This is about how to do number conversion between binary to octal, octal to hexadecimal, binary to hexadecimal.. ( in all these decimal is no where there, either in source or destination ) Whenever decimal is involved either in source or destination i have a general methodology as, if decimal is source, do the mod operation of that number with the base of destination. ( and continue the same way, and get the result ), Example: convert decimal 20 to octal 20 mod 8 = 4 2 = 2 So it is 24 in Octal. This way you can do for anything ( binary, hex ) from Decimal. if decimal is destination, do the multiplication operation with the source's base from 0 to N which starts from left to right. And add up to get the decimal. Example: convert binary 1010 to decimal 0 : 0 x 2**0 = 0 1 : 1 x 2**1 = 2 0 : 0 x 2**2 = 0 1: 1 x 2**3 = 8 The sum is 10 in Decimal. This way you can do for anything ( octal, hex ) to decimal. Questions Is there any similar general logic, which i can use for conversion between octal, hex and binary ? Hope the above is clear.. Else let me know.
0
0
0
0
1
0
I've got a line (x1,y1) and (x2,y2). I'd like to use tan inverse to find the angle of that line, how would I do so in java? I'd like to see what angle the line makes in relation to x1,y1
0
0
0
0
1
0
Possible Duplicate: John Carmack’s Unusual Fast Inverse Square Root (Quake III) I came across this piece of code a blog recently - it is from the Quake3 Engine. It is meant to calculate the inverse square root fast using the Newton-Rhapson method. float InvSqrt (float x){ float xhalf = 0.5f*x; int i = *(int*)&x; i = 0x5f3759df - (i>>1); x = *(float*)&i; x = x*(1.5f - xhalf*x*x); return x; } What is the reason for doing int i = *(int*)&x;? Doing int i = (int) x; instead gives a completely different result.
0
0
0
0
1
0
I was wondering if there was any tutorial that introduces 3D Graphics theory while showing relevant code, without using OpenGL or DirectX or something. I'm very comfortable with engineering math (I'm an A/V DSP student, so I work with a lot of math all the time). Most of the tutorials I see either show me the same old matrix translation/rotation examples, along with a discussion on projections and show me using similar triangles how projections work or assume you know everything about 3D or just use a bunch of OpenGL primitives. I've ordered a book (Interactive Computer Graphics: A Top-Down Approach) on the topic but I'd like to get started right now. I'd really like something that just worked with an SDL surface or a Java Graphics2D object and just used matrix math to render everything. I was hoping to be able to do some simple stuff, like rendering some simple shapes before the book arrived. Ideally something that introduced topics and gave coded examples on how they worked. EDIT: All the answers were great, but I just loved the code. Exactly what I was looking for, even if it was in Pascal ;)
0
0
0
0
1
0
I was wondering, is it possible to use Artificial Intelligence to make compilers better? Things I could imagine if it was possible - More specific error messages Improving compiler optimizations, so the compiler could actually understand what you're trying to do, and do it better If it is possible, are there any research projects on this subject?
0
1
0
0
0
0
Can anyone all the different techniques used in face detection? Techniques like neural networks, support vector machines, eigenfaces, etc. What others are there?
0
1
0
0
0
0
For the implementation of single layer neural network, I have two data files. In: 0.832 64.643 0.818 78.843 Out: 0 0 1 0 0 1 The above is the format of 2 data files. The target output is "1" for a particular class that the corresponding input belongs to and "0" for the remaining 2 outputs. The problem is as follows: Your single layer neural network will find A (3 by 2 matrix) and b (3 by 1 vector) in Y = A*X + b where Y is [C1, C2, C3]' and X is [x1, x2]'. To solve the problem above with a neural network, we can re-write the equation as follow: Y = A' * X' where A' = [A b] (3 by 3 matrix) and X' is [x1, x2, 1]' Now you can use a neural network with three input nodes (one for x1, x2, and 1 respectively) and three outputs (C1, C2, C3). The resulting 9 (since we have 9 connections between 3 inputs and 3 outputs) weights will be equivalent to elements of A' matrix. Basicaly, I am trying to do something like this, but it is not working: function neuralNetwork load X_Q2.data load T_Q2.data x = X_Q2(:,1); y = X_Q2(:,2); learningrate = 0.2; max_iteration = 50; % initialize parameters count = length(x); weights = rand(1,3); % creates a 1-by-3 array with random weights globalerror = 0; iter = 0; while globalerror ~= 0 && iter <= max_iteration iter = iter + 1; globalerror = 0; for p = 1:count output = calculateOutput(weights,x(p),y(p)); localerror = T_Q2(p) - output weights(1)= weights(1) + learningrate *localerror*x(p); weights(2)= weights(1) + learningrate *localerror*y(p); weights(3)= weights(1) + learningrate *localerror; globalerror = globalerror + (localerror*localerror); end end I write this function in some other file and calling it in my previous code. function result = calculateOutput (weights, x, y) s = x * weights(1) + y * weights(2) + weights(3); if s >= 0 result = 1; else result = -1; end
0
1
0
0
0
0
I save 100.000 Vectors of in a database. Each vector has a dimension 60. (int vector[60]) Then I take one and want present vectors to the user in order of decreasing similarity to the chosen one. I use Tanimoto Classifier to compare 2 vectors: Is there any methods to avoid doing through all entries in the database? One more thing! I don't need to sort all vectors in the database. I whant to get top 20 the most similar vectors. So maybe we can roughly threshold 60% of entries and use the rest for sorting. What do you think?
0
0
0
0
1
0
I am looking for an efficient way to check if an object will cut a corner to get from point A to point B or prevent the object from moving from point A to point B if there is a diagonal unwalkable position in between. What is known: Every point is a square of width and height 1 Every point has a list of its 8 adjacent points A point can be either walkable or nonwalkable Here are some examples (a is the source, b is the desination and X is an unwalkable point): aX b In the above case, a cannot walk to be because there is an unwalkable point adjacent to both point a and point b...therefore, for this current case, b becomes unwalkable from a (ie, a has to move downwards before proceeding to b) The following is a similar case, in the sense that a cannot walk to b: aX Xb The way I am doing it at the moment is getting the set of orthogonally adjacent points of both point A and point B and intersecting these two sets. If there are no elements in the intersected result, then point A can walk to point B. ...and it works. But is there a, maybe, more mathematical and efficient way of achieving this?
0
0
0
0
1
0
Firstly, this is AI for PacMan and not the ghosts. I am writing an Android live wallpaper which plays PacMan around your icons. While it supports user suggestions via screen touches, the majority of the game will be played by an AI. I am 99% done with all of the programming for the game but the AI for PacMan himself is still extremely weak. I'm looking for help in developing a good AI for determining PacMan's next direction of travel. My initial plan was this: Initialize a score counter for each direction with a value of zero. Start at the current position and use a BFS to traverse outward in the four possible initial directions by adding them to the queue. Pop an element off of the queue, ensure it hasn't been already "seen", ensure it is a valid board position, and add to the corresponding initial directions score a value for the current cell based on: Has a dot: plus 10 Has a power up: plus 50 Has a fruit: plus fruit value (varies by level) Has a ghost travelling toward PacMan: subtract 200 Has a ghost travelling away from PacMan: do nothing Has a ghost travelling perpendicular: subtract 50 Multiply the cell's value times a pecentage based on the number of steps to the cell, the more steps from the initial direction, the closer the value of the cell gets to zero. and enqueue the three possible directions from the current cell. Once the queue is empty, find the highest score for each of the four possible initial directions and choose that. It sounded good to me on paper but the ghosts surround PacMan extremely rapidly and he twitches back and forth in the same two or three cells until one reaches him. Adjusting the values for the ghost presence doesn't help either. My nearest dot BFS can at least get to level 2 or 3 before the game ends. I'm looking for code, thoughts, and/or links to resources for developing a proper AI--preferably the former two. I'd like to release this on the Market sometime this weekend so I'm in a bit of a hurry. Any help is greatly appreciated. FYI, this was manually cross-posted on GameDev.StackExchange
0
1
0
0
0
0
I am calculating a formula and would like to know how to write exp(a/b) in C#. I heard about math.exp, but it takes only one parameter.
0
0
0
0
1
0
There is a container, for example lets say which has a volume of "V". The container needs to be filled with various types of boxes, where each type has a unique size (volume), for example lets say Box Type A - has a volume of K Box Type B - has a volume of L Now the problem is that there is a requirement to find out whats the maximum number of boxes of both types which could be fit into the container (combination of both boxes) To simplify lets say that "W" and "R" are quantities, then we get (K * W) + (L * R) = V AND how the cartons(boxes) should be stacked up in the container. For example the first row (by row I mean when the boxes are laid x co-ordinate wise) of boxes in the container should contain 4 stacks (starting from the floor of the container) of "Box Type A" and the topmost two stacks (nearing the top ceiling of the container) with "Box Type B" (By stacks I mean when the boxes are laid on top of each other [z co-ordinate wise]).Thereafter a new row is laid after the previous one is complete till the whole container is full. The problem is what is the best way to layout these boxes in the container as to utilize all (or most) of the space in the container, and pack in the maximum possible number of boxes which can be a combination of 1 or more (max around 5 type of boxes in one container). The program should simply take the inputs of the types and details of the boxes, the container and voilà you get a full detailed analysis. The problem is that I have not touched the area of machine learning or solving this kind of problem. I would appreciate if I was given advice on as what algorithm/s to use, where to start learning to solving this problem and such, whats the best way to approach this, any helpful machine learning libraries to use, etc.
0
0
0
1
1
0
I am capturing some points on an X, Y plane to represent some values. I ask the user to select a few points and I want the system to then generate a curve following the trend that the user creates. How do I calculate this? So say it is this: Y = dollar amount X = unit count user input: (2500, 200), (4500, 500), (9500, 1000) Is there a way I can calculate some sort of curve to follow those points so I would know based off that selection what Y = 100 would be on the same scale/trend? EDIT: People keep asking for the nature of the curve, yes logarithmic. But I'd also like to check out some other options. It's for pricing the the restraint is that the as X increases Y should always be higher. However the rate of change of the curve should change related to the two adjacent points that the user selected, we could probably require a certain number of points. Does that help? EDIT: Math is hard. EDIT: Maybe a parabola then?
0
0
0
0
1
0
How do you dereference a slot in a fact matched in the LHS of a rule? If a variable matches a fact, I can't find how to create further conditions that match slots within that fact. For example, in the code below, I want to print some text if there's a fact of the form "(do (action ?action))". However, ?action is itself a fact, and I only want the rule to trigger if that fact's "name" slot is "run". How would I accomplish this? (deftemplate do (slot action) ) (deftemplate action (slot name) ) (defrule find-do "" ?do <- (do (action ?action)) (test (eq ?action.name "run")) ; This causes a syntax error. => (printout t "doing " ?action crlf) ) (deffacts startup (do (action (action (name "running")))))
0
0
0
1
0
0
Recently there has been a paper floating around by Vinay Deolalikar at HP Labs which claims to have proved that P != NP. Could someone explain how this proof works for us less mathematically inclined people?
0
0
0
0
1
0
I have recently visted the GMail Blog, and found the extreme point of logic building inside software, i.e. Never forget an attachment again Gmail looks for phrases in your email that suggest you meant to attach a file (things like "I've attached" or "see attachment") and warns you if it looks like you forgot to do so. Every day, this saves tons of people the embarrassment of having to send a follow up email with the file actually attached. (source: blogspot.com) I think this is too much... Please share your expreience about the extreme point of logic building inside software/application.
0
1
0
0
0
0
I'm thinking about writing a little library to make a guess at the name of an (RGB value) colour, from a predetermined list of candidates. My first attempt was based purely on pythagorean distance within the three-dimensional RGB colour space - this wasn't massively succesful as most of the named colour points were at the edges of the space (eg Blue at 0, 0, 255), so, for most colours in the middle of the space, the named colour that it was closest too was fairly arbitrary. So, I'm thinking about better approaches and have come up with a few candidates Cylindrical distance within an HSV colourspace - which may well have similar problems to the above, however, HSV seems to be more meaningful in a human sort of sense than RGB, which could be useful. Either of the above, but with each named colour point being weighted with an arbitrary value that denotes the strength of its attraction to points in the surrounding space. is there a name for such a model? I realise this is a bit vague, but it seems like a fairly intuitive idea to me. A Bayesian network that examines properties of an HSV colour and returns the most likely colour name (I'm imagining nodes similar to, for instance P(Black | Saturation < 10), P(Red | Hue = 0), However, this seems less than ideal - for instance, the probability that a given colour is red is proportional to how close its hue is to 0, rather than being a discrete value. Is there a way of adapting bayesian networks to deal with probabilities that are continuous on the variable being tested? Finally, I was wondering if some sort of Support Vector Machine-based classification within either the HSV or RGB colour space, but not being massively familiar with these, I'm unsure whether this will offer any particular advantage over the pythagorean distance based approach I tried originally, especially as I'm only dealing with a three dimensional space. Therefore, I was wondering, do any of you have any experience with similar problems, or know of any resources that might be able to help me to decide on an approach? If anyone could point me in the right direction (whether it's one of the above, or something entirely different) I'd be extremely grateful. Cheers! Tim
0
1
0
0
0
0
I am looking for a fast way to perform the following divison: Dividend is a signed 64 bit integer. Divisor is a signed 32 bit integer. Quotient should be a signed 64 bit integer, remainder is unnecessary. Low dword of the dividend is zero. I am using only 32 bit data types, since 64 bit ones are poorly supported by the compiler, and no assembly. Accuracy can be somewhat compromised in favor of speed. Any pointers on this one?
0
0
0
0
1
0
I would like to create a function floor(number, step), which acts like : floor(0, 1) = 0 floor(1, 1) = 1 floor(1, 2) = 0 floor(5, 2) = 4 floor(.8, .25) = .75 What is the better way to do something like that ? Thanks.
0
0
0
0
1
0
The problem is straight forward: 1) We have a photon traveling from Point 1 (x,y,z) to Point 2 (x,y,z), both of which could be located anywhere in 3D space. 2) We have a polygon that is both rotated randomly on the x-axis and/or y-axis and also located anywhere in 3D space. 3) We want to find: a) if the photon will collide with the polygon at all and b) if it does where will that be (x,y,z)? An image of the problem: http://dl.dropbox.com/u/3150177/Programming/3D/Math/Photon%20Path/Photon%20Path.png The aim of this is to calculate how the photon's path should be altered from an interaction(s) with the polygon(s). I am reading up on this subject now but I was wondering if anyone could give me a head start. Thanks in advance.
0
0
0
0
1
0
I have a math problem which is written like this: x^1+x^2+x^3+...+x^n Are there any constructs in C# that will help me solve these kinds of equations? I know I could write a for loop or use recursion to accomplish this, but I remember reading about some construct in c# that will pre-compile such a statement for later execution. Are there any interesting ways to solve these kinds of equations?
0
0
0
0
1
0
Has anyone used the photo filter in Photoshop? Edit > Adjustments > Photo Filter... It produces a really nice image tint that I've been unable to reproduce with blending modes. Has anyone got any idea of the pixel maths behind this filter? - So I can build a shader based on it. It seems to basically be a luminosity preserving colour tint. Has variables: Color, Amount and Preserve Luminosity. Any ideas?
0
0
0
0
1
0
And can you give me an example of an algorithm? alt text http://ryancalderoni.com/archive/ideal_curve.jpg EDIT: And then how would I calculate the math using Javascript? Can someone add that? Sorry to not include that context originally.. NOTE: I am using 'flot' to graph it and the input for flot is a javascript array like this: [[x,y],[x,y],[x,y]...] So given the values that change the curve I output all the points to an array with a loop and spit it out to flot to graph.
0
0
0
0
1
0
Suppose I want to randomly select a number n between 0 and 30, where the distribution is arbitrary, and not uniform. Each number has a corresponding weight P(n): P(0) = 5, P(1) = 1, P(2) = 30, P(3) = 25, and so on and so forth. How do I do a random selection from this set, such that the probability of selecting a number is proportional to its weight? What is this type of random selection even called? I can see one way of implementing it: Make a lookup table V where V(n) = V(n-1) + P(n); with base case V(0) = P(0). Generate a random number X with a uniform distribution between 0 and the maximum value of V. Find the smallest value of n such that V(n) > X. Is something like this already implemented in a library? (Using Perl.)
0
0
0
0
1
0
I've been able to solve the following problem using std::next_permutation (c++) etc, but I'm now thinking about it in a more general and would very much like to form an expression as this type of problem seems to lend itself - though I'm not having any luck as of yet. Here is the question: Given a running race with N contestants, what is the probability that exactly M contestants will finish in a position that is the same as the number on their shirt. Where M <= N. What I've done so far: There will be N! ways the race can end, I've tried fiddling with a small variant of the problem consisting of either 3 or 4 contestants with the required number of people meeting the condition as being 2. in both cases for 2 people finishing in the particular order the probability is 1/2 I'd like to know if there's already some kind of expression that handles all the cases? Some code: #include <cstdio> #include <algorithm> #include <vector> int main(int argc, char* argv[]) { if (argc != 3) return 1; int n = atoi(argv[1]); int m = atoi(argv[2]); if (m > n) return 1; std::vector<int> lst(n); for (int i = 0; i < n; ++i) lst[i] = i; unsigned int total = 0; unsigned int perm_count = 0; do { int cnt = 0; for (int i = 0; i < n; ++i) if (lst[i] == i) ++cnt; if (cnt == m) ++total; ++perm_count; } while (std::next_permutation(lst.begin(),lst.end())); printf("Probability of (%d,%d) = %8.7f ",n,m,(1.0 * total / perm_count)); return 0; } Update: The expression is called a Partial Derangement: http://mathworld.wolfram.com/PartialDerangement.html Note1: The formula is correct, if one assumes that the fully ordered permutation does not count. Note2: I've changed the question slightly to make it more clear, hence also changed to code - this should reconsile with comments made by ShreevatsaR.
0
0
0
0
1
0
I am attempting to use output from an accelerometer moving back and forth on a single axis to calculate its current position. I have tried using Euler integrations, but the velocity and position errors become too large too quickly. After some reading, I am wondering whether RK4 could be applied to this problem to minimise the error? Cheers, A.
0
0
0
0
1
0
I'm trying to understand the math on this raphael.js demo: http://raphaeljs.com/pie.js Checkout the sector method: function sector(cx, cy, r, startAngle, endAngle, params) { var x1 = cx + r * Math.cos(-startAngle * rad), x2 = cx + r * Math.cos(-endAngle * rad), y1 = cy + r * Math.sin(-startAngle * rad), y2 = cy + r * Math.sin(-endAngle * rad); return paper.path(["M", cx, cy, "L", x1, y1, "A", r, r, 0, +(endAngle - startAngle > 180), 0, x2, y2, "z"]).attr(params); } This is the actual demo: http://raphaeljs.com/pie.html My math is a little rusty and I'm trying to understand the sector function - given the startAngle and endAngle parameters (each start and end point values between 0 and 360 drawing an arc), why does this function work?
0
0
0
0
1
0
I got angle in degree as -415 degrees, i have converted it into radian as float degreeValue = -415 float radianValue = degreeValue * pi / 180.0; here i got as -0.7(round off) how to convert again into degree to get same value of angle in degrees.
0
0
0
0
1
0
We've all seen that stores have nice-looking pricing on their products; "1.99", "209.90" and so on. That's easily done as well if you enter prices manually, but l et's say that we would have a database which stores prices, that are daily updated according to currency changes. Prices are therefore automatically calculated and will end up looking like "1547,83" which isn't nice at all for the eyes. How could a function be made in PHP that both rounds prices and adjust them to be "presentable" within set tolerances depending on the size of the prize? Thanks a lot!
0
0
0
0
1
0
what's the most elegant way of rounding a float to it's closest 1/4ths in Objective C? For example: 3.14 should be 3.25 2.72 should be 2.75 6.62 should be 6.50 1.99 should be 2.00 etc.
0
0
0
0
1
0
I'm reading a chapter in this fascinating book about using genetic programming to interactively evolve images. Most of the function set is comprised of simple arithmetic and trig functions (which really operation on and return images). These functions make up the internal nodes of the parse trees that encode our images. The leaves of the tree, or the terminal values, are random numbers and x,y coordinates. There's a section about adding iterative functions of the complex plane to the function set: Say the genetics inserts a particular Mandelbrot set as a node somewhere in a bushy tree. The function expects two arguments: mandel(cReal, cImag), treating them as real and imaginary coordinates in the complex plane. If the genome just happened to supply the pixel coordinates (x,y), and mandel() were the root node, you would get the familiar Mset. But chances are that cReal and cImag are themselves the results of whole branches of functions, with many instances of coordinates x,y scattered out among the leaves. Enter the iteration loop, orbit around for a while, and finally escape with some measure of distance to the Mset attractor, such as the number of iterations. My question is how would you make a Mandelbrot set renderer as a function that takes the real and imaginary coordinates of a point on the complex plane as arguments and returns a rendering of the Mandelbrot set?
0
1
0
0
0
0
As far as I known, there are are numpy and scipy for python. Are there similar libs for F#? Thanks.
0
0
0
0
1
0
in c#, at least, generating a new guid is a one line one call process. A guid is easy to use and format, and it "guarantees" uniqueness. However, is it irresponsible to just go off and generate new guids for every little thing. Could we be significantly increasing the chances of a "ta tan tan" guid collision?! thoughts...?
0
0
0
0
1
0
I decided to go with a Neural Network in order to create behaviors for an animation engine that I have. The neural network takes in 3 vector3s and 1 Euler angle for every body part that I have. The first vector3 is the position, the second is its velocity, and the third is its angular velocity. The Euler angle is what rotation the body part is at. and I have 7 body parts. Each one of those data types has 3 floats. 7*4*3 = 84, so I have 84 inputs for my neural network. The outputs are mapped to the muscles of the character. They provide the amount of strength to apply to each muscle, and there are 15 of them. I am running 15 networks simultaneously for 10 seconds, rating their fitness by calculating the lowest energy use, having the least amount of z and x movement, and if the body parts are in the correct y position compared to the rest (hips.y > upperleg.y, upperleg.y > lowerleg.y etc.), and then running them through a genetic algorithm. I was running a neural network of 168 neurons per hidden layer, with 8 hidden layers. I'm trying to get the character to stand up straight and not move around too much. I ran this for 3000 generations and I didn't even come close. The neural network and genetic algorithm are C# versions of this tutorial. I changed the crossover method from one point to blending. I have 84 inputs and 15 outputs. How large should my Neural Network be?
0
0
0
1
0
0
How to get the co-ordinates of the outline shape formed using smaller grid blocks. For example, If I used 32x32 unit blocks for construct a shape (any shape). Then how can I get overall co-ordinates of the shape, including the negative spaces. For example: One could arrange the blocks like this: (each block is 32x32 and coordinates refer to bottom left corner of the block) Block 1 - (0,0) BLock 2 - (32,0) Block 3 - 64,0) Block 4 - (64,32) Block 5 - (64, 64) BLock 6 - (32, 64) BLock 6 - (0 64) Block 7 - (0, 32) Now you can see this will create an empty space in the middle. So what I would like to know is, how to get the coordinates of the above shape such that I get: Main Block = (0,0), (96,0), (0,96) Empty space = (32,32), (64,32), (64,64), (32,64) Is there any mathematical solution to this? Eventually I will be doing complex shapes. thanks ******** edit **** Hi, How to deal with this condition? <------------------^<----^ | || | V------------------>| | <------^ /^| | | |<------^ / || | | || |/ || | V------>V------>V-->V----> i would like the result to be like this <-------------------<----^ | | V ^-----------> | | | / | | <-------^ / | | |/ | V------>------->--->----->
0
0
0
0
1
0
My application allows rotating points around a center based on the mouse position. I'm basically rotating points around another point like this: void CGlEngineFunctions::RotateAroundPointRad( const POINTFLOAT &center, const POINTFLOAT &in, POINTFLOAT &out, float angle ) { //x' = cos(theta)*x - sin(theta)*y //y' = sin(theta)*x + cos(theta)*y POINTFLOAT subtr; subtr.x = in.x - center.x; subtr.y = in.y - center.y; out.x = cos(angle)*subtr.x - sin(angle)*subtr.y; out.y = sin(angle)*subtr.x + cos(angle)*subtr.y; out.x += center.x; out.y += center.y; } where POINTFLOAT is simply struct POINTFLOAT { float x; float y; } The issue is that the points need to be updated on mousemove. I am looking for a way to do this without doing the following: Store original points Rotate Original points Copy result Show Result Rotate Original points Copy result Show Result.... I feel storing the originals seems messy and uses extra memory. Is there a way, knowing the previous rotation angle and the current one that I can somehow avoid applying the transformation to the original points all the time and just build upon the points i'm modifying? *the center will never change until mouse up so thats not an issue Thanks
0
0
0
0
1
0
I'm trying to use the follow code to produce a decimal number, but the evaluation of l divided by h (low by high) always comes out to be 0. How can I correct this? Thanks! EditText marketValLow = (EditText) findViewById(R.id.marketValLow); EditText marketValHigh = (EditText) findViewById(R.id.marketValHigh); String valLow = marketValLow.getText().toString(); String valHigh = marketValHigh.getText().toString(); int l = Integer.parseInt(valLow); int h = Integer.parseInt(valHigh); if (valLow.trim().equals("") || valHigh.trim().equals("")) { Toast.makeText(CurrentMarketValue.this, "You need to enter a high AND low." + valLowIndex, Toast.LENGTH_SHORT).show(); } else if ((l / h) < .9) { Toast.makeText(CurrentMarketValue.this, "The range between your value cannot be more than 10%." + (l / h), Toast.LENGTH_SHORT).show(); }
0
0
0
0
1
0
I have comments enabled on my site and I require users to enter at least 30 characters to publish their comments (Just to get some value because they usualy just submitted "I like it") But some users now use simple technique to overcome this and enter e.g.: "I like it. asdsdf dfdsfsdf tt erretrt re" As you can see the rest of the text is nonsense. Is there a way (algorithm) how to filter these comments out in PHP ?
0
1
0
0
0
0
I'm looking for a formula to convert them. I know to convert a general transparency it is alpha * new + ( 1 - alpha ) * old I have: Color A : RGB( 85, 113, 135 ) Color B : RGB( 43, 169, 225 ) Color A has 90% opacity and is laid on top of Color B, resulting in Color C : RGB( 65, 119, 145 ) My question is, how does it get Color C? If I substitute Color B for another thing, how do I get Color C? Here's another example, same base color: Color A : RGB( 85, 113, 135 ) Color B : RGB( 45, 67, 82 ) -------- Color C : RGB( 65, 109, 131 ) Those are working examples done with images -- I'm trying to now calculate the remaining Color C so I can assign a background color. UPDATE, please see the accepted answer. The red in the above examples is strange -- the accepted answer has the correct formula for all the colors, I tested it in Photoshop.
0
0
0
0
1
0
Im a final year university student who is doing a license plate recognition system as my final year project. I want to know when recognizing the characters what suits the best, is it artificial nurel networks(ANN) or optical character recognition(OCR) using pattern matching? Or is there any easy method I can use? All the answered welcomed. Thanks a lot
0
1
0
0
0
0
Is there a way to decompose complex sentences into simple sentences in nltk or other natural language processing libraries? For example: The park is so wonderful when the sun is setting and a cool breeze is blowing ==> The sun is setting. a cool breeze is blowing. The park is so wonderful.
0
1
0
0
0
0
As a pet project/learning experience (no this is not homework) I'm working on software to recognize barcodes from a photograph. I'm not looking for software or a library that does it - instead I'm using this as a learning exercise that I'm blogging about and will post up on Codeplex. I have code that successfully recognizes EAN13 barcodes (which I published on CodePlex) and UPC version A/E should follow shortly. I have two areas that I'm concerned about, though. First is in decoding barcodes that are in a picture that is bit blurry or with poor contrast, etc. Second is in simply finding the actual barcode in a larger picture (right now you have to give me a photo of just the barcode). I have the gut feeling that some form of AI is going to help me out here. I played a bit in the past with genetic algorithms and I took a course ages ago on AI so it's not totally foreign to me, but I'm not quite sure where to start. What type of algorithm is best suited to this type of problem? Any recommended reading or code for the AI grunt work? Yes, I want to understand what's happening, but I don't necessarily want to go down to the level of coding the sorts, etc myself.
0
1
0
0
0
0
I need an algorithm to convert a closed bezier curve (perhaps self-crossing) to a binary bitmap: 0 for inside pixels and 1 for outside. I'm writing a code that needs to implement some operations on bezier curves, could anybody give me some resources or tutorials about beziere? Wikipedia and others didn't say anything about optimization, subtracting, union, knot insertion and deletion and other operations :-) alt text http://www.imagechicken.com/uploads/1271001073057545100.jpg
0
0
0
0
1
0
Did anybody port the C source code of StricMath.exp (OpenJDK) to Java and made it available online? I mean the port of http://hg.openjdk.java.net/jdk6/jdk6/jdk/file/7b641a18cf0b/src/share/native/java/lang/fdlibm/src/e_exp.c
0
0
0
0
1
0
I need to create a simple formula for determining the popularity of an item based on votes and age. Here is my current formula, which needs some work: 30 / (days between post date and now) * (vote count) = weighted vote Whenever a vost is cast for an item it checks if its weighted vote is > 300. If an item has a weighted vote more than 300 then it is promoted to the front page. The problem is that this formula makes it very hard for older items to be promoted. 30 / 1 day * 10 votes = 300 (promoted) 30 / 5 days * 15 votes = 90 (not promoted) 30 / 30 days * 30 votes = 30 (not promoted) 30 / 80 days * 40 votes = 15 (not promoted) How can I alter the formula to make it relatively easier for older items to be promoted (IE. make the above four weighted values fairly close together)?
0
0
0
0
1
0
Here is an example of the type of data that I am trying to manipulate: 1213954013615]: 992 1213954013615]: 993 1213954013615]: 994 1213954013615]: 995 1213954013615]: 995 1213954013615]: 996 1213954013615]: 996 1213954013615]: 996 1213954013615]: 998 1213954247424]: 100 1213954247424]: 1002 1213954247424]: 1007 1213954303390]: 111 1213954303390]: 1110 1213954303390]: 1111 1213954303390]: 1112 1213954303390]: 1114 1213954303390]: 112 1213954303390]: 112 1213954303390]: 112 1213954303390]: 112 ...What I am hoping to achieve is to generate an average based on the epoch number on the left. For example, adding 992, 993, 994, 995, 995, 996, 996, 996, 998 and dividing by the number of unique instances of the epoch time "1213954013615", doing this for each unique group of epoch times. Here is what I have so far: awk '{arr[$1]+=$2} END {for (i in arr) {print "[epoch", i,arr[i]/NR}}' But this, of course, divides by the total number of epoch times, I need something equivalent to "uniq" for this, but can't find an equivalent in awk. Many thanks.
0
0
0
0
1
0
I have read some tutorials for bezier curve such as this one http://www.codeproject.com/KB/recipes/BezirCurves.aspx. The basic idea to create bezier curve is to use some control points and make decision how many new points need to be created. And then interpolate those new points. Here is the question: Assume I have 1000 points and I would like to interpolate 2000 points more. The number of control points I want to use is 5. The parameter t is in the range of [0, 1]. Givens points P0, P1, P2, P3, P4, P5, P6, ...P1000. I can use P0-P4 to generate new points, then what's next? use P5-P9 to generate new points??? I can immediately see there is a sudden transform between P4 and P5. How can I solve this issue? Thank you ///////////////////////////////////////////////////// Hello Stargazer712, I understand your comments until it reaches the implementation method. Assume we have the following points: A1->A2->A3->A4->A5->A6->A7->A8 initial points You said that we need to add a new point at the midpoint of every other pair. My question is what the order of the new point is? Let use use this annotation (A1+A3)/2 == A12 Now generated new points are A13 A24 A35 A46 A57 A68 (this is what you mean "every other pair"? Where should I insert those points into the original list? The contour I am working on is extracted from binary image. The generated contour is zig-zag shape. After I apply this smooth method, it shape doesn't improve too much. I think the major reason is that the neighbors are near each other and make the interpolation not that useful. Thank you ////////////////////////////////////////////////////
0
0
0
0
1
0
Are there any tutorials on how to calculate 'outcomes' for events in a game, based on inputs like character strength, weapers, etc. Also, how do you go about making things progresively harder and challenging. I'm not looking for math for things like graphic rendering, visual objects moving around etc. This is for figuring out if e.g. a character beat the 'bad guy' based on characteristics of the character like strength, level, training, weaponar, etc. Hope this makes sense.
0
0
0
0
1
0
I found a great c# example that colors cells in different shades of orange based on the how large or small the value is: http://demos.devexpress.com/ASPxTreeListDemos/Appearance/ConditionalFormatting.aspx The problem is that it expects the numbers to be very large for it to work. Is there a way using a math formula that I could specify the largest and smallest number (or all numbers if needed) and have it calculate the shade of orange that way. Here is the specific code from the link above: protected void treeList_HtmlDataCellPrepared(object sender, TreeListHtmlDataCellEventArgs e) { if(e.Column.Name == "budget") { decimal value = (decimal)e.CellValue; e.Cell.BackColor = GetBudgetColor(value); if(value > 1000000M) e.Cell.Font.Bold = true } } Color GetBudgetColor(decimal value) { decimal coeff = value / 1000 - 22; int a = (int)(0.02165M * coeff); int b = (int)(0.09066M * coeff); return Color.FromArgb(255, 235 - a, 177 - b); } I'm assuming that the number multiplied times the coeff could be calculated somehow. Any ideas?
0
0
0
0
1
0
I'm no good at math. :) Is this right? I'm accumulating all CPU seconds, and I need to find what percentage the addon's CPU time is from the total. function PluginResources.GetTotalCPU(addon) UpdateAddOnCPUUsage() local totalCPU = 0 for i=1, GetNumAddOns() do totalCPU = totalCPU + (GetAddOnCPUUsage(i) ) end local addonUsage = GetAddOnCPUUsage(addon) local usage = totalCPU / addonUsage return usage end
0
0
0
0
1
0
Given a point list (A1, A2, A3, ...., AN), each point Ai has Ai_x, Ai_y, and Ai_z indicates the x, y, z coordinate respectively. Assume that given three point AONE, ATWO, ATHREE, a function named as checkColinear exist, i.e. checkColinear(AONE, ATWO, ATHREE) returns TRUE if points AONE, ATWO and ATHREE are colinear. I am looking for a quick method to remove points that are colinars with some key points on the list. Thank you
0
0
0
0
1
0
Related: what can I use as std::map keys? I needed to create a mapping where specific key locations in space map to lists of objects. std::map seemed the way to do it. So I'm keying a std::map on an xyz Vector class Vector { float x,y,z } ; , and I'm making a std::map<Vector, std::vector<Object*> >. So note the key here is not a std::vector, its an object of class Vector which is just a math xyz vector of my own making. To produce a "strictly weak ordering" I've written the following overload for operator<: bool Vector::operator<( const Vector & b ) const { // z trumps, then y, then x if( z < b.z ) { return true ; } else if( z == b.z ) { if( y < b.y ) { // z == b.z and y < b.y return true ; } else if( y == b.y ) { if( x < b.x ) { return true ; } else if( x == b.x ) { // completely equal return false ; } else { return false ; } } else { // z==b.z and y >= b.y return false ; } } else { // z >= b.z return false ; } } Its a bit long but basically makes it so any vector can consistently be said to be less than any other vector ((-1, -1, -1) < (-1,-1,1), and (-1, -1, 1) > (-1,-1,-1) for example). My problem is this is really artificial and although I've coded it and it works, I am finding that it "pollutes" my Vector class (mathematically) with this really weird, artificial, non-math-based notion of "less than" for a vector. But I need to create a mapping where specific key locations in space map to certain objects, and std::map seems the way to do it. Suggestions? Out-of-box solutions welcome!!
0
0
0
0
1
0
im making a drop down menu in flash and i want it to slide down. At the moment im using a linear slide ( _y += 5, _y -= 5) etc. I know there are other types of transitions like exponential and the like, how would i go about implementing them? I also remember there was a website once that showed all sorts of slide animations in javascript using different techniques.
0
0
0
0
1
0
I have a set of 3D boxes with arbitrary dimensions, translations and rotations. I need to force the boxes not to intersect by scaling them by a single constant over their 3 dimension components. At the moment I am doing this iteratively by checking for intersection and then reducing the scaling iteratively until there is no intersection. However this is taking too long to run, and I need to do it a lot of times. Does anybody know of a way to find the scaling I need in a single hit. Approximate solutions are most welcome. Many thanks to all. Rob.
0
0
0
0
1
0
I am developing a study for child psychology and would need to analyse thousands of childrens drawings, I would like to automate where possible through edge tracing etc. to guess the content of the picture comparing it to a library of objects... sun, house, tree, dog, etc. is it possible?
0
1
0
0
0
0
Given a quaternion q, and three 3D vectors (vx, vy, vz) which form coordinate axes, which can be oriented in arbitrary direction, but are all perpendicular to each other, thus forming a 3d space. How can I check if the quaternion q is rotated to the same direction (or opposite direction) as some of the 3D vectors (vx, vy, vz)?
0
0
0
0
1
0
Say you have 2 numbers, for each typical mathematical operation is it possible to predict (without significant overhead) whether those operations would result in an overflow of the type which those numbers are currently represented as?
0
0
0
0
1
0
I am considering a project in which a publication's content is augmented by relevant, publicly available tweets from people in the area. But how could I programmatically find the relevant Tweets? I know that generating a structure representing the meaning of natural language is pretty much the holy grail of NLP, but perhaps there's some tool I can use to at least narrow it down a bit? Alternatively, I could just use hashtags. But that requires more work on behalf of the users. I'm not super familiar with Twitter - do most people use hashtags (even for smaller scale issues), or would relying on them cut off a large segment of data? I'd also be interested in grabbing Facebook statuses (with permission from the poster, of course), and hashtag use is pretty rare on Facebook. I could use simple keyword search to crudely narrow the field, but that's more likely to require human intervention to determine which tweets should actually be posted alongside the content. Ideas? Has this been done before?
0
1
0
0
0
0
Given an object quaternion q, and basis vectors vx, vy, vz forming a 3D space, how can I check whether the quaternion is parallel or perpendicular to all of the basis vectors? For example, I have basis vectors: vx = (0.447410, 0, -0.894329) vy = (0, 1, 0) vz = (0.894329, 0, 0.447410) and quaternion q(w,x,y,z) = (-0.973224, 0, -0.229860, 0) I know the quaternion is perpendicular or parallel (or anti-parallel) to all of the basis vectors but how can I actually calculate it? Another example, q(w,x,y,z) = (0.823991, 0, 0.566602, 0) This is NOT perpendicular or parallel (or anti-parallel) to all of the basis vectors.
0
0
0
0
1
0
Possible Duplicate: Why is Lisp used for AI? What makes a language suitable for Artificial Intelligence development? I've heard that LISP and Prolog are widely used in this field. What features make them suitable for AI?
0
1
0
0
0
0
Hi I am trying to create a simple pie chart using the HTML canvas element. I found a nice tutorial on the web and starting to learn how it is done. Now I want to add some text and I need to know how to find the center of each slice in the pie where the text can be added. Here is the loop code: for ( i = 0; i < t.data.length; i++ ) { label = t.data[i].label; value = t.data[i].value; color = t.data[i].color; ctx.lineWidth = t.strokeLineWidth; ctx.strokeStyle = "#FFFFFF"; ctx.fillStyle = color; ctx.beginPath(); ctx.moveTo( centerX, centerY ); ctx.arc( centerX, centerY, radius, lastEnd, lastEnd + ( Math.PI * 2 * ( value / total ) ), false ); ctx.lineTo( centerX, centerY ); ctx.fill(); ctx.stroke(); lastEnd += Math.PI * 2 * ( value / total ); }
0
0
0
0
1
0