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 understand that nltk can split sentences and print it out using the following code.
but how do i put the sentences into a list instead of outputing onto the screen?
import nltk.data
from nltk.tokenize import sent_tokenize
import os, sys, re, glob
cwd = './extract_en' #os.getcwd()
for infile in glob.glob(os.path.join(cwd, 'fileX.txt')):
(PATH, FILENAME) = os.path.split(infile)
read = open(infile)
for line in read:
sent_tokenize(line)
the sent_tokenize(line) prints it out. how do i put it into a list?
| 0 | 1 | 0 | 0 | 0 | 0 |
I have list of objects with OrderNum fields.
The OrderNum fields have to match the list order (but are not required to be continuous).
Easy solution. Reset every OrderNum when list order changes:
for (int i = 0; i < list.length; i++) {
list[i].OrderNum = i;
}
But as the OrderNum are stored in SQL, the smaller amount of OrderNum are reset, the better. When OrderNum have to be reset, the changes can be big. There are 32 bits to use. The ordered list is retrieved by:
SELECT * FROM orderable_items ORDER BY order_num;
The actual programming language is C#.
| 0 | 0 | 0 | 0 | 1 | 0 |
I have a simple graphing problem where I traverse a graph looking for an item. Each node in the graph has a probability n/100 of the item being there, where the sum of all the probabilities equals 1. How can I find the minimum expected time to search for the item in the entire graph?
The item is guaranteed to exist in only one node.
At first glance it seems like a traveling sales person problem and that is simple. Just get the permutations of the the paths and calculate the path for each and return the minimum.
But then it gets tricky when I need to find the minimum expected time. Is there any mathimatical formula that I could plug in on the minimal path to get the result?
ie: sum = 0
for node in path:
sum += node.prob * node.weight
Or is there something more complicated that needs to be done?
| 0 | 0 | 0 | 0 | 1 | 0 |
I want to create a worksheet addition of, say, two five digit numbers. Using text-decoration:underline;, I get something like the following:
12345
+ 12345
-------
Wrapping in a div and using
style="width: 8em; margin: 1em; font-family: courier; text-align: right;"
gives me something like the following:
12345
+ 12345
-------
which is marginally better than before. How would accomplish aligning the digits on the ones? To be clear, the digits will be the same length, but the best answer would be robust to two digits of size m and n where m does not necessarily equal n, but I'm willing to trade robustness for not requiring javascript.
12345
+ 12345
-------
^---- align the ones digit
Thanks in advance!
| 0 | 0 | 0 | 0 | 1 | 0 |
Given that I have two lists that each contain a separate subset of a common superset, is
there an algorithm to give me a similarity measurement?
Example:
A = { John, Mary, Kate, Peter } and B = { Peter, James, Mary, Kate }
How similar are these two lists? Note that I do not know all elements of the common superset.
Update:
I was unclear and I have probably used the word 'set' in a sloppy fashion. My apologies.
Clarification: Order is of importance.
If identical elements occupy the same position in the list, we have the highest similarity for that element.
The similarity decreased the farther apart the identical elements are.
The similarity is even lower if the element only exists in one of the lists.
I could even add the extra dimension that lower indices are of greater value, so a a[1] == b[1] is worth more than a[9] == b[9], but that is mainly cause I am curious.
| 0 | 0 | 0 | 1 | 0 | 0 |
I am working on building a Question Classification/Answering corpus as a part of my masters thesis. I'm looking at evaluating my expected answer type taxonomy with respect to inter-rater agreement/reliability, and I was wondering: Does anybody know of any decent (preferably free) Java API(s) that can do this?
I'm reasonably certain all I need is Fleiss' Kappa and Krippendorff's Alpha at this point.
Weka provides a kappa statistic in it's evaluation package, but I think it can only evaluate a classifier and I'm not at that stage yet (because I'm still building the data set and classes).
Thanks.
| 0 | 1 | 0 | 1 | 1 | 0 |
I am reading a C book. In the Arithmetic Expression section, they say:
"Division typically uses more resources. To avoid division, we multiply rather than divide. For example, we multiply by 0.5 rather than divide by 2.0."
Why Division typically uses more resources?. Can anyone give me a detail explanation, please?
Thanks a lot.
| 0 | 0 | 0 | 0 | 1 | 0 |
I have two convex polygons in 3D. They are both flat on different planes, so they're a pair of faces.
What's the simplest way to calculate the closest distance between these two polygons?
Edit: The length of the shortest possible line that has an endpoint in the first polygon and another other endpoint in the second polygon. The distance that I'm looking for is the length of this shortest possible line.
| 0 | 0 | 0 | 0 | 1 | 0 |
Is there any software that acts as an intersection between contemporary OWL/RDF reasoners, and the older STRIPS-style automated planners and schedulers? Both systems make use of RETE-based pattern matching, but only the automated planners seem to formalise the concept of an "action". Unfortunately, all the projects I've found that implemented automated planning, like Graphplan or SOAR, seem to be dead or dying, and never seemed to scale well to begin with. Current data stores are implemented on RDMS and can scale to and reason over millions of triples, but I haven't found any that specifically try and reason over actions. I can envision how the concept of actions might be represented in traditional RDF, but I'm sure it would still be very complicated and hackish without official support. Unfortunately, I can't find much prior art. Has this been done before?
| 0 | 0 | 0 | 1 | 0 | 0 |
What is the best way to implement a python program that will take a string and will output its result according to operator precedence (for example: "4+3*5" will output 19). I've googled for ways to solve this problem but they were all too complex, and I'm looking for a (relatively) simple one.
clarification: I need something slightly more advanced than eval() - I want to be able to add other operators (for example a maximum operator - 4$2 = 4) or, also I am more interested in this academically than professionaly - I want to know how to do this.
| 0 | 0 | 0 | 0 | 1 | 0 |
I did not really know on how to title this question so hopefully you've find the way in :)
My Problem is:
I wanted to set a clock time for a label with a UISlider.
So basically my slider min value is 0000 and the max value is 2400. (24 hour format)
So how do I achieve a properly formatted clock?
For example if my slider's value is at (1161)11:61 it should be (1201)12:01 and so on.
Any tipps for that :)
Would be great to get some help here.
Thanks to all who participate.
| 0 | 0 | 0 | 0 | 1 | 0 |
Given two vectors in three dimensions pointing different directions. I would like the first vector be able to change direction a set number of degrees towards the second vector. What is the formula or algorithm to calculate this new vector.
For example a space-ship (this is for a space-ship simulator) is pointing in the direciton of (2,3,3). The ship will now change direction 20 degrees in the direction to the vector of (2,-3,-2). What would the new vector be. It is not rotating along an axis, but rather at a right angle to both vectors.
| 0 | 0 | 0 | 0 | 1 | 0 |
I was asked an interview question where I needed to use it but I have no idea what it is.
So in plain english what is the Fast Fourier Transform and how can I use it to find the derivative of a function given its (x, y) values as input?
How would you implement it?
EDIT:
I am asking this because given a sequence of (x, y) values I needed to calculate how the function looks like, derive it and find the number of times it is constantly changing (that is, (0, 1), (1, 2) is counted as one) or does not change at all (0, 5), (1, 5) is also counted as one change).
| 0 | 0 | 0 | 0 | 1 | 0 |
Firstly, I'm not really looking for a mathematical solution to this problem, I'm looking for a library. This has been done a thousand times but my google-fu is failing.
Seconly, I have a rails 3 project (ruby 1.8.7 EE). Is there a ruby/rails library (gem) that will take in latitude and longitude (or alternatively a zip code) and determine what values, from a latitude/longitude set, are within X radial miles? Further, is there a way to run this at a lower level, for instance, as a performant SQL query?
Thanks!
| 0 | 0 | 0 | 0 | 1 | 0 |
This is basically just a math question.
Heres what I am having troubles with... I am having a difficult time coming up with how to phrase the question, so bear with me. Basically I think I need to use some advanced math to accomplish this, but I do not know what I need.
I will use some illustrations to make this clear. Spam prevention doesn't let me post pictures... Here's a simple concept image though: http://radleygh.com/images/gimp-2_2011-057-00-57-26-40.bmp
Objective: Determine if several objects lie within a cone on a 2D plane
Cone Properties:
Position (x, y)
Angle (0-359)
Spread (0-359, aka Width)
Distance (0++)
I can decide the brownish lines using a simple bit of math:
Angle_A = Angle + (Spread / 2)
Angle_B = Angle - (Spread / 2)
Angle_Target = Point_Direction(origin, object_position)
Now I thought of comparing these with the position of each object with a simple if/then statement:
If (Angle_A > Angle_Target) && (Angle_B < Angle_Target) Then Angle_Target is between A and B
This works... untill Angle_A or Angle_B pass the 0-360 threshold. 0* is between 45* and 315*... but the above if statement wouldn't work. We can then determine which direction to check based on the size of the cone...
And what if the cone effect is larger than a 180* cone?
I'm not sure of the answer. I'm pretty sure I should be using Radians... But I do not understand the concept of Radians. if someone can point me in the right direction, perhaps show me an example somewhere, that would be wonderful!
I will continue to do my own research in the mean time.
| 0 | 0 | 0 | 0 | 1 | 0 |
I'm scaling an image in css with transforms.
The scale goes from 0 to whatever, with 0 through 1 being smaller than the image.
I need to get the scale into negatives, so that 0 is the same size as the original, 1 is double the size, and -1 is half the size.
I have vars:
var cssScale, factorScale;
How to get cssScale into factorScale and vice versa?
Thanks.
| 0 | 0 | 0 | 0 | 1 | 0 |
I made a function that returns the smallest common divisor of 2 numbers.
int check (int a, int b)
{
int i = 2; //every number is divisible by 1
begin:
if ((a % i == 0) && (b%i == 0)) //i must be divisible by both numbers
{
return i;
}
else
{
i++;
goto begin;
}
}
However, I'm using the much-advised-against goto, so I was wondering how this could be rewritten using a for or while loop.
| 0 | 0 | 0 | 0 | 1 | 0 |
I'm trying to implement "Stochastic gradient descent" in MATLAB. I followed the algorithm exactly but I'm getting a VERY VERY large w (coffients) for the prediction/fitting function. Do I have a mistake in the algorithm ?
The Algorithm :
x = 0:0.1:2*pi // X-axis
n = size(x,2);
r = -0.2+(0.4).*rand(n,1); //generating random noise to be added to the sin(x) function
t=zeros(1,n);
y=zeros(1,n);
for i=1:n
t(i)=sin(x(i))+r(i); // adding the noise
y(i)=sin(x(i)); // the function without noise
end
f = round(1+rand(20,1)*n); //generating random indexes
h = x(f); //choosing random x points
k = t(f); //chossing random y points
m=size(h,2); // length of the h vector
scatter(h,k,'Red'); // drawing the training points (with noise)
%scatter(x,t,2);
hold on;
plot(x,sin(x)); // plotting the Sin function
w = [0.3 1 0.5]; // starting point of w
a=0.05; // learning rate "alpha"
// ---------------- ALGORITHM ---------------------//
for i=1:20
v = [1 h(i) h(i).^2]; // X vector
e = ((w*v') - k(i)).*v; // prediction - observation
w = w - a*e; // updating w
end
hold on;
l = 0:1:6;
g = w(1)+w(2)*l+w(3)*(l.^2);
plot(l,g,'Yellow'); // drawing the prediction function
| 0 | 1 | 0 | 1 | 0 | 0 |
Hi I'm trying to use the PET Parser, but the documentation given for usage is insufficient. Can anyone point me to a good article or tutorial on using PET? Does it support utf-8?
| 0 | 1 | 0 | 0 | 0 | 0 |
Does anybody have any pointers to Naive Bayes Classifier Implementation preferably in C. I have 5 dimensional binary dataset. The class labels are also binary. I used Naive Bayes Classifier in Matlab with good results. However, is there any machine learning algorithm and its implementation which allows me to infer data from the class labels? Here in this case I want five dimensional binary data inferred from a binary class label. A sample of data is [1 1 0 1 0] and class is 0.
| 0 | 0 | 0 | 1 | 0 | 0 |
I am using Jama matrix to perform SVD operations. I have couple of questions regarding performance.
I am not worried about so much accuracy, and I think double is more accurate than Float, am I right? If I use float other than double, how much will it improve the performance and reduce accuracy?
In Jama matrix it uses one function that it calls a lot, it used double and Math.abs function, that requires a lot of Heap and CPU. If I change it to double and remove Math.abs, how much will it impact the performance and results in terms of accuracy?
Here is the Jama math function:
public static double hypot(double a, double b) {
double r;
if (Math.abs(a) > Math.abs(b)) {
r = b/a;
r = Math.abs(a)*Math.sqrt(1+r*r);
} else if (b != 0) {
r = a/b;
r = Math.abs(b)*Math.sqrt(1+r*r);
} else {
r = 0.0;
}
return r;
}
Here is the what I am thinking to do with this function
public static float hypot(float a, float b) {
float r;
if (a > b) {
r = b/a;
r = (float) (a*Math.sqrt(1+r*r));
} else if (b != 0) {
r = a/b;
r = (float) (b*Math.sqrt(1+r*r));
} else {
r = 0;
}
return r;
}
I do not know, if it is a good way to do it or not.
Thanks
| 0 | 0 | 0 | 0 | 1 | 0 |
I am looking for free and open source spell checking libraries (could check whether spelling is correct for a given string, and any suggested corrections for a mis-spelled string), which could be easily integrated into Java program on Linux. English language spell checking is a must requirement,spell checking for other languages is a better to have requirement.
Any suggestions?
BTW: libraries for C/C++ is also ok.
| 0 | 1 | 0 | 0 | 0 | 0 |
I'm trying to get some python code I've written earlier on Windows to work on my DS. I'm using (DSPython), and when I tried to import math, it failed with "ImportError: No module named math". I've gotten most all other modules I need that don't rely on math working. But math is normally a builtin module, so I can't just find math.py on my PC and copy it over. Any suggestions on where I can find an alternative to the builtin math module that can still perform the same functions?
| 0 | 0 | 0 | 0 | 1 | 0 |
I am working on an app that involves drawing a line on my android screen based on its orientation and could use some help or pointers.
The line is drawn in the following way: If the phone is held flat then then the line shrinks and becomes a dot and as the phone is tilted and orientatated the line becomes bigger - ie the phone stood up and the line points down and is max magnitude of 9.8 and held flat it is a small dot. Crucialy no matter what angle the phone is held at the arrow allways points down- ie the line of gravity.
Now I figured out how to calculate the yaw pitch and roll angles of the phones but mathematically I am a bit lost on how to derive the vector of this line from this information - any pointers would be most welcome.
Thanks
| 0 | 0 | 0 | 0 | 1 | 0 |
As part of a synthetic noise generation algorithm, I have to construct on the fly a lot of large non-singular square matrices
a i,j (i,j:1..n) / ∀ (i,j) a i,j ∈ ℤ and 0 ≤ a i,j ≤ k and Det[a] ≠ 0
but the a i,j should also be random following a uniform distribution in [0, k].
In its current incarnation the problem has n ≅ 300, k≅ 100.
In Mathematica, I can generate random element matrices very fast, but the problem is that I must also check for singularity. I am currently using the Determinant value for this.
The problem is that this check, for the 300x300 matrices takes something near 2 seconds, and I can't afford that.
Of course I may construct the rows by selecting a random first row and then constructing successive orthogonal rows, but I'm not sure how to guarantee that those rows will have their elements following an uniform distribution in [0,k].
I am looking for a solution in Mathematica, but just a faster algorithm for generating the matrices is also welcome.
NB> The U[0,k] condition means that taken a set of matrices, each position (i , j) across the set should follow a uniform distribution.
| 0 | 0 | 0 | 0 | 1 | 0 |
The title for this one was quite tricky.
I'm trying to solve a scenario,
Imagine a survey was sent out to XXXXX amount of people, asking them what their favourite football club was.
From the response back, it's obvious that while many are favourites of the same club, they all "expressed" it in different ways.
For example,
For Manchester United, some variations include...
Man U
Man Utd.
Man Utd.
Manchester U
Manchester Utd
All are obviously the same club however, if using a simple technique, of just trying to get an extract string match, each would be a separate result.
Now, if we further complication the scenario, let's say that because of the sheer volume of different clubs (eg. Man City, as M. City, Manchester City, etc), again plagued with this problem, its impossible to manually "enter" these variances and use that to create a custom filter such that converters all Man U -> Manchester United, Man Utd. > Manchester United, etc. But instead we want to automate this filter, to look for the most likely match and converter the data accordingly.
I'm trying to do this in Python (from a .cvs file) however welcome any pseudo answers that outline a good approach to solving this.
Edit: Some additional information
This isn't working off a set list of clubs, the idea is to "cluster" the ones we have together.
The assumption is there are no spelling mistakes.
There is no assumed length of how many clubs
And the survey list is long. Long enough that it doesn't warranty doing this manually (1000s of queries)
| 0 | 1 | 0 | 0 | 0 | 0 |
I want to normalize a matrix, but if a column contains dates moth/day/year, how can I normalize, is it better to get rid of it?
| 0 | 0 | 0 | 0 | 1 | 0 |
Could anyone please tell me how to extract only the nouns from the following output:
I have tokenized and parsed the string "Give me the review of movie" based on a given grammar using following procedure:-
sent=nltk.word_tokenize(msg)
parser=nltk.ChartParser(grammar)
trees=parser.nbest_parse(sent)
for tree in trees:
print tree
tokens=find_all_NP(tree)
tokens1=nltk.word_tokenize(tokens[0])
print tokens1
and obtained the following output:
>>>
(S
(VP (V Give) (Det me))
(NP (Det the) (N review) (PP (P of) (N movie))))
(S
(VP (V Give) (Det me))
(NP (Det the) (N review) (NP (PP (P of) (N movie)))))
['the', 'review', 'of', 'movie']
>>>
Now I would like to only obtain the nouns. How do I do that?
| 0 | 1 | 0 | 0 | 0 | 0 |
I'm having a problem figuring out this problem, it is similar to combining sets of non-unique letters, but is slightly different.
Let k, m, and n be positive integers. We have nm balls, m colors, n balls, and k uniquely labeled bins. How many different ways are there to select n balls to put into the k bags?
For example, if m = 3, n = k = 2, the result is 21. There are 3 colors where we are choosing 2 balls out of the total 6 to place into 2 bins.
(-, WW), (-,WR), (-, WB) ...
(WW, -), (WR, -) ...
(W,W), (W,R) ...
(B,W), (B,R) ...
The normal version of this problem does not require the selection of a subset of the total elements. That problem yields n! / x1! x2! x3! ... where x1, x2, x3 are groups of duplicated letters.
correction (clarity) -> you have a total of nm balls. n balls of each color where there are m colors; from here you then choose n of these total nm balls randomly and place them into the k distinct bins.
| 0 | 0 | 0 | 0 | 1 | 0 |
I am creating a 2D sprite game in Unity, which is a 3D game development environment.
I have constrained all translation of objects to the XY-plane and rotation to the Z-axis.
My problem is that the meshes that are used to detect collisions between objects must still be in 3D. I have the need to detect collisions between the player object (a capsule collider) and a sprite (that has its collision volume defined by a polygonal prism).
I am currently writing the level editor and I have the need to let the user define the collision area for any given tile. In the image below the user clicks the points P1, P2, P3, P4 in that order.
Obviously the points join up to form a quadrilateral. This is the collision area I want, however I must then convert that to a 3D mesh. Basically I need to generate an extrusion of the polygon, then assign the vertex winding and triangles etc. The vertex positions is not a problem to figure out as it is merely a translation of the polygon down the z-axis.
I am having trouble creating an algorithm for assigning the winding order of the vertices, especially since the mesh must consist only of triangles.
Obviously the structure I have illustrated is not important, the polygon may be any 2d shape and will always need to form a prism.
Does anyone know any methods for this?
Thank you all very much for your time.
| 0 | 0 | 0 | 0 | 1 | 0 |
In python 3, are there any methods that would return just the decimal value after a division?
For example, if I divided 4 by 5 in this method, it would return 8.
| 0 | 0 | 0 | 0 | 1 | 0 |
Trying to write simple python script which will use NLTK to find and replace synonyms in txt file.
Following code gives me error:
Traceback (most recent call last):
File "C:\Users\Nedim\Documents\sinon2.py", line 21, in <module>
change(word)
File "C:\Users\Nedim\Documents\sinon2.py", line 4, in change
synonym = wn.synset(word + ".n.01").lemma_names
TypeError: can only concatenate list (not "str") to list
Here is code:
from nltk.corpus import wordnet as wn
def change(word):
synonym = wn.synset(word + ".n.01").lemma_names
if word in synonym:
filename = open("C:/Users/tester/Desktop/test.txt").read()
writeSynonym = filename.replace(str(word), str(synonym[0]))
f = open("C:/Users/tester/Desktop/test.txt", 'w')
f.write(writeSynonym)
f.close()
f = open("C:/Users/tester/Desktop/test.txt")
lines = f.readlines()
for i in range(len(lines)):
word = lines[i].split()
change(word)
| 0 | 1 | 0 | 0 | 0 | 0 |
Currently I have this code, and it works.
#include <stdio.h>
int isFactor(long number1, long number2)
{
int isitFactor = (number2 % number1 == 0)?1:0;
return isitFactor;
}
int isPerfect(int number)
{
int counter;
int sum;
for (counter = 1; counter < number; counter++)
if (isFactor(counter, number))
sum += counter;
return (sum == number);
}
int main()
{
int counter = 1;
for (counter = 1; counter <= 100; counter++)
{
printf("", isPerfect(counter));
if (isPerfect(counter))
printf("%d
", counter);
}
}
However, if I take out the unnecessary line with the printf in main(), it fails to produce any numbers.... Possible causes?!
| 0 | 0 | 0 | 0 | 1 | 0 |
I happened to debate with a friend during college days whether advanced mathematics is necessary for any veteran programmer. He used to argue fiercely against that. He said that programmers need only basic mathematical knowledge from high school or fresh year college math, no more no less, and that almost all of programming tasks can be achieved without even need for advanced math. He argued, however, that algorithms are fundamental & must-have asset for programmers.
My stance was that all computer science advances depended almost solely on mathematics advances, and therefore a thorough knowledge in mathematics would help programmers greatly when they're working with real-world challenging problems.
I still cannot settle on which side of the arguments is correct. Could you tell us your stance, from your own experience?
| 0 | 0 | 0 | 0 | 1 | 0 |
Why do we do it by multiplying the Row of first with the Column of second. What's the practical use of it and who invented it? Logically 4x2 means four times two or two times four. So why can be matrix multiplication just the dot product of corresponding elements?
It's one of the things that baffles me.
| 0 | 0 | 0 | 0 | 1 | 0 |
Need help to plot graphs:
Wt contains 1000 Iterators on how far one has walked the 100 steps. Mean and sd are the mean and standard deviation of those 1000. I am asked to create five graphs showing from the starting position to the end position after a hundred steps with time t on the x-axis and the status of the y-axis. t is 100.
Can someone explain and show how to plot graph like that?
Code for Wt:
Wt = NULL
for(i in 1:1000){
Xk = rnorm(100,mean=0.4,sd=0.7)
Wt[i]=sum(Xk)
}
mean(Wt)
sd(Wt)
| 0 | 0 | 0 | 0 | 1 | 0 |
Given two or more samples of text, specifically segments of code, what's the most efficient way of detecting where the samples differ and forming a pattern that matches each sample?
For example, given the following samples of code:
cd ~/workspaces/project/tmp1/bin
rsync --recursive --progress /data/local/documents* data
cd ~/workspaces/project/we32usZ/bin
rsync --recursive --progress /data/local/lib* data
cd ~/workspaces/project/oiususs/bin
rsync --recursive --progress /data/local/usr* data
How would I deduce this pattern (where $varN indicates a wildcard variable)?
cd ~/workspaces/project/$var1/bin
rsync --recursive --progress /data/local/$var2* data
My initial approach is to compare two samples, comparing each ith letter until a difference is found, afterwards searching for where the "variable" part of the text ends, and then repeat this for other samples. However, this seems very inefficient, and obviously assumes the texts are very similar to begin with. Is there a better way?
| 0 | 0 | 0 | 1 | 0 | 0 |
I'm having a problem with Math.atan returning the same value as the input.
public double inchToMOA( double in, double range){
double rangeIn = 36*range;
double atan = (in / rangeIn) * -1.0;
double deg = Math.atan(atan);
double moa = deg * 60;
return moa;
}
I had this all in one line, but I broke it down into different variables to see if I could find out why it wasn't working. if in = -10 and range = 300, then atan is about -.00094. The angle should be about -.053 degrees, but math.atan is returning -.00094, the same as the input.
Is my number too small for math.atan?
| 0 | 0 | 0 | 0 | 1 | 0 |
I'm wondering which algorithms are used to implement math functions from the java.lang.Math class?
For example, is sin(x)(or log(x)) implemented as sum of elements of Taylor series or any other algorithm?
| 0 | 0 | 0 | 0 | 1 | 0 |
I have some labels and attributes from text.
I am looking for patterns (combinations of key-value pairs that occur across many documents) of labels and attributes amongst these documents.
What kind of an algorithm and tool should I be looking into? I want to score these patterns based on relevance and importance and not just string matching.
Any kind of inputs would be great.
Thanks
| 0 | 0 | 0 | 1 | 0 | 0 |
I'm trying to split the japanese sentences up using RegexpTokenizer but it is returning null sets. can someone tell me why? and how to get split the japanese sentences up?
#!/usr/bin/python # -*- encoding: utf-8 -*-
import nltk
import os, sys, re, glob
from nltk.tokenize import RegexpTokenizer
jp_sent_tokenizer = nltk.RegexpTokenizer(u'[^ 「」!?。.)]*[!?。]')
print jp_sent_tokenizer.tokenize ('の各宣言を実行しておく必要があることに注意しよう。これ以下の節では、各スクリプト例の前にこれらがすでに宣言されていることを前提とする。')
the output to the above code is
[]
| 0 | 1 | 0 | 0 | 0 | 0 |
Possible Duplicates:
In C#: Math.Round(2.5) result is 2 (instead of 3)! Are you kidding me?
.Net Round Bug
I have a halfway value (number.5) and I need to specify how this will be rounded (upper or lower value.)
I understand the behaviour of Math.Round with the MidPointRounding parameter but that does not solve my problem:
// To Even
Console.WriteLine(Math.Round(4.4)); // 4
Console.WriteLine(Math.Round(4.5)); // 4
Console.WriteLine(Math.Round(4.6)); // 5
Console.WriteLine(Math.Round(5.5)); // 6
// AwayFromZero
Console.WriteLine(Math.Round(4.4)); // 4
Console.WriteLine(Math.Round(4.5)); // 5
Console.WriteLine(Math.Round(4.6)); // 5
Console.WriteLine(Math.Round(5.5)); // 6
// in one case I need
Console.WriteLine(Math.Round(4.4)); // 4
Console.WriteLine(Math.Round(4.5)); // 4
Console.WriteLine(Math.Round(4.6)); // 5
Console.WriteLine(Math.Round(5.5)); // 5
// another case I need
Console.WriteLine(Math.Round(4.4)); // 4
Console.WriteLine(Math.Round(4.5)); // 5
Console.WriteLine(Math.Round(4.6)); // 5
Console.WriteLine(Math.Round(5.5)); // 6
| 0 | 0 | 0 | 0 | 1 | 0 |
In my program I've create a mesh that look like this:
http://en.wikibooks.org/wiki/File:Blender3DNoobToPro-Creating_The_Canvas.jpg
And I want to get something like this:
http://en.wikibooks.org/wiki/File:Blender3DNoobToPro-Molding_the_Mountains_02.jpg
I create this mesh with this simple code
for (int i = -(xPlanesCount / 2); i < (xPlanesCount / 2); i++)
{
for (int j = -(yPlanesCount / 2); j < (yPlanesCount / 2); j++)
{
var xOffset = i * size;
var yOffset = j * size;
//code that create a plane
}
}
The question is... if I want to make a hill... how can I do that? I know the coordinates of "hill" top (for example x10 - y2), the radius of the hill is 2 planes and height of the hill is 10 pixels.
What calculation do I need to make to get this result?
http://en.wikibooks.org/wiki/File:Blender3DNoobToPro-Molding_the_Mountains_02.jpg
| 0 | 0 | 0 | 0 | 1 | 0 |
I'm doing some 'early computing' on a 32-bit Windows PC, and looking at the limits.
Now, 2**32 is 4,294,967,296, and I find that
4294967290 + 5
is perfectly OK, and
4294967290 + 6
quite properly overflows.
What puzzles me is that
429496729 * 10
overflows, although the product, 4294967290, is in range.
Anyone interested?
| 0 | 0 | 0 | 0 | 1 | 0 |
I'm trying to implement software which automatically detects nude images. Hoping to do this through openCV. What do you think of the possibility and the best algorithm that can be used? Any examples would be highly appreciated.
| 0 | 0 | 0 | 1 | 0 | 0 |
I'm creating an analog clock input method that users can use to pick a time. Users can click on the inner circle to set the short hand (hour) and can click on the outer circle to set the long hand (minute).
The problem is that users are free to click any point on the clock and therefor can pick an invalid position of the hands. Is there any way (algoritm) to detect this?
window.addEvent('domready', function()
{
var handLong = [10, 20, 30, 40, 50, 60, 70, 80];
var handShort = [10, 20, 30, 40, 50];
injectHands('clock', handShort, handLong);
$('clock').addEvent('click', function(e)
{
var x = correctX(e.page.x - e.target.getPosition().x, true);
var y = correctY(e.page.y - e.target.getPosition().y, true);
var angle = calculateAngle(x, y);
// grote wijzer positioneren
if (insideOuter(x, y))
{
moveHand(handLong, 'Long', angle);
}
// kleine wijzer positioneren
else if (insideInner(x, y))
{
moveHand(handShort, 'Short', angle);
}
});
});
// Valt punt (x, y) binnen een cirkel met middenpunt (x, y) en radius r
function insideCircle(pointX, pointY, circleX, circleY, radius)
{
dX = pointX - circleX;
dY = pointY - circleY;
return ((dX * dX) + (dY * dY)) <= (radius * radius);
}
// Valt punt (x, y) (enkel) binnen de buitenste cirkel (grote wijzer)
function insideOuter(pointX, pointY)
{
return !insideInner(pointX, pointY) && insideCircle(pointX, pointY, 0, 0, 100);
}
// Valt punt (x, y) (enkel) binnen de binnenste cirkel (grote wijzer)
function insideInner(pointX, pointY)
{
return insideCircle(pointX, pointY, 0, 0, 50);
}
// corrigeer x as (100 => 0) (0 => 100)
function correctX(x, nn)
{
if (nn)
{
return x - 100;
}
return x + 100;
}
// corrigeer y as (100 => 0) (0 => 100)
function correctY(y, nn)
{
if (nn)
{
return -y + 100;
}
return Math.abs(y - 100);
}
function calculateAngle(x, y)
{
if ((x >= 0) && (y >= 0))
{
return Math.atan(x / y) * (180 / Math.PI);
}
else if (((x >= 0) && (y < 0)) || ((x < 0) && (y < 0)))
{
return 180 + Math.atan(x / y) * (180 / Math.PI);
}
else if ((x < 0) && (y >= 0))
{
return 360 - Math.abs(Math.atan(x / y) * (180/ Math.PI));
}
}
function roundAngleByMinute(angle)
{
}
function calculateX(angle, hypotenuse)
{
return Math.sin((Math.PI / 180) * angle) * hypotenuse;
}
function calculateY(angle, hypotenuse)
{
return Math.cos((Math.PI / 180) * angle) * hypotenuse;
}
function injectHands(div, handShort, handLong)
{
for (var i = 0; i < handShort.length; i++)
{
$(div).grab(new Element('img', {src: 'images/red_8x8.png', class: 'hands handShort', id: 'handShort-' + handShort[i]}));
}
for (var i = 0; i < handLong.length; i++)
{
$(div).grab(new Element('img', {src: 'images/blue_8x8.png', class: 'hands handLong', id: 'handLong-' + handLong[i]}));
}
$(div).grab(new Element('img', {src: 'images/black_8x8.png', class: 'hands', id: 'hand-center'}));
$$('img.hands').hide();
$('hand-center').show();
}
function moveHand(hand, whichHand, angle)
{
for (var i = 0; i < hand.length; i++)
{
var hypotenuse = hand[i];
var x = calculateX(angle, hypotenuse) - 5;
var y = calculateY(angle, hypotenuse) + 5;
var left = correctX(x);
var top = correctY(y);
$('hand' + whichHand + '-' + hypotenuse).set('styles', {'left': left + 'px', 'top': top + 'px'});
}
$$('img.hand' + whichHand).show();
}
| 0 | 0 | 0 | 0 | 1 | 0 |
I'm developing an iPhone app.
I want to round a Float32 number like this 3.124 to this 3.12. Or a number like 4.2258 to 4.226.
How can I do that?
I want to hold this value on a Float32 variable or on a float variable.
| 0 | 0 | 0 | 0 | 1 | 0 |
I know that this is not exactly the right place to ask this question, but maybe a wise guy comes across and has the solution.
I'm trying to write a computer game and I need an algorithm to solve this question:
The game is played between 2 players. Each side has 1.000 dollars. There are three "boxes" and each player writes down the amount of money he is going to place into those boxes. Then these amounts are compared. Whoever placed more money in a box scores 1 point (if draw half point each). Whoever scores more points wins his opponents 1.000 dollars. Example game:
Player A: [500, 500, 0]
Player B: [333, 333, 334]
Player A wins because he won Box A and Box B (but lost Box C).
Question: What is the optimal strategy to place the money?
I have more questions to ask (algorithm related, not math related) but I need to know the answer to this one first.
Update (1): After some more research I've learned that these type of problems/games are called Colonel Blotto Games. I did my best and found few (highly technical) documents on the subject. Cutting it short, the problem I have (as described above) is called simple Blotto Game (only three battlefields with symmetric resources). The difficult ones are the ones with, say, 10+ battle fields with non-symmetric resources. All the documents I've read say that the simple Blotto game is easy to solve. The thing is, none of them actually say what that "easy" solution is.
Update (2): I wrote a small actionscript file to demonstrate the strategy in the paper mentioned by Tom Sirgedas. You can test it at megaswf. Instructions: Click a point inside the triangle. Red region represent winning cases. Blue region represents losing cases, tiny whitish lines represents draw.
| 0 | 0 | 0 | 0 | 1 | 0 |
This is a thing that puzzles me. I know that when you use Euler angles and apply rotations to objects you have to stick to one axis sequence, for example, XYZ, in order to avoid gimbal lock. My question is the reverse.
Imagine I have quaternions that I want to convert to Euler angles. So, I take all those quaternions and convert to a sequence of rotations to be applied on 3 axis in my object.
These are the questions:
if I follow conversions like the one shown in this Wikipedia page will I obtain angles that go from -PI to PI in all 3 axis?
now I have the angles, how do I know which order I should apply to the object?
do this formulas of Wikipedia imply that I must use a particular axis transformation sequence as XYZ or something?
is there a different formula for different axis sequences?
what I am looking for are the formulas to convert to the aeronautics notation sequence (see picture)
My math is a little bit rusty, so please don't make your answer too mathematically exoteric.
thanks in advance.
| 0 | 0 | 0 | 0 | 1 | 0 |
I'm writing a small application about image retrieval, but I can't understand what this mathematical expression means
d^2 = || x - p ||^2
where x and p are two-element vectors.
Can somebody tell me what means this ||, and how can I raise a vector to power ??
EDIT
Thanks to espertus answer I know that || x - p ||^2 is a euclidean distance. However I also came across this expression ||p||^2 . What would that mean ? I think that it can't be euclidean distance. What else could it be ?
| 0 | 0 | 0 | 0 | 1 | 0 |
I'm trying to compute this equation:
int n = 89;
int SUMx = 347762, SUMy = 4898, SUMxy = 19671265;
long long SUMxx = 1370329156;
printf("(float)(( SUMx*SUMy - n*SUMxy ) / ( SUMx*SUMx - n*SUMxx ) = %f
", (float)(( SUMx*SUMy - n*SUMxy ) / ( SUMx*SUMx - n*SUMxx )));
SUMxx used to be int, but doing n*SUMxx overflowed, so I changed it to long long. Now it is just giving me an answer of 0.000000 where I want it to be 0.0464.
How do I accomplish this? Is there some discrepancy where I need to change the other datatypes to long long as well?
Thank you :)
| 0 | 0 | 0 | 0 | 1 | 0 |
My requirement is to recognize and extract numerical data from a natural language sentence (English only) in response to queries. Platform is Java. For example if the user query is "What is the height of mount Everest" and we have a paragraph as:
In 1856, the Great Trigonometric Survey of British India established the first published height of Everest, then known as Peak XV, at 29,002 ft (8,840 m). In 1865, Everest was given its official English name by the Royal Geographical Society upon recommendation of Andrew Waugh, the British Surveyor General of India at the time, who named it after his predecessor in the post, and former chief, Sir George Everest.[4] Chomolungma had been in common use by Tibetans for centuries, but Waugh was unable to propose an established local name because Nepal and Tibet were closed to foreigners. (Pasted from wikipedia)
For a user query "Height of mount Everest" from the paragraph I need to get 29002 ft or 8840 m as the answer. Can anyone please suggest any possible ways of doing it in Java? Are there any open source libraries for the same?
| 0 | 1 | 0 | 0 | 0 | 0 |
I understand the principle behind this problem but it's giving me a headache to think that this is going on throughout my application and I need to find as solution.
double Value = 141.1;
double Discount = 25.0;
double disc = Value * Discount / 100; // disc = 35.275
Value -= disc; // Value = 105.824999999999999
Value = Functions.Round(Value, 2); // Value = 105.82
I'm using doubles to represent quite small numbers. Somehow in the calculation 141.1 - 35.275 the binary representation of the result gives a number which is just 0.0000000000001 out. Unfortunately, since I am then rounding this number, this gives the wrong answer.
I've read about using Decimals instead of Doubles but I can't replace every instance of a Double with a Decimal. Is there some easier way to get around this?
| 0 | 0 | 0 | 0 | 1 | 0 |
I'm building my first Genetic Algorithm in javascript, using a collection of tutorials.
I'm building a somewhat simpler structure to this scheduling tutorial http://www.codeproject.com/KB/recipes/GaClassSchedule.aspx#Chromosome8, but I've run into a problem with breeding.
I get a population of 60 individuals, and now I'm picking the top two individuals to breed, and then selecting a few random other individuals to breed with the top two, am I not going to end up with a fairly small amount of parents rather quickly?
I figure I'm not going to be making much progress in the solution if I breed the top two results with each of the next 20.
Is that correct? Is there a generally accepted method for doing this?
| 0 | 1 | 0 | 0 | 0 | 0 |
Given two lines of common origin point, whose rotational angles I have in degrees, what's the best way in Lua to calculate the reflex and obtuse angles involved?
| 0 | 0 | 0 | 0 | 1 | 0 |
I've successfully ran mahout lda, and displayed the ouput using the command mahout ldatopics.
For example my topics are science and sports. then the output will be like:
topic 0
basketball,
play,
baseball
topic 1
research,
study,
philosophy
My question now is how can I, identify the the individual article's group or cluster.
Is there an id number or some sort of tracking, so that for every new article that I add it will be grouped or added to a specific cluster/topic.
If I already have the cluster, what's the next step?
Thanks
| 0 | 0 | 0 | 1 | 0 | 0 |
So I've got an assignment that takes two inputs, males and females, and outputs matingPairs, the product of the two.
In addition to that, the instructions ask to draw a shape using one of those variables.
I've decided to draw circles for each value.
I first draw matingPairs, followed by the smaller male and female circles on top of the original, larger matingPairs circle.
The problem I'm running in to is obviously representing the graphic in the applet. If the numbers go higher than say 100, the graphic becomes too large for the applet.
I'm looking for a way to basically have the matingPairs circle always fill the applet, then have males and females dynamically adjust so their size is scaled relative to the matingPairs circle size. I'm using JApplet.
Thank you very much for any guidance. I'm really looking for a solution, rather a push in the right direction.
| 0 | 0 | 0 | 0 | 1 | 0 |
I am developing a CMD batch. I want to do some math in it. This formula: (x+1)100:y
So in batch, x = %x%, and y = %y%. I know how to set the variables. Now, how can batch calculate this? (WINDOWS CMD)
Do I need something extra?
(I need this to be available to users of Windows XP to 7.)
| 0 | 0 | 0 | 0 | 1 | 0 |
Several questions have been asked about the SIFT algorithm, but they all seem focussed on a simple comparison between two images. Instead of determining how similar two images are, would it be practical to use SIFT to find the closest matching image out of a collection of thousands of images? In other words, is SIFT scalable?
For example, would it be practical to use SIFT to generate keypoints for a batch of images, store the keypoints in a database, and then find the ones that have the shortest Euclidean distance to the keypoints generated for a "query" image?
When calculating the Euclidean distance, would you ignore the x, y, scale, and orientation parts of the keypoints, and only look at the descriptor?
| 0 | 0 | 0 | 1 | 0 | 0 |
Evaluate
(z x^-1 y)^5 y^5
~~~~~~~~~~~~~~~~~~~~~~~ OVER
x^-4 z^-4
How would I evaluate this if X = 10, y = -3 and z = 3? I would like a step-by-step solution to help me fully understand it.
| 0 | 0 | 0 | 0 | 1 | 0 |
Possible Duplicate:
How do you calculate the average of a set of angles?
If I have a set of bearings, ranging from 1-360, how can I find the average? Usually to find the average one would add them all up and divide by the number of items. The problem here is that doing that in the case of [1, 359], 2 bearings, would result in in 180, which in fact should be 360. Any ideas?
| 0 | 0 | 0 | 0 | 1 | 0 |
Does anyone know if there is a library for the iPhone that includes a Naïve Bayes Classifier?
| 0 | 0 | 0 | 1 | 0 | 0 |
I am working on a Windows application for one customer.
He wants to be able to enter the height, width and the length of a cardboard box, and then have the application automatically draw the cardboard box on the screen.
I want to know if that's possible to be done with C#.
Here is a sample how the cardboard box should look alike:
Please let me know your opinion and if anyone else did something similar in the past. Thanks in advance for any help.
| 0 | 0 | 0 | 0 | 1 | 0 |
Let's say I have a bunch of essays (thousands) that I want to tag, categorize, etc. Ideally, I'd like to train something by manually categorizing/tagging a few hundred, and then let the thing loose.
What resources (books, blogs, languages) would you recommend for undertaking such a task? Part of me thinks this would be a good fit for a Bayesian Classifier or even Latent Semantic Analysis, but I'm not really familiar with either other than what I've found from a few ruby gems.
Can something like this be solved by a bayesian classifier? Should I be looking more at semantic analysis/natural language processing? Or, should I just be looking for keyword density and mapping from there?
Any suggestions are appreciated (I don't mind picking up a few books, if that's what's needed)!
| 0 | 1 | 0 | 0 | 0 | 0 |
I would like to accomplish two things with this:
Select (any) cell from a grid, and give the 'bands' of neighboring cells an ever increasing value (in this example 1 -5)
From the selected cell, select the next cell in a spiral fashion as show in blue, also accounting for if the 'route' leave the grid.
How would I go about this?
| 0 | 0 | 0 | 0 | 1 | 0 |
Caveat: I'm using ColdFusion, but I feel this is could cover a broad range of languages, as this is more of a programming question, not just a ColdFusion question.
Ok, I have been tasked with implementing code to apply promotions to items in a shopping cart. Basically, there can be any number of promotions for any number of items - i.e. "Buy 2 of item 'ABC', get 1 of item 'ABC' 50% off". However, there can also be "buy 3 of item 'ABC', get 1 of item 'ABC' free". Or even "buy 2 of item 'ABC', get 1 of item 'XYZ' 50% off".
So, imagine there are more promotions running like this across a broad range of products.
Now, I need to run through every scenario possible to apply the promotion (or promotionS) that give the customer the best possible value (the lowest sub-total).
However, I cannot figure out how to write the code that will run through EVERY possible scenario. I am able to narrow the number of promotions that eligible, by filtering out those that do not apply to the items in the cart. Obviously, I also know the number of eligible items in the cart.
So, let's say I have 5 items in my cart, and 3 of those items have eligible promotions (such as those above). 1 item has 3 possible promotions, another has 4 possible promotions, another has 2 possible promotions. My first thought is, loop through each possible promotion, and within that loop, loop though each possible order of eligible items:
1-2-3
1-3-2
2-1-3
2-3-1
3-1-2
3-2-1
...and apply the promotions each time, saving the combination that produces the lowest sub-total.
Will this work? Is it overkill? Does anyone have a better suggestion?
Any code samples would be greatly appreciated. Although I'm programming this in ColdFusion, I can read/understand other languages just fine.
Thank you.
| 0 | 1 | 0 | 0 | 0 | 0 |
I have to make the solar system in openGL. The problem is that actual planet distances and sizes are so different that its difficult to draw. I was thinking there must be some way of 'compressing' a series of numbers so that the numbers become closer but their relative differences remain the same. So for instance on one end of the scale the numbers would be as they were, on the other end of the scale all the numbers would have converged on the same value. I know this is just a case of scaling and then adding/subtracting an amount but not sure how to proceed.
| 0 | 0 | 0 | 0 | 1 | 0 |
Please take a moment to understand my situation. If it is not comprehendable, please tell me in a comment.
I have an ArrayList of Waypoints. These waypoints are not in any order. A waypoint has the following properties:
{int type, float z, float y, float x, float rotation}
This applies to a 3 dimensional world, but since my pathfinding should not care about height (and thus treat the world as a 2 dimensional one), the y value is ignored. Rotation is not of importance for this question.
In this 2 dimensional world, the x represents the x axis and the z represents the y axis.
If x increases, the object in the world moves east. If x decreases, the object in the world moves west.
If z increases, the object in the world moves north. If z decreases, the object in the world moves south.
Thus, these "new" waypoints can be simplified to: waypoint = {float x, float y}.
Now, these waypoints represent the X-axis (x) and Y-axis (z) locations of an object. Moreover, there is a current location: curLocation = {float x, float y} and a target location: tarLocation = {float x, float y}.
This is what I want to get:
All combinations of waypoints (aka: paths or routes) that will lead from curLocation to tarLocation under the following strict conditions:
The distance inbetween each waypoint may not be bigger than (float) maxInbetweenDistance. This includes the initial distance from curLocation to the first waypoint and the distance from the last waypoint to tarLocation. If no such combination of waypoints is possible, null should be returned.
When multiple waypoints are found within maxInbetweenDistance from a waypoint that lead towards the target waypoint, the closest waypoint should be chosen (even better would be if an alternative waypoint that is slightly further away would result in a new path with a longer distance that is also returned).
The order of returned waypoint combinations (paths) should be from shortest route (minimum distance) to longest route (maximum distance)
Finally, please consider these points:
This is the only thing I need to do AI/pathfinding wise, which is why I do not wish to use a full blown pathfinding or AI framework. I believe one function should be able to handle the above.
If returning all possible combinations of waypoints causes too much overhead, it'd also be fine if one can specify a maximum amount of combinations (but still ordered from closest to furthest). Eg. the 5 closest paths.
How would I achieve this? Any feedback is appreciated.
| 0 | 1 | 0 | 0 | 0 | 0 |
I'm using libsvm library in my project and have recently discovered that it provides out-of-the-box cross validation.
I'm checking the documentation and it says clearly that I have to call svm-train with -n switch to use CV feature
.
When I call it with -v switch I cannot get a model file which is needed by svm-predict.
Implementing Support Vector Machine from scratch is beyond the scope of my project, so I'd rather fix this one if it is broken or ask the community for support.
Can anybody help with that?
Here's the link to the library, implemented in C and C++, and here is the paper that describes how to use it.
| 0 | 0 | 0 | 1 | 0 | 0 |
I have implemented a version of Rush Hour (the puzzle board game) in Python as a demonstration of some AI algorithms. The game isn't important, because the AI is relatively independent of its details: I've attempted to implement a version of iterative deepening depth first search in Python as follows (note that this code is almost directly copied from Russell and Norvig's AI text, 3rd edition, for those of you who know it):
def depth_limited_search(game, limit):
node = GameNode(game)
frontier = []
#frontier = Queue.Queue()
frontier.append(node)
#frontier.put(node)
frontier_hash_set = set()
frontier_hash_set.add(str(node.state))
explored = set()
cutoff = False
while True:
if len(frontier) == 0:
#if frontier.empty():
break
node = frontier.pop()
#node = frontier.get()
frontier_hash_set.remove(str(node.state))
explored.add(str(node.state))
if node.cost > limit:
cutoff = True
else:
for action in node.state.get_actions():
child = node.result(action)
if str(child.state) not in frontier_hash_set and str(child.state) not in explored:
if child.goal_test():
show_solution(child)
return child.cost
frontier.append(child)
#frontier.put(child)
frontier_hash_set.add(str(child.state))
if cutoff:
return 'Cutoff'
else:
return None
def iterative_deepening_search(game):
depth = 0
while True:
result = depth_limited_search(game, depth)
if result != 'Cutoff':
return result
depth += 1
The search algorithm, as implemented, does return an answer in a reasonable amount of time. The problem is that the answer is non-optimal. My test board of choice has an optimal answer in 8 moves, however this algorithm returns one using 10 moves. If i replace the lines above commented out lines with the commented lines, effectively turning the iterative deepening depth-first search into an iterative deepening breadth-first search, the algorithm DOES return optimal answers!
I've been staring at this for a long time now trying to figure out how a simple change in traversal order could result in nonoptimality, and I'm unable to figure it out. Any help pointing out my stupid error would be greatly appreciated
| 0 | 1 | 0 | 0 | 0 | 0 |
Having some difficulty doing translations for complicated neither...nor sentences.
With these characters:
~ Negation
V Disjunction
& Conjunction
I'm trying to translate and understand, for example:
"Neither John nor Mary are standing in front of either Jim or Cary"
I have been told that a successful translation of "Neither e nor a is to the right of c" is translated as follows: ~(RightOf(e, c) V RightOf(e, c))
What about just doing a translation on: "I like neither chocolate nor vanilla"
~(Like(chocolate) V Like(Vanilla))
Any food for thought would be appreciated.
| 0 | 0 | 0 | 0 | 1 | 0 |
I have a grid (not necessarily a square but I drew it as a square to simplify it) and certain values associated with each of the smaller squares. Given a circle of radius x, I am trying to find the region where the sum of the values is the maximum. The following picture will make it clear:
My guess here is that if a plane is divided into a grid using a large number of small squares, approximating the circle to a square will only lead in some over-approximation which is ok to me initially because I have not yet finalized how to address the case of a circle overlapping with a partial square (what would its value be?).
The simplest approach I can think of is brute-force: Start perhaps at the lower left and start moving in a zig-zag path until we hit the top-right and output the region with the maximum sum. I am fine with this approach but for large plane regions, there will be huge number of squares and at some might this approach might prove expensive. I am not sure if there is a better way of solving this problem but I would really appreciate if anyone had other thoughts on how to go about solving this.
| 0 | 1 | 0 | 0 | 0 | 0 |
I'm trying to make motion controller using the values from android sensors. Currently sending/receiving data to/from PC is almost done, and also already gone a trial to rotate cube using orientation sensor values, and it seemed usable.
The problem is, as orientation sensor uses magnetic sensor to calculate orientation, the actual values islikely to different from the desired values. For instance, one will expect the cube stays unrotated when he or she directs the controller straight to the PC monitor. Actually, cube will be rotated for such as (27, 59, 107), unless the PC is strictly placed on the north poll.
I've already searched for some references, but only I could found was remapping the reference by predefined constants, such as ROTATE_X_90.
Is there any way to remap reference coordinate by custom values?
| 0 | 0 | 0 | 0 | 1 | 0 |
I need to implement the harvesine distance in my java code.
I found this snippet in Javascript, and I need to convert it to java.
How can I convert latitude and longitude to radians in Java ?
Math.sin wants a double in Java. Should I pass the previously converted value in radians or not ?
Math.sin and Math.cos return long. Should I declare a as long and pass it to Math.sqrt or convert it to double ?
thanks
dLat = (lat2-lat1).toRad();
dLon = (lng2-lng1).toRad();
a = Math.sin(dLat/2) * Math.sin(dLat/2) +
Math.cos(lat1.toRad()) * Math.cos(lat2.toRad()) *
Math.sin(dLon/2) * Math.sin(dLon/2);
c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
d = R * c;
return d;
| 0 | 0 | 0 | 0 | 1 | 0 |
I need to perform division between integers in Java, and the result should be a float.
Could I just use / symbol for it? As in:
int integer1 = 1;
int integer2 = 2;
float quotient = integer1 / integer2; // Could I do this?
| 0 | 0 | 0 | 0 | 1 | 0 |
Can you please tell me how much is (-2) % 5?
According to my Python interpreter is 3, but do you have a wise explanation for this?
I've read that in some languages the result can be machine-dependent, but I'm not sure though.
| 0 | 0 | 0 | 0 | 1 | 0 |
I've figured out how to display the repeating part of a repeating decimal using OverBar.
repeatingDecimal doesn't actually work as a repeating decimal. I'd like to make a variation of it that looks and behaves like a repeating decimal.
Question
How could I make a working repeating decimal representation (possibly using Interpretation[])?
Background
Please excuse me if I ramble. This is my first question and I wanted to be clear about what I have in mind.
The following will "draw" a repeating decimal.
repeatingDecimal[q2_] :=
Module[{a},
a[{{nr__Integer}, pt_}] :=
StringJoin[
Map[ToString,
If[pt > -1, Insert[{nr}, ".", pt + 1],
Join[{"."}, Table["0", {Abs[pt]}], {nr}]]]];
(* repeating only *)
a[{{{r__Integer}}, pt_}] :=
Row[{".", OverBar@StringJoin[Map[ToString, {r}]]}];
(* One or more non-repeating;
more than one repeating digit KEEP IN THIS ORDER!! *)
a[{{nr__, {r__}}, pt_}] :=
Row[{StringJoin[
Map[ToString,
If[pt > -1, Insert[{nr}, ".", pt + 1],
Join[{"."}, Table["0", {Abs[pt]}], {nr}]]]],
OverBar@StringJoin[Map[ToString, {r}]]}];
(* One or more non-repeating; one repeating digit *)
a[{{nr__, r_Integer}, pt_}] :=
Row[{StringJoin[Map[ToString, {nr}]], ".",
OverBar@StringJoin[Map[ToString, r]]}];
a[RealDigits[q2]]]
So
repeatingDecimal[7/31]
displays a repeating decimal properly (shown here as a picture so that the OverBar appears).
Looking under the hood, it's really just an imposter, an image of a repeating decimal ...
In[]:= repeatingDecimal[7/31]//FullForm
Out[]:= Row[List[".",OverBar["225806451612903"]]]
Of course, it doesn't behave like a number:
% + 24/31
I'd like the addition to yield: 1
Edit: A cleaned up version of repeatingDecimal
Leonid showed how to wrap Format around the routine and to supply up-values for adding and multiplying repeated decimals. Very helpful! It will take some time for me to be comfortable with up and down values.
What follows below is essentially the streamlined version of the code suggested by Mr.Wizard. I set the OverBar above each repeating digit to allow line-breaking. (A single OverBar above Row looks tidier but cannot break when the right screen-margin is reached.)
ClearAll[repeatingDecimal]
repeatingDecimal[n_Integer | n_Real] := n
Format[repeatingDecimal[q_Rational]] := Row @ Flatten[
{IntegerPart@q, ".", RealDigits@FractionalPart@q} /.
{{nr___Integer, r_List: {}}, pt_} :> {Table[0, {-pt}], nr, OverBar /@ r}
]
repeatingDecimal[q_] + x_ ^:= q + x
repeatingDecimal[q_] * x_ ^:= q * x
repeatingDecimal[q_] ^ x_ ^:= q ^ x
The table below shows some output from repeatingDecimal:
n1 = 1; n2 = 15; ClearAll[i, k, r];
TableForm[Table[repeatingDecimal[i/j], {i, n1, n2}, {j, n1, n2}],
TableHeadings -> {None, Table[("r")/k, {k, n1, n2}]}]
Checking the solution: Operating with repeating decimals
Let's now check the addition and multiplication of repeating decimals:
a = repeatingDecimal[7/31];
b = repeatingDecimal[24/31];
Print["a = ", a]
Print["b = ", b]
Print["a + b = ", a, " + ", b, " = ", a + b]
Print["7/31 \[Times] 24/31 = " , (7/31)* (24/31)]
Print["a\[Times]b = ", a*b, " =
", repeatingDecimal[a*b]]
Print[N[168/961, 465]]
So addition and multiplication of repeating decimals work as desired. Power also appears to work properly.
Notice that 168/961 occupies 465 places to the right of the decimal point. After that, it starts to repeat. The results match those of N[168/961, 465], except for the OverBar, although line-breaks occur at different places. And, as is to be expected, this jibes with the following:
digits = RealDigits[168/961]
Length[digits[[1, 1]]]
Some effects of the Format[] wrapper on the behavior of N[] in summing repeated decimals
Mr.Wizard suggested that the Format wrapper is superfluous for the cases of Integers and Reals.
Let's consider how the following two additions
repeatingDecimal[7/31] + repeatingDecimal[24/31]
N@repeatingDecimal[7/31] + N@repeatingDecimal[24/31]
behave in four different cases:
Case 1: Results when Format wrapped around repeatingDecimals for Reals and Integers and up values are ON
As expected, the first addition yields an integer, the second a decimal.
Case 2: Results when Format NOT wrapped around repeatingDecimals for Reals and Integers but up values are ON
The Format wrapper around Reals and Integers doesn't affect the additions at hand.
Case 3: Results when Format wrapped around repeatingDecimals for Reals and Integers but up values are OFF
If upvalues are OFF, Format prevents addition from happening.
Case 4: Results when Format NOT wrapped around repeatingDecimals for Reals and Integers and up values are OFF
If upvalues are OFF and Format` NOT wrapped around repeatingDecimals for Reals and Integers , the second addition works as expected.
All the more reason to remove the Format wrapper for the case of reals and integers.
Anyone have any remarks about the different outcomes in Cases 3 and 4?
| 0 | 0 | 0 | 0 | 1 | 0 |
I'm searching the way to efficiently find the point on an edge which is the closest point to some other point.
Let's say I know two points which are vertices of the edge. I can calculate the equation of the line that crosses those points.
What is the best way to calculate the point on the edge which is the closest point to some other point in the plane.
I would post an image but I don't have enough reputation points.
| 0 | 0 | 0 | 0 | 1 | 0 |
Anyone know any good math functions that causes a lot of load on the CPU. I am wanting to create a simple program the just creates load for X amount of seconds while another program monitors it. I'm just looking for functions, not actual stress testing programs.
| 0 | 0 | 0 | 0 | 1 | 0 |
How can I make my C# applications self-aware?
e.g. able to read and write its own code and decide whether or not to bother to execute your commands.
Kindest Regards
| 0 | 1 | 0 | 0 | 0 | 0 |
Let's say we have numbers factors, for example 1260:
>>> factors(1260)
[2, 2, 3, 3, 5, 7]
Which would be best way to do in Python combinations with every subproduct possible from these numbers, ie all factorings, not only prime factoring, with sum of factors less than max_product?
If I do combinations from the prime factors, I have to refactor remaining part of the product as I do not know the remaining part not in combination.
I can also refine my divisors function to produce pairs of divisors instead of divisors in size order, but still it will cost me to do this for number with product upto 12000. The product must remain always the same.
I was linked to divisor routine, but it did not look worth the effort to prove them to adopt to my other code. At least my divisor function is noticably faster than sympy one:
def divides(number):
if number<2:
yield number
return
high = [number]
sqr = int(number ** 0.5)
limit = sqr+(sqr*sqr != number)
yield 1
for divisor in xrange(3, limit, 2) if (number & 1) else xrange(2, limit):
if not number % divisor:
yield divisor
high.append(number//divisor)
if sqr*sqr== number: yield sqr
for divisor in reversed(high):
yield divisor
Only problem to reuse this code is to link the divisors to factoring sieve or do some kind of itertools.product of divisors of the divisors in pairs, which I would give out as pairs instead of sorting to order.
Example results would be:
[4, 3, 3, 5, 7] (one replacement of two)
[5, 7, 36] (one replacement of three)
[3, 6, 14, 5] (two replacements)
Probably I would need some way to produce sieve or dynamic programming solutions for smaller divisors which could be linked to numbers whose divisors they are. Looks difficult to avoid overlap though. I do have one sieve function ready which stores biggest prime factor for each number for speeding up the factoring without saving complete factorings of every number... maybe it could be adapted.
UPDATE: The sum of factors should be near the product, so probably there is high number of factors of <= 10 in answer (upto 14 factors).
UPDATE2:
Here is my code, but must figure out how to do multiple removals recursively or iteratively for parts > 2 long and dig up the lexical partitioning to replace the jumping bit patterns which produce duplicates (pathetic hit count only for one replacement, and that does not count the passing of 'single element partionings' inside the single_partition):
from __future__ import print_function
import itertools
import operator
from euler import factors
def subset(seq, mask):
""" binary mask of len(seq) bits, return generator for the sequence """
# this is not lexical order, replace with lexical order masked passing duplicates
return (c for ind,c in enumerate(seq) if mask & (1<<ind))
def single_partition(seq, n = 0, func = lambda x: x):
''' map given function to one partition '''
for n in range(n, (2**len(seq))):
result = tuple(subset(seq,n))
others = tuple(subset(seq,~n))
if len(result) < 2 or len(others) == 0:
#empty subset or only one or all
continue
result = (func(result),)+others
yield result
if __name__=='__main__':
seen, hits, count = set(), 0, 0
for f in single_partition(factors(13824), func = lambda x: reduce(operator.mul, x)):
if f not in seen:
print(f,end=' ')
seen.add(f)
else:
hits += 1
count += 1
print('
Generated %i, hits %i' %(count,hits))
REFINEMENT I am happy to get only the factorings with max 5 factors in the non-prime factor parts. I have found by hand that non-decreasing arrangements for up to 5 same factors follow this form:
partitions of 5 applied to 2**5
1 1 1 1 1 2 2 2 2 2
1 1 1 2 2 2 2 4
1 1 1 3 2 2 8
1 2 2 2 4 4
1 4 2 16
2 3 4 8
THE SOLUTION
I do not remove the accepted answer from fine solution down, but it is over complicated for the job. From Project Euler I reveal only this helper function from orbifold of NZ, it works faster and without needing the prime factors first:
def factorings(n,k=2):
result = []
while k*k <= n:
if n%k == 0:
result.extend([[k]+f for f in factorings(n/k,k)])
k += 1
return result + [[n]]
The relevant solution for problem 88 of his run in Python 2.7 in 4.85 s by my timing decorator and after optimizing the stop condition by found counter 3.4 s in 2.6.6 with psyco, 3.7 s in 2.7 without psyco . Speed of my own code went from 30 seconds with code in accepted answer (sorting added by me removed) to 2.25 s (2.7 without psyco) and 782 ms with psyco in Python 2.6.6.
| 0 | 0 | 0 | 0 | 1 | 0 |
I'm calculating a ID for a grid cell like this:
id = x * 65536 + y;
Trying to calculate x and y for a ID I do this:
x = id / 65536;
y = id - (x * 65536);
This works, as long as Y is bigger than 0. If Y is negative, I have to calculate it like this:
x = (int)Math.Ceiling((double)id / 65536.0);
y = id - (x * 65536);
How do I know if I have to round up or down before knowing what y is? Is there a better way to generate one ID for a cell based on x and y? I feel like I'm missing something obvious, but after hours of tracking down strange errors to rounding problems, my brain is not working.
| 0 | 0 | 0 | 0 | 1 | 0 |
There are several ICA algorithms in use. Such as Fast-ICA algorithm, there is one developed by Jyh-Shing and Roger Jang called a fast-fixed point algorithm.
Do you know if there is an implementation or an example using this algorithm, maybe MATLAB?
| 0 | 1 | 0 | 1 | 0 | 0 |
I have tried the Orange Framework for Naive Bayesian classification.
The methods are extremely unintuitive, and the documentation is extremely unorganized. Does anyone here have another framework to recommend?
I use mostly NaiveBayesian for now.
I was thinking of using nltk's NaiveClassification but then they don't think they can handle continuous variables.
What are my options?
| 0 | 0 | 0 | 1 | 0 | 0 |
I am trying to solve these equations:
S := solve({ PVA1+PSA1+PPA1=1, PVA2+PSA2+PPA2=1, PVA3+PSA3+PPA3=1, PVA1*0.2+PVA2*0.5+PVA3*0.3=0.3, PSA1*0.2+PSA2*0.5+PSA3*0.3=0.2, PPA1*0.2+PPA2*0.5+PPA3*0.3=0.3}, Explicit=true) ;
But maple gives S := NULL. Any ideas? PS equations have some solutions.
| 0 | 0 | 0 | 0 | 1 | 0 |
Lets say you have website that keeps balance for each user. You give each user option to deposit money into their balance from PayPal, Amazon FPS, Authorize.NET eCheck and Credit Card and maybe couple of there once.
Each of the above companies charges fee. And since you are the receiver you are responsible for fees (except for Adaptive PayPal API there you can say who will pay the fees).
So lets say website user (sender) will deposit you $1000.00
And lets picker fee of 2.9% plus $0.30 fix fee = -$29.30
So the receiver (the website owner) ends up with $970.70
If you try to charge $1029.30 you end up with $999.1503
If you try to charge $1031.11 you end up with $1000.90781 which is acceptable (this is when the fee is increased by 0.181% to 3.081% + 0.30)
So this question is, what is the best way to calculate the 0.181% in Java method
I know this is more of math problem than Java problem but what would be the best algorithm to use for guessing the best fee percentage so the final value would get as close as possible to the final value of what the website user is try to deposit.
So the method should take the actual fee 2.9% (0.029 for multiplication), the fix fee 0.30 the amount the user is trying to deposit and figure out the final sum to be charged that would be as close as possible to the deposit amount.
The way I have been doing it is trying to increase the 2.9% until I hit slightly higher after the fees are subtracted.
UPDATE
As per bellow answers I coded up this method. Any further suggestions are more than welcome:
public static float includeFees(float percentageFee, float fixedFee, float amount) {
BigDecimal amountBD = new BigDecimal(amount);
BigDecimal percentageFeeBD = new BigDecimal(1-percentageFee);
BigDecimal fixedFeeBD = new BigDecimal(fixedFee);
return amountBD.add(fixedFeeBD).divide(percentageFeeBD, 10, BigDecimal.ROUND_UP)
.setScale(2, BigDecimal.ROUND_UP).floatValue();
}
| 0 | 0 | 0 | 0 | 1 | 0 |
I've got a c homework problem that is doing my head in and will be greatful if anyone can help point me in the right direction.
If I have two minutes points on an analog watch such as t1 (55 minutes) and t2 (7 minutes), I need to calculate the shortest amount of steps between the two points.
What I've come up with so far is these two equations:
-t1 + t2 + 60 =
-55 + 7 + 60
= 12
t1 - t2 + 60 =
55 - 7 + 60
= 108
12 is lower then 108, therefore 12 steps is the shortest distance.
This appears to work fine if I compare the two results and use the lowest. However, if I pick out another two points for example let t1 = 39 and t2 = 34 and plug them into the equation:
-t1 + t2 + 60 = -39 + 34 + 60 = 55
t1 - t2 + 60 = 39 - 34 + 60 = 35
35 is lower then 55, therefore 35 steps is the shortest distance.
However, 35 isn't the correct answer. 5 steps is the shorest distance (39 - 34 = 5).
My brain is a little fried, and I know I am missing something simple. Can anyone help?
| 0 | 0 | 0 | 0 | 1 | 0 |
I would like to derive a pattern that tells me when the door should be open and when closed. For instance, if the status spectrum refers to the front door and recorded data show that the first day it is opened for 1 minute at 9am, at 12 noon and at 6 pm, and that the second day it is opened for 1.5 mins at 9.30, 12.30, and 6.30, and the third day... similarly, then there should be derive a pattern where
the front door is opened for less than, say, two minutes every day between 9 and 10, between 12 and 1 pm, and between 6 and 7 pm (or something similar).
How to do it? Any algorithms? Can this be done using weka or other machine learning programs?
| 0 | 0 | 0 | 1 | 0 | 0 |
I've got a database with a 40k venues and growing right now.
Assuming I'm the red dot
I want to be able to retrieve the closest record as quickly as possible.
However the distance too the next item could be anything. And there also might be 0-n matches. But do I need to load all 40000 results when I'm just looking for 1?
How can I sort the records by distance? Should it be done in MYSQL, or PHP?
This calculation happens at almost every request, per user, per page, so the solution needs to be quick.
Edit Thanks for the quick and promising answers, I'll need to review these resources, and will accept/comment on answers within a few days.
| 0 | 0 | 0 | 0 | 1 | 0 |
I want to differentiate data vectors to find those that are similar. For example:
A=[4,5,6,7,8];
B=[4,5,6,6,8];
C=[4,5,6,7,7];
D=[1,2,3,9,9];
E=[1,2,3,9,8];
In the previous example I want to distinguish that A,B,C vectors are similar (not the same) to each other and D,E are similiar to each other. The result should be something like: A,B,C are similar and D,E are similar, but the group A,B,C is not similar to the group of D,E. Matlab can do this?
I was thinking using some classification algorithm or Kmeans,ROC,etc.. but I'm not sure which one will be the best one.
Any suggestion? Thanks in advance
| 0 | 0 | 0 | 0 | 1 | 0 |
I am working on a Dutch corpus and I want to know if NLTK has dutch grammar embedded in it so I can parse my sentences? In general does NLTK only work on English? I know that it has the Alpino dutch copora, but there is no indication that the functions (like parsing using CFGs) are made for Dutch also.
Thanks
| 0 | 1 | 0 | 0 | 0 | 0 |
Here is the problem:
var p:int = 0;
var n:Number = 0;
n = 32.999999999999999;
p = Math.floor(n);
trace(p); // returns 33
n = 32.11111111111111;
p = Math.floor(n);
trace(p); // returns 32
I would expect both of these to return 32. I have searched, and it seems this is an unreported bug in AS3. Or ... am I doing something wrong?
| 0 | 0 | 0 | 0 | 1 | 0 |
Prove by induction.Every partial order on a nonempty finite set at least one minimal element.
How can I solve that question ?
| 0 | 0 | 0 | 0 | 1 | 0 |
I am working on implementing a clustering algorithm in C++. Specifically, this algorithm: http://www.cs.uiuc.edu/~hanj/pdf/sigmod07_jglee.pdf
At one point in the algorithm (sec 3.2 p4-5), I am to calculate perpendicular and angular distance (d┴ and dθ) between two line segments: p1 to p2, p1 to p3.
It has been a while since I had a math class, I am kinda shaky on what these actually are conceptually and how to calculate them. Can anyone help?
| 0 | 0 | 0 | 0 | 1 | 0 |
static boolean isPrime(int n)
{
if(n<=1) return false;
if(n==2) return true;
if(n%2==0) return false;
int m = (int)Math.round(Math.sqrt(n));
for(int i=3; i <= m; i+=2)
if(n%i==0)
return false;
return true;
}
static boolean isHumble(int n)
{
for(int i = 2; i <= n; i++)
{
if (isPrime(i) && isFactor(n, i))
{
System.out.println(i);
//if(isPresent(i))
// return false;
//else return true;
return true;
}
}
return false;
}
static boolean isFactor(int val1, int val2)
{
return val1%val2==0;
}
static boolean isPresent(int n){
for(int val : prime_factors)
if(n==val)
return true;
return false;
}
// prime_factors {2,3,5,7}
I am implementing an isHumble function, but for some reason something seems to be off. Can anyone help me out please?
| 0 | 0 | 0 | 0 | 1 | 0 |
Maybe this is just obvious to everyone but can someone explain where XOR (or Exclusive-OR) got its name from? What does the word Exclusive really mean? Not that it matters, but its just stuck in my head since morning.
OR:
0 0 0
0 1 1
1 0 1
1 1 1
XOR:
0 0 0
0 1 1
1 0 1
1 1 0
Is it "exclusively 0 for inputs 1,1", "special version of OR" or something else?
| 0 | 0 | 0 | 0 | 1 | 0 |
I'm working with 2D Fourier transforms, and I have a method that will output the following result:
The code looks like this:
private Bitmap PaintSin(int s, int n)
{
Data = new int[Width, Height];
Bitmap buffer = new Bitmap(Width, Height);
double inner = (2 * Math.PI * s) / n;
BitmapData originalData = buffer.LockBits(
new Rectangle(0, 0, buffer.Width, buffer.Height),
ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
for (int i = 0; i < buffer.Width; i++)
{
for (int j = 0; j < buffer.Height; j++)
{
double val;
int c = 0;
if (j == 0)
{
val = Math.Sin(inner * i);
val += 1;
val *= 128;
val = val > 255 ? 255 : val;
c = (int)val;
Color col = Color.FromArgb(c, c, c);
SetPixel(originalData, i, j, col);
}
else
SetPixel(originalData, i, j, GetColor(originalData, i, 0));
Data[i, j] = c;
}
}
buffer.UnlockBits(originalData);
return buffer;
}
Now, I'm trying to think of a formula that will accept an angle and will out put an image where the solid lines are at the given angle.
For example, if I inputted 45 Degrees, the result would be:
Thank you for any help!
Here is the SetPixel code if that is needed:
private unsafe void SetPixel(BitmapData originalData, int x, int y, Color color)
{
//set the number of bytes per pixel
int pixelSize = 3;
//get the data from the original image
byte* oRow = (byte*)originalData.Scan0 + (y * originalData.Stride);
//set the new image's pixel to the grayscale version
oRow[x * pixelSize] = color.B; //B
oRow[x * pixelSize + 1] = color.G; //G
oRow[x * pixelSize + 2] = color.R; //R
}
| 0 | 0 | 0 | 0 | 1 | 0 |
I am a computer science student and I am going to work on an artificial intelligence project which will compose a musical tune according to the genre and mood inputs. Are the algorithms to be used for this project likely to be very resource-consuming? Would it make any difference (in terms of speed) if I choose to go with Java rather than C++? (Note : I know only these two languages and I am more comfortable with Java than C++.)
NB : Sorry for my poor English. If someone can, please clean up this post wherever necessary. Thanks.
| 0 | 1 | 0 | 0 | 0 | 0 |
I've coded up the FFT for a dataset I'm working with. My intent is to create a waterfall plot of the result, but the problem I'm running into is if I change my input data size, then I get a different number of frequency bins. Currently I'm just making my input dataset twice the size of the number of pixels I need to map to. I'm trying to figure out a way to map the frequency bins of any data set size to a specific number of pixels. For example, mapping an array of 500 values to an array that is 1250 elements long. It would be nice to have the option to perform linear and non-linear interpolation on the data mapping. I also might need to go the other way, say to map the values to an array that is 300 elements long. I'm not a math major and am coming up with a blank on this one.
| 0 | 0 | 0 | 0 | 1 | 0 |
If I'm given the Polar coordinates of a Fourier transform and I want to go back to the Cartesian (Real/Imaginary) coordiates, how would I go about doing that?
I'm able to get the Polar numbers from the Cartesian coordiates with the following code:
private double GetPhase(double real, double imaginary)
{
return Math.Atan2(imaginary, real);
}
private double GetMagnitude(double real, double imaginary)
{
return Math.Sqrt((real * real) + (imaginary * imaginary));
}
But how do I go back?
| 0 | 0 | 0 | 0 | 1 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.