text
stringlengths
0
27.6k
python
int64
0
1
DeepLearning or NLP
int64
0
1
Other
int64
0
1
Machine Learning
int64
0
1
Mathematics
int64
0
1
Trash
int64
0
1
I'm creating a jokes website. Each joke is stored as a record in mysql db. I'm trying to develop a vote link which increments the joke record's "score" column when a "vote" link is clicked. I'm just hoping for some general direction as to how to do this... I'm planning on using jquery's ajax to send the joke's id to a php page to process. I'm just not sure how exactly to process it... something like this? $id = $_POST['id'] mysql_query("UPDATE jokes SET score='++' WHERE id='$id'"); Each joke will be within a uniquely identified <div> (the id= is generated with the record's unique id). Thanks a lot!
0
0
0
0
1
0
This is the lat/long for Philadelphia: http://www.rcn.montana.edu/resources/tools/coordinates.aspx?nav=11&c=DD&md=24&mdt=International(1924)-Hayford(1909)&lat=39.947648&lath=N&lon=-75.151978&lonh=W This is the lat/long for Boulder: http://www.rcn.montana.edu/resources/tools/coordinates.aspx?nav=11&c=DD&md=24&mdt=International(1924)-Hayford(1909)&lat=40.0149856&lath=N&lon=-105.2705456&lonh=W That lat and long are correct (You can check it in Google Maps). UTM_east and UTM_north are also correct for both. Now, plug the UTMs into the distance formula here: http://www.basic-mathematics.com/distance-formula-calculator.html And you will get distance in meters, which is 7 miles. Why on earth is Boulder 7 miles away from Philadelphia?
0
0
0
0
1
0
I am looking for good beginners material on Prolog, both online and printed. I am not only interested in 'learning the language' but also in background and scientific information.
0
1
0
0
0
0
Let's say I have x1, y1 and also x2, y2. How can I find the distance between them? It's a simple math function, but is there a snippet of this online?
0
0
0
0
1
0
Here's what I currently have: function getNearestMultipleOf(n, m) { return Math.round(n/m) * m; } console.log(getNearestMultipleOf(37,18)); //36 A friend told me Math.round is expensive and a more efficient way is to use modulo to check if n has to be rounded up or down and use either Math.ceil or floor. How would you do this?
0
0
0
0
1
0
I am planning to make a program which will have some circular shapes moving inside of a oddly shaped Polygon. I can't seem to figure out how to do the collision detection with the edges and have the shapes bounce back correctly. I am sure this problem has been solved before, but I can't find a nice example. My main problems are: Figuring out if the circle has hit the edge of its surrounding polygon. Once a hit occurs calculate the normal of the hit point to figure out the reflection vector. Can anyone point me in the right direction? Thanks, Jason
0
0
0
0
1
0
Each side is 60 degrees. and the top and bottom sides are horizontal I think width = (cos(60) * sideLength * 2) + sideLength = sideLength * 2 This seems a bit off
0
0
0
0
1
0
I've asked about a shortest path algorithm here: 2D waypoint pathfinding: combinations of WPs to go from curLocation to targetLocation (To understand my situation, please read that question as well as this one.) It appears that the Dijkstra shortest path algorithm would be able to do what I need. However, I have about 500 to 1000 nodes in my routes map. The implementations I have seen so far limited the amount of nodes to something under 50. My question is: should I still use the Dijkstra shortest path algorithm, or an alternative? Are there any implementations in Java?
0
1
0
0
0
0
I have developed a system in R for graphing large datasets obtained from wind turbines. I am now porting the process into Java. The results I get between the two systems are inconsistent. As shown below: The dataset is first plotted using using R, and secondly using JFreeChart. The red line in both graphs correspond to my respective calculations in each language (which are detailed below). The brown dashed line in #1 corresponds to the blue line in #2, there are no discrepancies here, they are provided for reference The shaded area represent the data points, grey in #1 and red in #2. I can explain the discrepancies between the (red) calculated lines and that is due to the fact that I am using different calculation methods. In R the data is processed as follows, I wrote this code with a little help and have no idea what is going on here (but hey, it works). df <- data.frame(pwr = pwr, spd = spd) require(mgcv) mod <- gam(pwr ~ s(spd, bs = "ad", k = 20), data = df, method = "REML") summary(mod) x_grid <- with(df, data.frame(spd = seq(min(spd) + 0.0001, maxi, length=100))) pred <- predict(mod, x_grid, se.fit = TRUE) x_grid <- within(x_grid, fit <- pred$fit) lines(fit ~ spd, data = x_grid, col = "red", lwd = thickLineWidth) In Java (SQL infact) I am using the method of bins to calculate the average at every 0.5 on the x-axis. The resulting data is plotted using a org.jfree.chart.renderer.xy.XYSplineRenderer I do not know too much about how the line is rendered. SELECT ROUND( ROUND( x_data * 2 ) / 2, 1) AS x_axis, # See https://stackoverflow.com/questions/5230647/mysql-rounding-functions AVG( y_data ) AS y_axis FROM table GROUP BY x_axis My take on the variance between the two graphs: Presence of a single outlier at 18 on the x_axis (most visible on the R graph) seems to have an enormous impact on the shape of the curve. Even between 5 and 15 on the x-axis it seems that the line in the R graph is more continuous, it doesn't change trajectory as readily as that produced by Java. The 'crater' evident at 18 on the java x-axis has to 'mounds' each side of it, I believe this is due to polynomial effects in the rendering system. These are things that I would like to eliminate. So in an effort to understand the difference between the two graphs I have a few questions: Exactly what is going on in my R script? How can I, or, do I want to port the same process to my Java code? Can anyone explain the spline system used by JFreeCharts, is there another?
0
0
0
0
1
0
Hello I want to Compare two webpages using python script. how can i achieve it? thanks in advance!
0
1
0
0
0
0
I was wondering if anyone was familiar with any attempts at algorithmic sentence negation. For example, given a sentence like "This book is good" provide any number of alternative sentences meaning the opposite like "This book is not good" or even "This book is bad". Obviously, accomplishing this with a high degree of accuracy would probably be beyond the scope of current NLP, but I'm sure there has been some work on the subject. If anybody knows of any work, care to point me to some papers?
0
1
0
0
0
0
Do you see anything wrong in this code? in thosen't work well it returns a NaN. public class Method2 extends GUIct1 { double x=0,y=0; void settype1 (double conv1) { x = conv1; } void settype2 (double conv2) { y = conv2; } double conversion ( double amount) { double converted = (amount*y)/x; return converted; } } Way it is used an i already changed the set part Method2 convert = new Method2(); \\ method is called ..... convert.settype1(j); ..... convert.settype2(k); ..... double x = convert.conversion(i); System.out.println(x);
0
0
0
0
1
0
double a1; a1 = Math.Pow(somehighnumber, 40); something.Text = Convert.ToString(xyz); the result i get is have E+41 etc. its like 1,125123E+41 etc. i dont get why.
0
0
0
0
1
0
I have an NSArray of NSNumbers with integer values such as [1,10,3]. I want to get the sum of all the possible subsets of these numbers. For example for 1,10 and 3 i would get: 1, 10, 3, 1+10=11, 1+3=4, 10+3=13, 1+10+3=14 there are 2^n possible combinations. I understand the math of it but im having difficulties putting this into code. so how can i put this into a method that would take the initial array of numbers and return an array with all the sums of the subsets? e.g -(NSArray *) getSums:(NSArray *)numbers; I understand that the results grow exponentially but im going to be using it for small sets of numbers.
0
0
0
0
1
0
How would you derive this expression? I need to draw a parse tree for this, but having real trouble deriving this. A google search didn't give any useful links either, any help would be much appreciated, but please do give a brief explanation of how you did it as I have few others to do myself. Does the "|" stand for an "or" operator just like in programming? < exp> ---> < exp> * < factor> | < factor> < factor> ---> < factor> - < term> | < term> < term> ---> x | y | z This is the best I could come up with and I am fully lost .. < exp> ---> < exp> * < factor> ---> x * < factor> ---> x * < factor> * < factor>
0
0
0
0
1
0
I've got a series of files that are namedHHMMSSxxxxxxxxxxxxxxxx.mp3, where HH,MM, and SS are parts of a timestamp and the x's are unique per file. The timestamp follows a 24 hour form (where 10am is 100000, 12pm is 120000, 6pm is 180000, 10pm is 220000, etc). I'd like to shift each down by 10 hours, so that 10am is 000000, 12pm is 020000, etc. I know basic BASH commands for renaming and moving, etc, but I can't figure out how to do the modular arithmetic on the filenames. Any help would be very much appreciated.
0
0
0
0
1
0
I would like seek your help for a problem I am trying to tackle involving XPaths. I am trying to generalize multiple Xpaths provided by a user to get an XPath that would best 'fit' all the provided examples. This is for a web scraping system I am building. Eg: If the user gives the following xpaths (each pointing to a link in the 'Spotlight' section from the Google News page) Good examples: /html/body/div[@id='page']/div/div[@id='main-wrapper']/div[@id='main']/div/div/div[3] /div[1]/table[@id='main-am2-pane']/tbody/tr/td[@id='rt-col']/div[3]/div[@id='s_en_us:ir']/div[2]/div[1]/div[2]/a[@id='MAE4AUgAUABgAmoCdXM']/span /html/body/div[@id='page']/div/div[@id='main-wrapper']/div[@id='main']/div/div/div[3]/div[1]/table[@id='main-am2-pane']/tbody/tr/td[@id='rt-col']/div[3]/div[@id='s_en_us:ir']/div[2]/div[6]/div[2]/a[@id='MAE4AUgFUABgAmoCdXM']/span /html/body/div[@id='page']/div/div[@id='main-wrapper']/div[@id='main']/div/div/div[3]/div[1]/table[@id='main-am2-pane']/tbody/tr/td[@id='rt-col']/div[3]/div[@id='s_en_us:ir']/div[2]/div[12]/div[2]/a[@id='MAE4AUgLUABgAmoCdXM']/span Bad Examples: (pointing to a link in another section) /html/body/div[@id='page']/div/div[@id='main-wrapper']/div[@id='main']/div/div/div[3]/div[1]/table[@id='main-am2-pane']/tbody/tr/td[@id='lt-col']/div[2]/div[@id='replaceable-section-blended']/div[1]/div[4]/div/h2/a[@id='MAA4AEgFUABgAWoCdXM']/span It should be able to generalize and produce an xpath expression that would select all the links in the 'Spotlight' section. (It should be able to throw out the incorrect xpath given) Generalized XPath /html/body/div[@id='page']/div/div[@id='main-wrapper']/div[@id='main']/div/div/div[3]/div[1]/table[@id='main-am2-pane']/tbody/tr/td[@id='rt-col']/div[3]/div[@id='s_en_us:ir']/div[2]/div/div[2]/a[@id='MAE4AUgLUABgAmoCdXM']/span Could you kindly advice me on how to go about it. I was thinking of using the Longest Common Substring strategy but however that would over-generalize if a bad example is given (like the fourth example given) Are there any libraries or any open source software that has been done in this area? I saw some similar posts (finding common ancestor from a group of xpath? and Howto find the first common XPath ancestor in Javascript?) However they are talking about longest common ancestor. I am writing it in Javascript as a form of a firefox extension. Thanks for your time and any help would be greatly appreciated!
0
0
0
1
0
0
Any good tutorial with source that will demonstrate how to develop neural network (step bay step for dummies ;-))
0
1
0
0
0
0
I'm interested in learning some AI algorithms that have a practical use in web applications eg. search, product recommendations etc. Obviously since I'm asking this question I am look for some more entry level material. Any sort of useful stuff on the subject is good - books, blogs, tutorials, anything. My language of choice is c# so anything in that would be awesome but I'm happy to look at examples in other languages.
0
1
0
0
0
0
I'm looking for a good explanation why (not how, I know that) binary subtraction is always (?) done by adding the complement etc. Is it just because of the extra logic gates that would be necessary or are there additional, more sophisticated reasons? For example, I could understand that it would be problematic if the result is negative - the representation might have to change. Can you think of more reasons?
0
0
0
0
1
0
Good afternoon, Having never used C# to do serious mathematical work, I have just noticed something which left me confused... If it is true that double Test = Math.Sqrt(UInt64.MaxValue) is equal to 4294967296.0, that is, UInt32.MaxValue + 1, why is it that ulong Test2 = UInt32.MaxValue * UInt32.MaxValue; is equal to 1? At first sight it seems to me that overflow occurs here... But why is that since that product should fit a UInt64? Thank you very much.
0
0
0
0
1
0
I'm sure ive had this in school before, but i cant remember what is this thing called as. I have arbitrary number and i need to know how many times i can multiply it by 0.9 (or any other value 0-1) until theres less than x left from the original number. in a loop format it would look like: num = 4654; mult = 0.9; limit = 140; count = 0; while(num >= limit){ num *= mult; count++; } But is this even possible to be done without a loop? something with logarithms?
0
0
0
0
1
0
Can someone help me out with the stanford parser from http://nlp.stanford.edu/software/lex-parser.shtml? I've only downloaded and unzipped the parser. I've also installed the jython fully but i cannot parse a sentence, it seems like i've installed some modules or something. http://wiki.python.org/jython/InstallationInstructions >>> import sys >>> sys.path.append('~/standford-parser-2010-11-30/stanford-parser-2011-11-30.jar') >>> from java.io import CharArrayReader >>> from edu.stanford.nlp import * Traceback (innermost last): File "<console>", line 1, in ? ImportError: no module named edu Is there more installation procedures other than unzipping it and importing it in jython?
0
1
0
0
0
0
There is a good compilation of trajectory math in wikipedia. But I need to calculate a trajectory that has non uniform conditions. E.g. the wind speed changes above certain altitude. (Cannot be modeled easily.) Should I calculate projectile's velocity vector e.g. every second and then for the next second based on that (having small enough tdelta) Or should I try to split the trajectory into pieces - based on the parameters (e.g. wind is vwind 1 between y1 and y2 so I calculate for y<y1, y1≤y<y2 and y2≤y separately). Try to build and solve a symbolic equation - run time - with all the parameters modeled. (Is this completely utopistic? Traditional programmin languages aren't too good solving symbols.) Something completely different... ? Are there good languages / frameworks for handling symbolic math?
0
0
0
0
1
0
I am getting problems when I calculating distance between point and line. There is floating point number calculation (compare expression) problem. Due to this I not able to know perfect value of $onextensionFlag. please see following... May I know what is wrong? proc calculateDistanceToLinefrompoint {P line} { # solution based on FAQ 1.02 on comp.graphics.algorithms # L = sqrt( (Bx-Ax)^2 + (By-Ay)^2 ) # (Ay-Cy)(Bx-Ax)-(Ax-Cx)(By-Ay) # s = ----------------------------- # L^2 # dist = |s|*L # => # | (Ay-Cy)(Bx-Ax)-(Ax-Cx)(By-Ay) | # dist = --------------------------------- # L # (Ay-Cy)(Ay-By)-(Ax-Cx)(Bx-Ax) # r = ----------------------------- # L^2 # r=0 P = A # r=1 P = B # r<0 P is on the backward extension of AB # r>1 P is on the forward extension of AB # 0<=r<=1 P is interior to AB set ret 0 set Ax [lindex $line 0 0] set Ay [lindex $line 0 1] set Az [lindex $line 0 2] set Bx [lindex $line 1 0] set By [lindex $line 1 1] set Bz [lindex $line 1 2] set Cx [lindex $P 0] set Cy [lindex $P 1] set Cz [lindex $P 2] if {$Ax==$Bx && $Ay==$By && $Az==$Bz} { set ret [list [GetDistanceBetweenTwoPoints $P [lindex $line 0]] 1] } else { set L [expr {sqrt(pow($Bx-$Ax,2) + pow($By-$Ay,2) + pow($Bz-$Az,2))}] #puts "L=$L" set d_val [expr {($Ay-$Cy)*($Bx-$Ax)-($Ax-$Cx)*($By-$Ay)-($Az-$Bz)*($Az-$Cz)}] set n_rval [expr {$d_val / pow($L,2)}] set n_rval [format "%0.3f" $n_rval] if { 0 < $n_rval && $n_rval < 1} { set onextensionFlag 0;# inside clipping area } elseif {$n_rval == 0 || $n_rval == 1} { set onextensionFlag 1 ;# inside clipping area (but on point) } elseif { $n_rval > 1 || $n_rval < 0 } { set onextensionFlag 2 ;# outside clipping area } else { set onextensionFlag 3 ;# consider inside clipping area } set ret [list [expr {abs($d_val) / $L}] $onextensionFlag $n_rval] } }
0
0
0
0
1
0
hello everyone i am doing a project in lip sync. however i am facing a problem here. i have each frame of a picture which is generated from a sound unit. now i would like to play the sound and the picture frames simultaneously so as to have an effect of a lip sync. i.e for a 2 second audio around 10 frames are generated.now how do i run this audio and picture frames together so as to obtain a 'lip sync' in matlab. thank u in advance
0
0
0
0
1
0
Describe a process to convert a base36 number to base16, without converting to base10 as an intermediary.
0
0
0
0
1
0
I have some problems with calculating cosinus 90 in Java using Math.cos function : public class calc{ private double x; private double y; public calc(double x,double y){ this.x=x; this.y=y; } public void print(double theta){ x = x*Math.cos(theta); y = y*Math.sin(theta); System.out.println("cos 90 : "+x); System.out.println("sin 90 : "+y); } public static void main(String[]args){ calc p = new calc(3,4); p.print(Math.toRadians(90)); } } When I calculate cos90 or cos270, it gives me absurb values. It should be 0. I tested with 91 or 271, gives a near 0 which is correct. what should I do to make the output of cos 90 = 0? so, it makes the output x = 0 and y = 4. Thankful for advice
0
0
0
0
1
0
I'm trying to build an Augmented Reality Demonstration, like this iPhone App: http://www.acrossair.com/acrossair_app_augmented_reality_nearesttube_london_for_iPhone_3GS.htm However my geometry/math is a bit rusty nowadays. This is what I know: If i have my Android phone on the landscape mode (with the home button on the left), my z axis points to the direction I'm looking. From the sensors of my phone i know what is the angle my z axis has with the North axis, let's call this angle theta. If I have a vector from my current position to the point I want to show in my screen, i can calculate the angle this vector does with my z axis. Let's call this angle alpha. So, based on the alpha angle I have a perception of where the point is, and I'm able to show it in the screen (like the Nearest Tube App). This is the basic theory of a simple demonstration (of course it's nothing like the App, but it's the first step). Can someone give me some lights on this matter? [Update] I've found this very interesting example, however I need to have the movement on both xx and yy axis. Any hints?
0
0
0
0
1
0
everyone. I'm using the Baum-Welch algorithm to train a pos tagger,it is totally in the unsupervised way. Here comes the problem: When i get the label result, I only get a sequence of numbers. I can't figure out which label stands for VV,NN,DT. How can I solve this problem?
0
1
0
1
0
0
I am planning on using LibSVM to predict user authenticity in web applications. (1) Collect Data on particular user behavior(eg. LogIn time, IP Address, Country etc.) (2) Use Collected Data to train an SVM (3) Use real time data to compare and generate an output on level of authenticity Can some one tell me how can I do such a thing with LibSVM? Can Weka be helpful in these types of problems?
0
0
0
1
0
0
I am using some rule-based and statistical POS taggers to tag a corpus(of around 5000 sentences) with Parts of Speech(POS). Following is a snippet of my test corpus where each word is seperated by its respective POS tag by '/'. No/RB ,/, it/PRP was/VBD n't/RB Black/NNP Monday/NNP ./. But/CC while/IN the/DT New/NNP York/NNP Stock/NNP Exchange/NNP did/VBD n't/RB fall/VB apart/RB Friday/NNP as/IN the/DT Dow/NNP Jones/NNP Industrial/NNP Average/NNP plunged/VBD 190.58/CD points/NNS --/: most/JJS of/IN it/PRP in/IN the/DT final/JJ hour/NN --/: it/PRP barely/RB managed/VBD *-2/-NONE- to/TO stay/VB this/DT side/NN of/IN chaos/NN ./. Some/DT ``/`` circuit/NN breakers/NNS ''/'' installed/VBN */-NONE- after/IN the/DT October/NNP 1987/CD crash/NN failed/VBD their/PRP$ first/JJ test/NN ,/, traders/NNS say/VBP 0/-NONE- *T*-1/-NONE- ,/, *-2/-NONE- unable/JJ *-3/-NONE- to/TO cool/VB the/DT selling/NN panic/NN in/IN both/DT stocks/NNS and/CC futures/NNS ./. After tagging the corpus, it looks like this: No/DT ,/, it/PRP was/VBD n't/RB Black/NNP Monday/NNP ./. But/CC while/IN the/DT New/NNP York/NNP Stock/NNP Exchange/NNP did/VBD n't/RB fall/VB apart/RB Friday/VB as/IN the/DT Dow/NNP Jones/NNP Industrial/NNP Average/JJ plunged/VBN 190.58/CD points/NNS --/: most/RBS of/IN it/PRP in/IN the/DT final/JJ hour/NN --/: it/PRP barely/RB managed/VBD *-2/-NONE- to/TO stay/VB this/DT side/NN of/IN chaos/NNS ./. Some/DT ``/`` circuit/NN breakers/NNS ''/'' installed/VBN */-NONE- after/IN the/DT October/NNP 1987/CD crash/NN failed/VBD their/PRP$ first/JJ test/NN ,/, traders/NNS say/VB 0/-NONE- *T*-1/-NONE- ,/, *-2/-NONE- unable/JJ *-3/-NONE- to/TO cool/VB the/DT selling/VBG panic/NN in/IN both/DT stocks/NNS and/CC futures/NNS ./. I need to calculate the tagging accuracy(Tag wise- Recall & Precision), therefore need to find an error(if any) in tagging for each word-tag pair. The approach I am thinking of is to loop through these 2 text files and store them in a list and later compare the 'two' lists element by element. The approach seems really crude to me, so would like you guys to suggest some better solution to the above problem. From the wikipedia page: In a classification task, the precision for a class is the number of true positives (i.e. the number of items correctly labeled as belonging to the positive class) divided by the total number of elements labeled as belonging to the positive class (i.e. the sum of true positives and false positives, which are items incorrectly labeled as belonging to the class). Recall in this context is defined as the number of true positives divided by the total number of elements that actually belong to the positive class (i.e. the sum of true positives and false negatives, which are items which were not labeled as belonging to the positive class but should have been).
0
1
0
1
0
0
Possible Duplicate: random a 512-bit integer N that is not a multiple of 2, 3, or 5 I have a question for a random 512-bit integer n that isn't a multiple of 2,3, or 5 what is the chance that n is prime? what about that n is composite but fools the fermat primality test? what about that it is composite but doesn't fool the fermat primality test?
0
0
0
0
1
0
NSLog(@"Before: %d",currentArticle); currentArticle--; NSLog(@"SUBTRACT %d",currentArticle); "currentArticle" is an integer. This is only being echoed once in my console. If I do not run this subtraction, the number "currentArticle" remains at 7. This is being run in the main thread, and only run once per user interaction. I have also tried currentArticle = currentArticle - 1; With the same result. Am I taking crazy pills? Thanks! Edit: Declared as follows: extern int *currentArticle; And assigned later as: currentArticle = 0; I tried rewriting as this: int *curArticle; // in my .h file curArticle = 1; And then I run the curArticle--; and it still decrements by two... I have stepped through the code and ensured there are no other calls hitting this variable.. Thanks for the feedback so far, I will keep hacking away at it.
0
0
0
0
1
0
I have to convert within my XSLT number in exponential format ( i.e: 1,2345E7 ) into numeric ( i.e: 12340000 ). What would the a XSLT function to achieve this.
0
0
0
0
1
0
I've searched around, but after sifting through quite a lot of posts, I haven't really seen this covered -- I'd like to convert an unsigned, base-10 integer to a much higher "custom" base, by providing the "alphabet", but I'm not sure where to start, and am probably overlooking the simplicity. As mentioned on wikipedia, there are variants of traditional Base 64 that do not add padding, etc., for use in URLs and what-not, but I am not sure how to begin implementing that. 8 I'm not encoding strings or binary data - just plain integer numbers - and would like to be able to feed an arbitrarily-long "alphabet" into the conversion function. Ideally, of course, I would be able to reverse the numbers as well. I'm using PHP, but I should be able to work with anything using straightforward math and not a lot of custom libraries, of course.
0
0
0
0
1
0
if you are to choose a random a 512-bit integer N that is not a multiple of 2, 3, or 5 What is the probability that N is prime? i don't know the algorithm behind this one... i'm trying to work on a project but this is the starting point.. :)
0
0
0
0
1
0
Can someone help me check my bash script? i'm trying to feed a directory of .txt files to the stanford parser (http://nlp.stanford.edu/software/pos-tagger-faq.shtml) but i can't get it to work. i'm working on ubuntu 10.10 the loop is working and reading the right files with: #!/bin/bash -x cd $HOME/path/to for file in 'dir -d *' do # $HOME/chinesesegmenter-2006-05-11/segment.sh ctb $file UTF-8 echo $file done but with #!/bin/bash -x cd $HOME/yoursing/sentseg_zh for file in 'dir -d *' do # echo $file $HOME/chinesesegmenter-2006-05-11/segment.sh ctb $file UTF-8 done i'm getting this error: alvas@ikoma:~/chinesesegmenter-2006-05-11$ bash segchi.sh Standard: CTB File: dir Encoding: -d ------------------------------- Exception in thread "main" java.lang.NoClassDefFoundError: edu/stanford/nlp/ie/crf/CRFClassifier Caused by: java.lang.ClassNotFoundException: edu.stanford.nlp.ie.crf.CRFClassifier at java.net.URLClassLoader$1.run(URLClassLoader.java:217) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:205) at java.lang.ClassLoader.loadClass(ClassLoader.java:321) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294) at java.lang.ClassLoader.loadClass(ClassLoader.java:266) Could not find the main class: edu.stanford.nlp.ie.crf.CRFClassifier. Program will exit. the following command works: ~/chinesesegmenter-2006-05-11/segment.sh ctb ~/path/to/input.txt UTF-8 and output this alvas@ikoma:~/chinesesegmenter-2006-05-11$ ./segment.sh ctb ~/path/to/input.txt UTF-8 Standard: CTB File: /home/alvas/path/to/input.txt Encoding: UTF-8 ------------------------------- Loading classifier from data/ctb.gz...done [1.5 sec]. Using ChineseSegmenterFeatureFactory Reading data using CTBSegDocumentReader Sequence tagging 7 documents 如果 您 在 新加坡 只 能 前往 一 间 俱乐部 , 祖卡 酒吧 必然 是 您 的 不二 选择 。 作为 或许 是 新加坡 唯一 一 家 国际 知名 的 夜店 , 祖卡 既 是 一 个 公共 机构 , 也 是 狮城 年轻人 选择 进行 成人 礼等 庆祝 的 不二场所 。
0
1
0
0
0
0
I am writing a converter for 2D geometry data. One of the elements I have to convert is an arc. In the source system the arc is described with two axis aligned rectangles. The first rectangle is a boundingbox for the circle of which the arc is part of. The second rectangle is a boundingbox for the arc itself. The constraint is, that the arc's boundingbox must intersect two edges of the circle's boundingbox. I know the coordinates of the top left and bottom right points of each rectangle. The target system describes an arc as follows: A rectangle is a bounding box around the circle of which the arc is part of. So far it is the same as above. Then I have two points designating the start and end points of the arc. Both points must be exactly on the circle's "edge". The question is: do you see an easy way to calculate the start and end-point of the arc? I have already seen this question but it seems really complicated. Perhaps there is an easier way to do this... My thoughts so far: It seems I must calculate the intersections of the edges of the arc's boundingbox with the circle. Two cases are possible (due to the restrictions mentioned above): only one edge intersects with the circle or two edges intersect with the circle. Additionally all other edges will always be outside of the circle. Update: the start and end points cut the circle in two parts. Which of the two parts is draw as the arc, is determined by the order of the start and end points. The arc is always drawn counter clockwise from start to end point.
0
0
0
0
1
0
I just discovered an algorithm for finding the power set. I googled after solutions, but found none that worked any good, so I figured out one myself. But I wonder what algorithm it is, because I cannot find it on the net or in any books. I mean, does it have a name? Compared to the algorithms I found on some sites for calculating the power set, I think mine is far better and wonder why no one uses it? This is the algorithm: R <- [] L <- [ e1, e2 ... en ] c <- 0 function: powerSet(L, c) R <- R union L for e in L starting at c powerSet(L\{e}, c) end return R end And here it is implemented in Java: public static void powerSet(List<String> list, int count) { result.add(list); for(int i = count; i < list.size(); i++) { List<String> temp = new ArrayList<String>(list); temp.remove(i); powerSet(temp, i); } }
0
0
0
0
1
0
In Russell and Norvig, third edition, they give the following definition of the minimax value of a node in a game tree (zero-sum, perfect information, deterministic) The minimax value of a node is the utility (for MAX) of being in the corresponding state, assuming that both players play optimally from there to the end of the game. Only thing is, that in their setup of a game, the utility of a node is only defined for terminal nodes, so how should one understand the utility of a general node ? Thanks.
0
1
0
0
0
0
I'm trying to implement a web application that will let users define rules and ask questions to see if statements are legal or illegal according to a set of rules. The domains I have in mind would be rules for small communities or clubs. For example, say a possible rule set contains the rules: Only cars with valid registration tags may park anywhere indefinitely. Cars without valid registration tags may only park in a visitor spot for up to 3 days. And then someone asks "Can I park my Honda here?" The system would attempt to answer by first following a question and answer tree resembling: "Is a Honda a car?" =>Yes "Does it have a valid registration tag?" =>Yes "Yes" =>No "Are you parking in a visitor spot?" =>Yes "Have you parked in that spot for more than 3 days?" =>Yes "No" =>No "Yes" =>No "No" =>Define "visitor spot"? "A visitor spot is a parking spot. A parking spot is spatial rectangular area of asphault with a width of 8 feet and a length of 15 feet with a variation of 1 foot. It has either another parking spot or a curb adjacent to it. It has the words "Visitor" painted on it. It ressembles <img>." =>Define "parking"? "Parking is the act of placing a vehicle within the spatial area of a parking spot. The state of a parked image ressembles <img>." =>Define "valid registration tag"? "A valid registration tag ressembles <img>" =>No "No" =>Define "car"? "A car is a 4 wheeled vehicle weighing less than 3 tons." The user selects an answer at each node, and the system would ask the next question according to an answer until a leaf node is reached, representing a "final" answer. At each node, the user may ask the system to explain or define terms used in the question. Explanations would be a series of statements containing terms, which themselves could be further explained or defined. After enough experience is gained, the system could automatically skip certain nodes, such as the first "Is a Honda a car?" when it learns that in the context of "parking" a "Honda" will always imply a "car". Although not shown in this tree, some trees may have "Undefined" leaf nodes, representing cases where the rules didn't provide enough coverage to fully create the tree, requiring the question to be redirected to a human expert for clarification or correction of the rules. The goal would be to define the rules in a database, and then dynamically generate these Q&A trees as needed. Although the rules and questions shown here are represented as natural language, the initial system would use symbolic logic instead, as doing NLP in addition to this logical parsing would immensely complicate the initial system. The rules may be initially drafted as natural language, but they'd be manually converted to discrete rules by hand before being entered into the system. The questions would be displayed as simple natural language statements, and the answers would be multiple choice. Does this seem like a practical project? Is there any prior art? I haven't read about anything like this so far, but I'm not sure what search keywords adequately describe this system. What tools should I use? I'm not sure if I should use decision trees or some sort of expert system for matching questions to rules and narrowing down the scope of the question.
0
0
0
1
0
0
I'm working on an calculator that has three fields: "length," "width," "area." "Area" is equal to "length" x "width". However, my client needs to ability to update any two of these fields to get the third -- what I currently have only calculates area when length or width changes and doesn't have the ability to calculate the missing value. jQuery(document).ready( function ($) { $('input').change(function() { var $parent = $(this).parents("td").children("div").children("div"), length = $parent.find('input[id*="field-length-0-value"]').val(), width = $parent.find('input[id*="field-width-0-value"]').val(); $parent.find('input[id*="field-area-0-value"]').val(length * width); }); }); Source, jsbin How do I make the length or width update when the area is modified? Many thanks!
0
0
0
0
1
0
I want to do some simple math with some very small and very large numbers. I figured I'd start with BigDecimal: scala> java.math.BigDecimal.valueOf(54, 45) res0: java.math.BigDecimal = 5.4E-44 How do I then get the the mantissa? Either 54 or 5.4 would be fine.
0
0
0
0
1
0
I know this may sound stupid but I'm goin crazy with this XD I'm loading ad image (with ImageMagick) into a 1D vector, so that I have something like: 012345678... RGBRGBRGB... Where 0-. Are obviously the indexes of the vector, and R, G, and B are respectively the red byte, green byte, and blue byte. So I have a WIDTHxHEIGHTx3 bytes vector. Now, let's say I want to access the x,y,z byte, where z is the index of the color, which is the transformation formula to have a linear offset into the vector?
0
0
0
0
1
0
In a simple perception, can someone explain to me the concept of the Threshold and and how to set it, i.e. initially what is the value of the Threshold input and weight??
0
1
0
0
0
0
can someone help with me reading "#" char in python? i can't seem to get the file. because this is an output from the stanford postagger, is there any scripts available to convert the stanford postagger http://nlp.stanford.edu/software/tagger.shtml file to cwb. http://cogsci.uni-osnabrueck.de/~korpora/ws/CWBdoc/CWB_Encoding_Tutorial/node3.html so this is the utf-8 txt file that i'm trying to read: 如果#CS 您#PN 在#P 新加坡#NR 只#AD 能#VV 前往#VV 一#CD 间#M 俱乐部#NN ,#PU 祖卡#NN 酒吧#NN 必然#AD 是#VC 您#PN 的#DEG 不二#JJ 选择#NN 。#PU 作为#P 或许#AD 是#VC 新加坡#NR 唯一#JJ 一#CD 家#M 国际#NN 知名#VA 的#DEC 夜店#NN ,#PU 祖卡#NN 既#CC 是#VC 一#CD 个#M 公共#JJ 机构#NN ,#PU So with this code i'm not readin the # char in the utf-8 txt files: #!/usr/bin/python # -*- coding: utf-8 -*- ''' stanford POS tagger to CWB format ''' import codecs import nltk import os, sys, re, glob reload(sys) sys.setdefaultencoding('utf-8') cwd = './path/to/file.txt' #os.getcwd() for infile in glob.glob(os.path.join(cwd, 'zouk.txt')): print infile (PATH, FILENAME) = os.path.split(infile) reader = codecs.open(infile, 'r', 'utf-8') for line in reader: for word in line: if word == '\#': print 'hex is here'
0
1
0
0
0
0
From the accelerometer, is it possible to get the angle of elevation? For those of you who don't know, the angle of elevation is: Is this possible with the accelerometer measurements?
0
0
0
0
1
0
We know there are algorithms to reduce the dimension of data sets like PCA and Isomap What is the state of the art in the reducing dimensionality to data sets. Do you have an example, maybe on MATLAB? Lets say we have a data set with 100,000 attributes like Dorothea Data Set (Chemical compounds represented by structural molecular features must be classified as active (binding to thrombin) or inactive. This is one of 5 datasets of the NIPS 2003 feature selection challenge.) Data Set Characteristics: Multivariate Number of Instances: 1950 Area: Life Attribute Characteristics: Integer Number of Attributes: 100000 Date Donated 2008-02-29 Associated Tasks: Classification Missing Values? N/A Number of Web Hits: 17103
0
1
0
0
0
0
For use in a rigid body simulation, I want to compute the mass and inertia tensor (moment of inertia), given a triangle mesh representing the boundary of the (not necessarily convex) object, and assuming constant density in the interior.
0
0
0
0
1
0
(This may be better off on the math site, but I figured that since it's programming-related I'd ask here first). In some libraries, such as C++'s STL, algorithms or data structures that need to perform comparisons between elements require only a strict weak ordering < since all six relational operators can be derived from the strict weak ordering: x < y iff x < y x <= y iff !(y < x) x == y iff !(x < y || y < x) x != y iff x < y || y < x x >= y iff !(x < y) x > y iff y < x I've seen this used extensively, and while I know the term "strict weak ordering" for the < operator, I'm never quite sure what to call the equivalence relation x == y iff !(x < y || y < x) that you can derive from it. Is there a term for this equivalence relation?
0
0
0
0
1
0
I am a beginner and have currently started working on a game for Android which uses a particle swarm optimization algorithm. I am now trying to optimize my code a little and i have quite a lot of Math.random() in for-loops which is running almost all the time. So i was thinking of a way to get around and skip all the Math.random() calls. By using a method like this: float random[] = new float[100]; static int randomIndex=0; private float myRandom(){ if(randomIndex >= 99) randomIndex = 0; else randomIndex = randomIndex+1; return random[randomIndex]; } ...and also do this one time when the activity starts: for (int i=0; i< 100; i++) random[i]=(float) Math.random(); My question is if this will be better (faster) than using Math.random()? Does anyone have a better suggestion how to do? I also wonder if anyone know any good site where i can read more about how to write efficient java/android code. I'm afraid i kind of suck on it.
0
0
0
0
1
0
here is an example of what I mean function t1(){ $n = 875; $p = 12; $b = $n*($p/100); $a = $n-$b; return array('a' => $a, 'b' => $b); } $v1 = t1(); now from $v1 we can tell that $n was $v1['a']+$v1['b']; but how do we work out what $p was?
0
0
0
0
1
0
Knowing that EM algorithm as applied to fitting a mixture of Gaussians. Is there any example of this algorithm where is explained with k-means, in MATLAB? I have found this m file: function [label, model, llh] = emgm(X, init) % Perform EM algorithm for fitting the Gaussian mixture model. % X: d x n data matrix % init: k (1 x 1) or label (1 x n, 1<=label(i)<=k) or center (d x k) % Written by Michael Chen (sth4nth@gmail.com). %% initialization fprintf('EM for Gaussian mixture: running ... '); R = initialization(X,init); [~,label(1,:)] = max(R,[],2); R = R(:,unique(label)); tol = 1e-10; maxiter = 500; llh = -inf(1,maxiter); converged = false; t = 1; while ~converged && t < maxiter t = t+1; model = maximization(X,R); [R, llh(t)] = expectation(X,model); [~,label(:)] = max(R,[],2); u = unique(label); % non-empty components if size(R,2) ~= size(u,2) R = R(:,u); % remove empty components else converged = llh(t)-llh(t-1) < tol*abs(llh(t)); end end llh = llh(2:t); if converged fprintf('Converged in %d steps. ',t-1); else fprintf('Not converged in %d steps. ',maxiter); end function R = initialization(X, init) [d,n] = size(X); if isstruct(init) % initialize with a model R = expectation(X,init); elseif length(init) == 1 % random initialization k = init; idx = randsample(n,k); m = X(:,idx); [~,label] = max(bsxfun(@minus,m'*X,dot(m,m,1)'/2),[],1); [u,~,label] = unique(label); while k ~= length(u) idx = randsample(n,k); m = X(:,idx); [~,label] = max(bsxfun(@minus,m'*X,dot(m,m,1)'/2),[],1); [u,~,label] = unique(label); end R = full(sparse(1:n,label,1,n,k,n)); elseif size(init,1) == 1 && size(init,2) == n % initialize with labels label = init; k = max(label); R = full(sparse(1:n,label,1,n,k,n)); elseif size(init,1) == d %initialize with only centers k = size(init,2); m = init; [~,label] = max(bsxfun(@minus,m'*X,dot(m,m,1)'/2),[],1); R = full(sparse(1:n,label,1,n,k,n)); else error('ERROR: init is not valid.'); end function [R, llh] = expectation(X, model) mu = model.mu; Sigma = model.Sigma; w = model.weight; n = size(X,2); k = size(mu,2); logRho = zeros(n,k); for i = 1:k logRho(:,i) = loggausspdf(X,mu(:,i),Sigma(:,:,i)); end logRho = bsxfun(@plus,logRho,log(w)); T = logsumexp(logRho,2); llh = sum(T)/n; % loglikelihood logR = bsxfun(@minus,logRho,T); R = exp(logR); function model = maximization(X, R) [d,n] = size(X); k = size(R,2); nk = sum(R,1); w = nk/n; mu = bsxfun(@times, X*R, 1./nk); Sigma = zeros(d,d,k); sqrtR = sqrt(R); for i = 1:k Xo = bsxfun(@minus,X,mu(:,i)); Xo = bsxfun(@times,Xo,sqrtR(:,i)'); Sigma(:,:,i) = Xo*Xo'/nk(i); Sigma(:,:,i) = Sigma(:,:,i)+eye(d)*(1e-6); % add a prior for numerical stability end model.mu = mu; model.Sigma = Sigma; model.weight = w; function y = loggausspdf(X, mu, Sigma) d = size(X,1); X = bsxfun(@minus,X,mu); [U,p]= chol(Sigma); if p ~= 0 error('ERROR: Sigma is not PD.'); end Q = U'\X; q = dot(Q,Q,1); % quadratic term (M distance) c = d*log(2*pi)+2*sum(log(diag(U))); % normalization constant y = -(c+q)/2;
0
1
0
0
0
0
I am wondering what algorithm would be clever to use for a tag driven e-commerce enviroment: Each item has several tags. IE: Item name: "Metallica - Black Album CD", Tags: "metallica", "black-album", "rock", "music" Each user has several tags and friends(other users) bound to them. IE: Username: "testguy", Interests: "python", "rock", "metal", "computer-science" Friends: "testguy2", "testguy3" I need to generate recommendations to such users by checking their interest tags and generating recommendations in a sophisticated way. Ideas: A Hybrid recommendation algorithm can be used as each user has friends.(mixture of collaborative + context based recommendations). Maybe using user tags, similar users (peers) can be found to generate recommendations. Maybe directly matching tags between users and items via tags. Any suggestion is welcome. Any python based library is also welcome as I will be doing this experimental engine on python language.
0
0
0
1
0
0
Ok. Basically I want to assign the numbers 1-3 to an infinite progression of numbers in PHP. How would I do this? I want to assign as follows. Core - 1. Supplement - 1. Core - 2. Supplement - 2. Core - 3. Supplement - 3. Core - 4. Supplement - 1. Core - 5. Supplement - 2. Core - 6. Supplement - 3. Core - 7. Supplement - 1. etc Cheers
0
0
0
0
1
0
Since big web applications came into existence, searching for data (and doing it lightning fast and accurate) has been one of the most important problems in web applications. For a while, I've worked using Lucene.NET, which is a C# port of the Lucene project. I also work using PHP using Zend Framework's Lucene API, which brings me to my question. Most times for providing good indexing we need to perform some NLP tools like tokenizing, lemmatizing, and many more, the question is: Do you know of any good NLP programming framework/toolset using PHP? PS: I'm very aware of the Zend API for Lucene, but indexing data properly is not just storing and relying in Lucene, you need to perform some extra tasks, like those above.
0
1
0
0
0
0
I know that the total number of permutations for a given base is the factorial... so the total number of permutations of "abc" is 3! or 3x2x1 or 6. Obviously I'm not sure of the terminology to properly phrase my question, but I would like to find the highest numbered permutation before the "length" of it's representation increases to X characters. For example, Using a Base 62 'alphabet', I can represent integers up to 238327 before the representation uses 4 characters instead of 3. I'd like to know the math behind finding this out, given arbitrary values for Base and Length of representation. Essentially, "using Base-X, how high can I count using Y characters?".
0
0
0
0
1
0
I am not aware of any self-improving compiler, but then again I am not much of a compiler-guy. Is there ANY self-improving compiler out there? Please note that I am talking about a compiler that improves itself - not a compiler that improves the code it compiles. Any pointers appreciated! Side-note: in case you're wondering why I am asking have a look at this post. Even if I agree with most of the arguments I am not too sure about the following: We have programs that can improve their code without human input now — they’re called compilers. ... hence my question.
0
1
0
0
0
0
Can we write cryptographic function as rule in prolog i.e. C = enc(K, M). M = dec(K, C). I don't want low level detail but want to write a functor which provide me this functionality. If it is not possible in prolog then can some one give me reasoning behind that due to this reason prolog doesn't support this kind of functions.
0
0
0
0
1
0
Possible Duplicate: Distance Between Two GEO Locations How can I calculate the distance between two geo locations. (Latitude and Longitude)
0
0
0
0
1
0
I am trying to get 'picking' working in a 3D scene, where the view is rotated such that the iPhone is being held in a landscape mode. I'm using OpenGL ES 2.0 (so all shaders, no fixed-function pipeline). I'm performing the unproject from within the rendering code and immediately drawing the resulting ray using GL_LINES (ray only gets calculated the 1st time that I touch the screen, so afterwards I can move the camera around to observe the resulting line from various angles). My unproject code/call is fine (lots of examples of gluUnproject online). My matrix-inversion code is fine (even compared with excel for a few matrices). However, the resulting ray is off by at least 5-15 degrees from where I actually 'clicked' (in the Simulator it really is a click, so I'm expecting a lot more precision from the unproject). My view is rotated to landscape (after I create the perspective-projection matrix, I rotate it around the Z by -90 degrees; the aspect ratio remains at a portrait one). I believe that the problem with the math being off lies here. Does anyone have any experience doing picking/unprojection with specifically a landscape view?
0
0
0
0
1
0
A == B if C == D C == D if A == B Does A == B?
0
0
0
0
1
0
in first order logic, i know the rules. However, whenever i convert some sentences into FOL, i get errors, I read many books and tutorials, do u have any tricks that can help me out, some examples where i makes errors Some children will eat any food C(x) means “x is a child.” F(x) means “x is food.” Eat(x,y) x eats y I would have written like this: (∃x)(∀y) C(x) ∧ Eat(x,y) edit: (∃x)(∀y) C(x) ∧ F(y) ∧ Eat(x,y) But the book write it like this (∃x)(C(x) ∧ (∀y)(F(y)→Eat(x,y))) Edit No2: 2nd Type of error i'm making: Turtles outlast Rabbits. i'm writing it like this: ∀x,y Turtle(x) ∧ Rabbit(y) ∧ Outlast(x,y) but according to the book ∀x,y Turtle(x) ∧ Rabbit(y) --> Outlast(x,y) Of course, I agree with the book, but is there any problem with my version !!
0
1
0
0
0
0
I need to split text into sentences. I'm currently playing around with OpenNLP's sentence detector tool. I've also heard of NLTK and Stanford CoreNLP tools. What is the most accurate English sentence detection tools out there? I don't need too many NLP features--only a good tool for sentence splitting/detection. I've also heard about Lucene...but that may be too much. But if it has a kick-ass sentence detection module, then I'll use it.
0
1
0
0
0
0
I'm trying to use the Simple hill climbing algorithm to solve the travelling salesman problem. I want to create a Java program to do this. I know it's not the best one to use but I mainly want it to see the results and then compare the results with the following that I will also create: Stochastic Hill Climber Random Restart Hill Climber Simulated Annealing. Anyway back to the simple hill climbing algorithm I already have this: import java.util.*; public class HCSA { static private Random rand; static public void main(String args[]) { for(int i=0;i<10;++i) System.out.println(UR(3,4)); } static public double UR(double a,double b) { if (rand == null) { rand = new Random(); rand.setSeed(System.nanoTime()); } return((b-a)*rand.nextDouble()+a); } } Is this all I need? Is this code even right..? I have a range of different datasets in text documents that I want the program to read from and then produce results. Would really appreciate any help on this. ----- EDIT ---- I was being an idiot and opened the Java file straight into Eclipse when i should have opened it in notepad first.. here is the code i have now got. import java.io.BufferedReader; import java.io.FileReader; import java.io.Reader; import java.io.StreamTokenizer; import java.util.ArrayList; { //Print a 2D double array to the console Window static public void PrintArray(double x[][]) { for(int i=0;i<x.length;++i) { for(int j=0;j<x[i].length;++j) { System.out.print(x[i][j]); System.out.print(" "); } System.out.println(); } } //reads in a text file and parses all of the numbers in it //is for reading in a square 2D numeric array from a text file //This code is not very good and can be improved! //But it should work!!! //'sep' is the separator between columns static public double[][] ReadArrayFile(String filename,String sep) { double res[][] = null; try { BufferedReader input = null; input = new BufferedReader(new FileReader(filename)); String line = null; int ncol = 0; int nrow = 0; while ((line = input.readLine()) != null) { ++nrow; String[] columns = line.split(sep); ncol = Math.max(ncol,columns.length); } res = new double[nrow][ncol]; input = new BufferedReader(new FileReader(filename)); int i=0,j=0; while ((line = input.readLine()) != null) { String[] columns = line.split(sep); for(j=0;j<columns.length;++j) { res[i][j] = Double.parseDouble(columns[j]); } ++i; } } catch(Exception E) { System.out.println("+++ReadArrayFile: "+E.getMessage()); } return(res); } //This method reads in a text file and parses all of the numbers in it //This code is not very good and can be improved! //But it should work!!! //It takes in as input a string filename and returns an array list of Integers static public ArrayList<Integer> ReadIntegerFile(String filename) { ArrayList<Integer> res = new ArrayList<Integer>(); Reader r; try { r = new BufferedReader(new FileReader(filename)); StreamTokenizer stok = new StreamTokenizer(r); stok.parseNumbers(); stok.nextToken(); while (stok.ttype != StreamTokenizer.TT_EOF) { if (stok.ttype == StreamTokenizer.TT_NUMBER) { res.add((int)(stok.nval)); } stok.nextToken(); } } catch(Exception E) { System.out.println("+++ReadIntegerFile: "+E.getMessage()); } return(res); } }
0
1
0
0
0
0
Possible Duplicate: How to find a binary logarithm very fast? (O(1) at best) how does the log function work. How the log of a with base b is calculated.
0
0
0
0
1
0
I have a data file full of numbers I'm loading into a vector of floats. However, the numbers in the data file are of the form -4.60517025e+000 but are being read in like -4.60517 What number should -4.60517025e+000 be?
0
0
0
0
1
0
Out of curiosity, I've been reading up a bit on the field of Machine Learning, and I'm surprised at the amount of computation and mathematics involved. One book I'm reading through uses advanced concepts such as Ring Theory and PDEs (note: the only thing I know about PDEs is that they use that funny looking character). This strikes me as odd considering that mathematics itself is a hard thing to "learn." Are there any branches of Machine Learning that use different approaches? I would think that a approaches relying more on logic, memory, construction of unfounded assumptions, and over-generalizations would be a better way to go, since that seems more like the way animals think. Animals don't (explicitly) calculate probabilities and statistics; at least as far as I know.
0
1
0
1
0
0
I'm having a problem w/ my program. I have extracted a set of data and I would like to test if there is a combination for a particular number. For example, I have an array of int, 1 2 3 4 5, I would like to know if there is a combination for 7 maybe, and it must answer yes there is 3 + 4. I figured out that I need to use the combination formula. So I thought that the outer loop may go like 5C1..5C2..5C3..etc, starting to "take 1" then "take 2" at a time to find out all the possible combinations. The problem is I'm stuck at how to implement this in actual codes. I'm not really very good with Math, A defined loop structure would really help. Thanks a lot in advance!
0
0
0
0
1
0
I am a beginner with matlab. And I need it for a very small portion of my project. I am currently working on creating an extended source for a potential optics related project. I need the extended source to be circular or hexagonal in shape and I need the intensity of the source to be Gaussian distributed. My professor told me that I should model the source in Matlab and then import it on Zemax. Can anyone help me with the matlab part?
0
0
0
0
1
0
I am aware of the duplicates of this question: How does the Google “Did you mean?” Algorithm work? How do you implement a “Did you mean”? ... and many others. These questions are interested in how the algorithm actually works. My question is more like: Let's assume Google did not exist or maybe this feature did not exist and we don't have user input. How does one go about implementing an approximate version of this algorithm? Why is this interesting? Ok. Try typing "qualfy" into Google and it tells you: Did you mean: qualify Fair enough. It uses Statistical Machine Learning on data collected from billions of users to do this. But now try typing this: "Trytoreconnectyou" into Google and it tells you: Did you mean: Try To Reconnect You Now this is the more interesting part. How does Google determine this? Have a dictionary handy and guess the most probably words again using user input? And how does it differentiate between a misspelled word and a sentence? Now considering that most programmers do not have access to input from billions of users, I am looking for the best approximate way to implement this algorithm and what resources are available (datasets, libraries etc.). Any suggestions?
0
1
0
1
0
0
Still trying to earn my numpy stripes: I want to perform an arithmetic operation on two numpy arrays, which is simple enough: return 0.5 * np.sum(((array1 - array2) ** 2) / (array1 + array2)) Problem is, I need to be able to specify the condition that, if both arrays are element-wise 0 at the same element i, don't perform the operation at all--would be great just to return 0 on this one--so as not to divide by 0. However, I have no idea how to specify this condition without resorting to the dreaded nested for-loop. Thank you in advance for your assistance. Edit: Would also be ideal not to have to resort to a pseudocount of +1.
0
0
0
0
1
0
Does anyone know how to run a windows .exe on WINE on an ubuntu bash script? running on ubuntu 10.10 this is the program i'm trying to run "POSTAG-Sejong" from http://isoft.postech.ac.kr/Course/CS730b/2005/index.html it runs properly when i right-click and open with WINE windows program loader. but when i try to run it with the command in terminal $ wine ./postagsejongk/sjTaggerInteg.exe it fails and gives the error: ./dic/Dic.strie ╞─└╧└╗ ┐¡ ╝÷ ╛°╜└┤╧┤┘.wine: Unhandled exception 0x80000003 at address 0x441ce1 (thread 0009), starting debugger... 0x00441ce1: int $3 Modules: Module Address Debug info Name (48 modules) PE 400000- 13e1000 Export sjtaggerinteg ELF 20000000-20077000 Deferred libfreetype.so.6 ELF 20077000-20194000 Deferred libx11.so.6 ELF 20194000-20199000 Deferred libuuid.so.1 ELF 20199000-2019d000 Deferred libxau.so.6 ELF 2019d000-201be000 Deferred imm32<elf> \-PE 201a0000-201be000 \ imm32 ELF 201be000-201c4000 Deferred libxxf86vm.so.1 ELF 201c4000-201c8000 Deferred libxcomposite.so.1 ELF 201c8000-201d2000 Deferred libxcursor.so.1 ELF 26d2d000-26dd6000 Deferred winex11<elf> \-PE 26d40000-26dd6000 \ winex11 ELF 2786c000-27885000 Deferred version<elf> \-PE 27870000-27885000 \ version ELF 2f3dc000-2f3e4000 Deferred libxrandr.so.2 ELF 48ced000-48cf7000 Deferred libxrender.so.1 ELF 4c7d8000-4c90c000 Deferred user32<elf> \-PE 4c7f0000-4c90c000 \ user32 ELF 4d766000-4d77f000 Deferred libice.so.6 ELF 50721000-50727000 Deferred libxfixes.so.3 ELF 532d7000-532fe000 Deferred libexpat.so.1 ELF 593aa000-593bf000 Deferred libz.so.1 ELF 5abfc000-5ac58000 Deferred advapi32<elf> \-PE 5ac10000-5ac58000 \ advapi32 ELF 5d36b000-5d36f000 Deferred libxinerama.so.1 ELF 68000000-6801e000 Deferred ld-linux.so.2 ELF 6801e000-6815f000 Dwarf libwine.so.1 ELF 6815f000-68179000 Deferred libpthread.so.0 ELF 68179000-6817d000 Deferred libdl.so.2 ELF 6817d000-681a3000 Deferred libm.so.6 ELF 681a3000-681ab000 Deferred libnss_compat.so.2 ELF 681ab000-681c2000 Deferred libnsl.so.1 ELF 681c2000-681cd000 Deferred libnss_nis.so.2 ELF 681cd000-681d9000 Deferred libnss_files.so.2 ELF 681d9000-68212000 Deferred libncurses.so.5 ELF 6a619000-6a629000 Deferred libxext.so.6 ELF 72bac000-72bb2000 Deferred libxdmcp.so.6 ELF 72df1000-72dfa000 Deferred libsm.so.6 ELF 74a4f000-74a69000 Deferred libxcb.so.1 ELF 75fe8000-76145000 Deferred libc.so.6 ELF 76d42000-76d72000 Deferred libfontconfig.so.1 ELF 7ab01000-7ab8f000 Deferred gdi32<elf> \-PE 7ab10000-7ab8f000 \ gdi32 ELF 7b800000-7b990000 Dwarf kernel32<elf> \-PE 7b810000-7b990000 \ kernel32 ELF 7bc00000-7bcbb000 Dwarf ntdll<elf> \-PE 7bc10000-7bcbb000 \ ntdll ELF 7bf00000-7bf04000 Deferred <wine-loader> Threads: process tid prio (all id:s are in hex) 00000008 (D) Z:\home\ubi\postagsejongk\sjTaggerInteg.exe 00000009 0 <== 0000000e services.exe 0000001b 0 00000017 0 00000015 0 00000014 0 00000010 0 0000000f 0 00000011 winedevice.exe 00000016 0 00000013 0 00000012 0 00000018 plugplay.exe 0000001c 0 0000001a 0 00000019 0 0000001d explorer.exe 0000001e 0 Backtrace: =>0 0x00441ce1 in sjtaggerinteg (+0x41ce1) (0x00326770) 1 0x00404aa3 in sjtaggerinteg (+0x4aa2) (0x003269fc) 2 0x00401187 in sjtaggerinteg (+0x1186) (0x0032fe90) 3 0x7b85839c call_process_entry+0xb() in kernel32 (0x0032fea8) 4 0x7b85903f ExitProcess+0xc9e() in kernel32 (0x0032fee8) 5 0x7bc71c68 call_thread_func+0xb() in ntdll (0x0032fef8) 6 0x7bc74750 call_thread_entry_point+0x6f() in ntdll (0x0032ffc8) 7 0x7bc49e4a call_dll_entry_point+0x629() in ntdll (0x0032ffe8)
0
1
0
0
0
0
A very strange thing happened. I had an app to calculate points from answers. It worked very well, but since my localization (which has NO impact at all on my counting system of points) they aren't added properly; instead, they are added like a string. 2+4+5 = 245, before it was 11...Any ideas? Example: if(antworten.geo == 0) punktzahl += 10; else if(antworten.geo == 1) punktzahl += 8; else if(antworten.geo == 2) punktzahl += 4; Like this I get the answer from a spinner public class geo_listener implements OnItemSelectedListener{ private boolean i = false; @Override public void onItemSelected(AdapterView<?> parent, View view, int pos, long id){ if(i == true){ antworten.geo_str = parent.getSelectedItem().toString(); antworten.geo = parent.getSelectedItemPosition(); Toast chosen = Toast.makeText(parent.getContext(), parent.getSelectedItem().toString(), Toast.LENGTH_SHORT); chosen.show();} else{ i = true; antworten.geo = parent.getSelectedItemPosition(); } } @Override public void onNothingSelected(AdapterView<?> arg0) { // TODO Auto-generated method stub } } Like this I am defining all those vars and strngs public class antworten{ public static int rennen = 0; // 1 - Rennen 2 - Langsam public static String rennen_str; public static int next_item = 0; //1 - Küchenmesser 2 - Pistole 3 - Stift 4 - Baseball-Schläger public static String next_item_str; public static int family = 0; // 1 - Ja 2 - Nein public static String family_str; public static int place = 0; // 1 - Straße 2 - Zuhause 3 - Arbeit 4 - Restaurant 5 - Öffentlicher Platz public static String place_str; public static int geo = 0; // 1 - Berg 2 - Meer 3 - Land public static String geo_str; public static int virus = 0; // 1 - Luft 2 - Speichel 3 - Blut 4 - Weiß nicht public static String virus_str; public static int walk = 0; //1 - Küchenmesser 2 - Pistole 3 - Stift 4 - Baseball-Schläger public static String walk_str; public static int super_m = 0; // 1 - Ja 2 - Nein public static String super_m_str; public static int apo = 0; // 1 - Ja 2 - Nein public static String apo_str; public static int death = 0; // 1 - Kopfschuss 2 - Abtrennen 3 - Gegengift 4 - Normale Todesarten public static String death_str; public static long punktzahl; public static String punk_str; } and like this I am counting the points package com.zombies.survive; import android.app.Activity; import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.text.method.ScrollingMovementMethod; import android.view.View; import android.widget.Button; import android.widget.TextView; public class result_activity extends Activity { static Context mContext; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.result); String ant_ren = getApplicationContext().getString(R.string.ant1); String ant_itm = getApplicationContext().getString(R.string.ant2); String ant_fam = getApplicationContext().getString(R.string.ant3); String ant_plc = getApplicationContext().getString(R.string.ant4); String ant_geo = getApplicationContext().getString(R.string.ant5); String ant_vir = getApplicationContext().getString(R.string.ant6); String ant_wlk = getApplicationContext().getString(R.string.ant7); String ant_sup = getApplicationContext().getString(R.string.ant8); String ant_apo = getApplicationContext().getString(R.string.ant9); String ant_tot = getApplicationContext().getString(R.string.ant10); //Rennen Frage if(antworten.rennen == 0) antworten.punktzahl += 5; else antworten.punktzahl += 10; //Item Frage if(antworten.next_item == 0) antworten.punktzahl += 6; else if(antworten.next_item == 1) antworten.punktzahl += 10; else if(antworten.next_item == 2) antworten.punktzahl += 2; else if(antworten.next_item == 3) antworten.punktzahl += 5; //Familie Frage if(antworten.family == 0) antworten.punktzahl += 3; else antworten.punktzahl += 10; //Place Frage if(antworten.place == 0) antworten.punktzahl += 6; else if(antworten.place == 1) antworten.punktzahl += 2; else if(antworten.place == 2) antworten.punktzahl += 8; else if(antworten.place == 3) antworten.punktzahl += 10; else if(antworten.place == 4) antworten.punktzahl += 5; else if(antworten.place == 5) antworten.punktzahl += 6; else if(antworten.place == 6) antworten.punktzahl += 5; //Geo Frage if(antworten.geo == 0) antworten.punktzahl += 10; else if(antworten.geo == 1) antworten.punktzahl += 8; else if(antworten.geo == 2) antworten.punktzahl += 4; //Virus Frage if(antworten.virus == 0) antworten.punktzahl += 2; else if(antworten.virus == 1) antworten.punktzahl += 4; else if(antworten.virus == 2) antworten.punktzahl += 10; else if(antworten.virus == 3) antworten.punktzahl += 1; //Walk Frage if(antworten.walk == 0) antworten.punktzahl += 6; else if(antworten.walk == 1) antworten.punktzahl += 8; else if(antworten.walk == 2) antworten.punktzahl += 10; else if(antworten.walk == 3) antworten.punktzahl += 3; else if(antworten.walk == 4) antworten.punktzahl += 1; //Supermarkt Frage if(antworten.super_m == 0) antworten.punktzahl += 10; else if(antworten.super_m == 1) antworten.punktzahl += 5; //Apotheken Frage if(antworten.apo == 0) antworten.punktzahl += 10; else if(antworten.apo == 1) antworten.punktzahl += 5; //Töten Frage if(antworten.death == 0) antworten.punktzahl += 7; else if(antworten.death == 1) antworten.punktzahl += 4; else if(antworten.death == 2) antworten.punktzahl += 5; else if(antworten.death == 3) antworten.punktzahl += 10; antworten.punk_str = String.valueOf(antworten.punktzahl); TextView ergebniss = (TextView)findViewById(R.id.res_txt); ergebniss.setMovementMethod(new ScrollingMovementMethod()); ergebniss.setText(R.string.wenn_eine_zombie_apokalypse_eintreten_w_rde_steht_die_chance_f_r_dich_zu_berleben_bei_ + antworten.punk_str + "% "+ant_ren+ant_itm+ant_plc+ant_fam+ant_geo+ant_vir+ant_wlk+ant_sup+ant_apo+ant_tot); Button back_but = (Button)findViewById(R.id.back_but); back_but.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(result_activity.this,home.class); startActivity(i); } }); } }
0
0
0
0
1
0
Did anyone of you ever documented a function or method with pre and post conditions? (I'm asking because my teacher says that's the official/correct way to do it): Legend: (for I couldn't type special chars) 3 - read it as "there exists" '&exist' E - is a member of (as in set) A - for all --> - implies Suppose that s is a non-empty string. Let B(s) be the set of integers that give the indices of positions in the string s. Here starts documentation of this function: int FirstOccurence(String s, Char c) precondition: (s.lenght() > 0) && 3 int i in B(s) [s.charAt(i) == c] that's the precondition wait for postcondition ;) postcondition: (FirstOccurence(s,c) E B(s)) && (s.charAt(FirstOccurence(s,c)) == c) && A int i B(s)[(i < FirstOccurence(s,c)) --> !(s.charAt(i) == c) ] Did any one of you ever came across such a way of documenting functions/methods in a real world?
0
0
0
0
1
0
Currently if I do this decimal d; temp = "22.00"; decimal.TryParse(temp, NumberStyles.Any, CultureInfo.InvariantCulture, out d); Then 'd' turns out as 22. Is there any way I can ensure that trailing zeros don't get wiped out ? FYI I am using .net 4.0
0
0
0
0
1
0
I'm trying to add all the digits in an integer value until i get a value below 9 using Javascript. for an example, if i have 198, I want to add these together like 1 + 9 + 8 = 18, and since 18 is higher than 9 add 1 +8 again = 9.
0
0
0
0
1
0
I need to convert arbitrary triangulated 3D mesh to cloud of particles that are uniformly spaced. First thought was to try find a way to fill one 3D triangle. And then fill each triangle of mesh, removing duplicated particles on edges, but that's just hard and too much work. I was hoping for some more-math way. Can anyone point me to an algorithm which can help me do my task correctly... well, at least approximatively? Thanks
0
0
0
0
1
0
I am observing a rotation value of a character in a game, and its value confuses me. I am wondering, what kind of unit is used here? It does not seem to be radian or degrees. When the character faces... north, rotation = 0.014887573 north-east, rotation = -0.28192267 east, rotation = -0.7139419 south-east, rotation = -0.9176189 south, rotation = -0.99983466 west, rotation = 0.6936041 south-west, rotation = 0.90622354 north-west, rotation = 0.36119097 There appears to be somekind of exponential increase when facing a more southern rotation. Does this scale make sense to anyone? Update: there appears to be another variable which somehow seems to resolve the actual rotation when multiplied with the above value when facing east or north. If mulitplied, when facing west the value will be 0.5 and when facing east it will be -0.5. However, this multiplier becomes 0 when facing south and 1 when facing north, so when you multiple that with the first value they both become 0. What kind of rotation representation uses multiple values in a 3D scene?
0
0
0
0
1
0
What happens if I do something like this: unsigned int u; int s; ... s -= u; What's the expected behavior of this: 1) Assuming that the unsigned integer isn't too big to fit in the signed integer? 2) Assuming that the unsigned integer would overflow the signed integer? Thanks.
0
0
0
0
1
0
I am trying to loop to get all 2011 bi-weekly dates using this code in VB6: Dim HardDate As Date Dim NumberOfDaysSince As Integer Dim modulus As Integer Dim DaysToNext As Integer Dim nextpayday As Date Dim x As Integer x = 1 DateToday = Date HardDate = Format(Now, "m/dd/yyyy") Do While x <> 20 NumberOfDaysSince = DateDiff("d", HardDate, DateToday) modulus = NumberOfDaysSince Mod 14 DaysToNext = 15 - modulus nextpayday = Date + DaysToNext Debug.Print nextpayday HardDate = DateAdd("d", 1, nextpayday) DateToday = DateAdd("d", 10, HardDate) x = x + 1 Loop However, using that code above does not produce an on going bi-weekly date... Any help would be great! date example Pay Begin Date | Pay End Date | Check Date | Posts ------------------------------------------------------------------- 1/14/2011 | 1/24/2011 | 2/10/2011 | 2/3/2011 1/28/2011 | 2/10/2011 | 2/24/2011 | 2/17/2011 2/11/2011 | 2/24/2011 | 3/10/2011 | 3/3/2011 David
0
0
0
0
1
0
I have downloaded a MetaTrader MQL4 language .mq4 source-code file from here and I think there is a divide by zero error contained in the file. The relevant section is: // Calculate sums for the least-squares method n = ( Taps - 1 ) / 2; sx2 = ( 2*n + 1 ) / 3.0; sx3 = n * ( n + 1 ) / 2.0; sx4 = sx2 * ( 3*n*n + 3*n - 1 ) / 5.0; sx5 = sx3 * ( 2*n*n + 2*n - 1) / 3.0; sx6 = sx2 * ( 3*n*n*n*( n + 2 ) - 3*n + 1 ) / 7.0; den = sx6 * sx4 / sx5 - sx5; // <---------------------------- a DIV!0 error here? This demo-code case: Am I correct in my assumption that there is an error in the code,and if so,perhaps someone could point out what the correction should be? General computation cases: What is the industry best-practice / what practical software-design measures ought be used as a life-jacket protection for DIV!0 incident(s)?
0
0
0
0
1
0
What techniques/tips can you give in regards to summarizing report data points so you don't have to store the raw data in the database? For example, if I was storing page view traffic for a website, and my reports were accurate to the hour I could roll-up all database rows by the hour, and then possible even create further summary tables by the various increments like per day/month etc. Any other tricks/tips along these lines?
0
0
0
0
1
0
I want to rewrite some signal processing code of mine from C++ to Java. I wind up with matrices of complex numbers (numbers with imaginary components). I need to find the inverse of an NxN complex matrix, as well as the principle eigenvector. There are several Java libraries to do this with real numbers, but I couldn't find anything that supported complex numbers. I found one library but it was proprietary and had to be licensed. Has this been implemented anywhere? I can always wrap the needed C code with JNI, but I was doing this to avoid platform dependence.
0
0
0
0
1
0
My application creates coupons that each need a unique barcode number. This number needs to be a positive integer and must be between 6 - 12 digits. This number represents a unique coupon, so this number must be unique. I can't simply increment the barcode numbers by 1, because this will make it easy for hackers to guess other coupon barcodes. If I have a coupon db table, how can I generate this random barcode number and guarantee uniqueness?
0
0
0
0
1
0
I need to make transparency, having 2 pixels: pixel1: {A, R, G, B} - foreground pixel pixel2: {A, R, G, B} - background pixel A,R,G,B are Byte values each color is represented by byte value now I'm calculating transparency as: newR = pixel2_R * alpha / 255 + pixel1_R * (255 - alpha) / 255 newG = pixel2_G * alpha / 255 + pixel1_G * (255 - alpha) / 255 newB = pixel2_B * alpha / 255 + pixel1_B * (255 - alpha) / 255 but it is too slow I need to do it with bitwise operators (AND,OR,XOR, NEGATION, BIT MOVE) I want to do it on Windows Phone 7 XNA ---attached C# code--- public static uint GetPixelForOpacity(uint reduceOpacityLevel, uint pixelBackground, uint pixelForeground, uint pixelCanvasAlpha) { byte surfaceR = (byte)((pixelForeground & 0x00FF0000) >> 16); byte surfaceG = (byte)((pixelForeground & 0x0000FF00) >> 8); byte surfaceB = (byte)((pixelForeground & 0x000000FF)); byte sourceR = (byte)((pixelBackground & 0x00FF0000) >> 16); byte sourceG = (byte)((pixelBackground & 0x0000FF00) >> 8); byte sourceB = (byte)((pixelBackground & 0x000000FF)); uint newR = sourceR * pixelCanvasAlpha / 256 + surfaceR * (255 - pixelCanvasAlpha) / 256; uint newG = sourceG * pixelCanvasAlpha / 256 + surfaceG * (255 - pixelCanvasAlpha) / 256; uint newB = sourceB * pixelCanvasAlpha / 256 + surfaceB * (255 - pixelCanvasAlpha) / 256; return (uint)255 << 24 | newR << 16 | newG << 8 | newB; }
0
0
0
0
1
0
I have one problem related to rotation of point in 3D-space. Suppose I have one point with X, Y and Z coordinates. And now I want to rotate it, by specifying the rotation in one of these three ways: By user-defined degree By user-defined axis of rotation Around (relative to) user-defined point I found good link over here, but it doesn't address point 3. Can anyone help me solve that?
0
0
0
0
1
0
I have a set of 60D shape context vectors. These were constructed using a sample of 400 edge points from a silhouette using 5 radial bins and 12 angular bins (thus, I have 400 shape context vectors of 60D). I would like to analyse just how descriptive these vectors are in representing the overall shape of the underlying silhouette. To do this, I would like to project the 60D shape context vectors back into 2D space and visually inspect the result -- what I am hoping to see is a set of points that roughly resemble the original silhouette's shape. An approach to do this is by projecting on the first two principal components (PCA). Based on my implementation, the projected points did not resemble the silhouette's shape. I can see two main reasons for this (assuming for the time being that my implementation is correct): (1) shape context is either not appropriate as a descriptor given the silhouettes, or it's parameters need to be better tuned (2) this analysis method is flawed / not valid. My question is whether this is the right approach for analysing the descriptiveness of shape contexts in relation to my silhouette's shape? If not, can someone please explain why and propose an alternative method? Thanks, Josh
0
0
0
1
0
0
I know that array operators have the precedence. Then the binary arthimetic operators * , / , % . Then + and - which they are low precedence. But I'm confused which one will java solve first in this example. And if we have 2 operators have the same priority, what operator will be used first in java? Thank you. int x = y = -2 + 5 * 7 - 7 / 2 % 5; If someone could solve this for me and explain to me part by part. Because this always confuses me in exams.
0
0
0
0
1
0
We need to build a model of the shop floor in which we can relate pixel coordinates(x, y) from camera images to the actual objects in the 3D space of the store. The camera images, which will act as sources for generating such a model, suffer from fish-eye distortions. Hence straight lines actually appear as curves in the camera images and the walls appear to meet each other at not exactly right angles. We are sub-dividing the region into polygons. Each polygon on the image refers to a particular region such as a shelf, display area, checkout counter etc. By mapping the pixels that fall in each polygon, we want to relate it as belonging to the shelf corresponding to that region. Any ideas how to go about it? Following is a sample image of the store with some polygons marked: EDIT: We are not looking to find out the 3D coordinates, we just need to know which shelf is any polygon mapped to. So if the user clicks on a polygon, we can say he clicked on which shelf. We are able to manage the above for big polygons like the ones shown in the image, but the shelves away from the camera can be as small as a few pixels so we need some kind of a probabilistic result saying if the user clicked at (x,y) what is the probability that he was trying to click on Shelf-A or what is the probability that he was trying to click on Shelf-B and so on. Basically, what we are looking for is a probability function which would return the probabilities of click on nearby objects when a small polygon(or a pixel) is clicked on the 2D image. EDIT2: One thing which is not apparent from the sample image is that the polygon size could be really small(as small as a few pixels) and polygons in turn could be really close to each other. Moreover, the use case is that a customer in the store picks a product from one of the shelves. The application user would click on a point in the image from which he thinks the products is picked up. Now since the polygons are so small and so close, the user can only guess the exact point of pickup, so we can only know at best that it could be any one of the 3-4 polygons close to the point of click. So the question is how to calculate probabilities for these 3-4 polygons given the click? As suggested here distance of the click from the center of polygon and its area could be parameters in calculation of this probability, what I am wondering is if there is algorithm to do so.
0
0
0
0
1
0
Say I'm given n=32. I want to know what log_2(n) is. In this case, log_2(32) = 5. What is the fastest way in general to compute the log of a 2^k number? I.e. Given n = 2^k. log_2(n) = b. Find b. Bitwise operations are permitted.
0
0
0
0
1
0
I'm implementing the system described within this paper, and I'm getting a little stuck. I only recently encountered tensors/eigenvalues etc so excuse me if this is a little simple! Given a 2x2 tensor, how can I calculate the major and minor eigenvectors of it? Bonus points for implementations which are easy to translate into C# ;)
0
0
0
0
1
0
I am creating a 3D sphere gallery with ActionScript 3 and the Flash 10 3D (2.5D) APIs. I have found a method that works but is not ideal. I would like to see if there is a better method. My algorithm goes like this: Let n = the number of images h = the height of each image w = the width of each image Approximate the radius of the circle by assuming (incorrectly) that the surface area of the images is equal to the surface area of the sphere we want to create.To calculate the radius solve for r in nwh = 4πr2. This is the part that needs to be improved. Calculate the angle between rows. rowAngle = 2atan(h / 2 / r). Calculate the number of rows.rows = floor(π / rowAngle). Because step one is an approximation, the number of rows will not fit perfectly, so for presentation add padding rowAngle.rowAngle += (π - rowAngle * rows) / rows. For each i in rows: Calculate the radius of the circle of latitude for the row.latitudeRadius = radius * cos(π / 2 - rowAngle * i. Calculate the angle between columns.columnAngle = atan(w / 2 / latitudeRadius) * 2. Calculate the number of colums.columns = floor(2 * π / columnAngle) Because step one is an approximation, the number of columns will not fit perfectly, so for presentation add padding to columnAngle.columnAngle += (2 * π - columnAngle * column) / column. For each j in columns, translate -radius along the Z axis, rotate π / 2 + rowAngle * i around the X axis, and rotate columnAngle * j around the Y axis. To see this in action, click here. alternate link. Notice that with the default settings, the number of items actually in the sphere are less by 13. I believe is the error introduced by my approximation in the first step. I am not able to figure out a method for determining what the exact radius of such a sphere should be. I'm hoping to learn either a better method, the correct method, or that what I am trying to do is hard or very hard (in which case I will be happy with what I have).
0
0
0
0
1
0
I've got a fairly simple formula, although it involves a large-ish number, which is basically this: $one = 1300391053; $two = 0.768; // $millitime = 1.30039116114E+12 $millitime = ($one+$two)*1000; I understand this is the technically correct answer but I'm expecting to get 1300391053768. The goal of this is to get the time in milliseconds. I could combine the two and remove the decimal although that feels a bit odd. Is there a way to get this to store 'properly' ? [ as as side note, it seems not all installations handle this the same. My local PHP install (v5.3 on MacOS) returns the sci notation, but I run the identical code writecodeonline.com and get what I'm expecting/wanting. ]
0
0
0
0
1
0
I'm writing a bot that will analyse posts and reply with a vaguely related strings from a database. I'm not aiming for coherence, just for vague similarity that could pass as someone ignorant to the topic (but knowledgeable enough to try to reply). What are some methods that would help me to choose the right reply? One thing I've come up with is to create a vocabulary list, check which elements of the list are in the post, and get a reply from the database based on these results. This crude method has been successful about 10% of the time (based on 100 replies to random posts). I might expand the list by more words, but this method has its limit. Any better ones? (P. S. The database is sizeable -- about 500 000 replies)
0
1
0
0
0
0
I wonder how to make a Math.random() function, or something similar where it chooses a number from 0-9. But as the program progresses, another random variable will appear. That random value is what I want removed from the 0-9 scale. (The other random variable is also from 0-9)
0
0
0
0
1
0
I'm writing an arbitrary precision rational number package, which I'll need to test for correctness and efficiency. Of course I could put together an ad hoc set of tests myself, but since I'm far from the first to be doing this, I figure it's worth asking: can anyone recommend an existing set of tests I could use? Edit: I ended up writing a test routine that each time around the loop, generates three random numbers and verifies that various arithmetic identities hold. It's found several bugs in the numeric code so far. Here's the actual code: for (i = 0;; i++) { mem = memlo; printf(fmtw "\r", i); a = rndnum(); b = rndnum(); c = rndnum(); // Equality test(eq(a, a)); test(!eq(a, b) || !eq(b, c) || eq(a, c)); // Addition test(eq(add(add(a, b), c), add(a, add(b, c)))); test(eq(add(a, b), add(b, a))); test(eq(add(a, zero), a)); // Subtraction test(eq(sub(add(a, b), b), a)); test(sub(a, a) == zero); test(eq(sub(a, b), add(a, sub(zero, b)))); // Multiplication test(eq(mul(mul(a, b), c), mul(a, mul(b, c)))); test(eq(mul(a, b), mul(b, a))); test(eq(mul(a, one), a)); test(eq(mul(a, add(b, c)), add(mul(a, b), mul(a, c)))); // Division test(b == zero || eq(div_(mul(a, b), b), a)); test(a == zero || div_(a, a) == (one)); test(b == zero || eq(div_(a, b), mul(a, div_(one, b)))); test(c == zero || eq(div_(sub(a, b), c), sub(div_(a, c), div_(b, c)))); // I/O test(eq(a, roundtrip(a))); }
0
0
0
0
1
0
I need to break a number down to be represented by a randomly ordered sequence of 2s and 3s. For example: 5 can be 3,2 or 2,3 6 can be 3,3 I'm currently doing this with a loop in ActionScript 3 but have been looking into the possibility of using some kind of mathematical formula to save me a few lines of code. I'm a bit of a sop when it comes to Math and I've not yet found anything suitable. Does anyone know if such a thing exists? Thanks, Crung
0
0
0
0
1
0
I've asked some questions here and seen this geometric shape mentioned a few times among other geodesic shapes, but I'm curious how exactly would I generate one about a point xyz?
0
0
0
0
1
0