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 need to use a classifier J48 in android. But running into heapspace problems. Is there a way to fix the same? I get an error that states. Dalvik format failed: Failed to convert dex. PermGen space.
| 0 | 0 | 0 | 1 | 0 | 0 |
I want a function which takes, as input, the number of seconds elapsed since the last time it was called, and returns true or false for whether an event should have happened in that time period. I want it such that it will fire, on average, once per X time passed, say 5 seconds. I also am interested if it's possible to do without any state, which the answer from this question used.
I guess to be fully accurate it would have to return an integer for the number of events that should've happened, in the case of it being called once every 10*X times or something like that, so bonus points for that!
| 0 | 0 | 0 | 0 | 1 | 0 |
I am writing a .py file that contains strings from multiple charactersets, including English, Spanish, and Russian. For example, I have something like:
string_en = "The quick brown fox jumped over the lazy dog."
string_es = "El veloz murciélago hindú comía feliz cardillo y kiwi."
string_ru = "В чащах юга жил бы цитрус? Да, но фальшивый экземпляр!"
I am having trouble figuring out how to encode my file to avoid generating syntax errors like the one below when my file is run:
SyntaxError: Non-ASCII character '\xc3' in file example.py on line 128, but no encoding
declared; see http://www.python.org/peps/pep-0263.html for details
I've tried adding # -*- coding: utf-8 -*- to the beginning of my file, but without any luck. I've also tried marking my strings as unicode (i.e. string_en = u'The quick brown fox jumped over the lazy dog."), again unsuccessfully.
Is it possible to include characters from different Python codecs in one file, or am I attempting to do something that is not allowed?
| 0 | 1 | 0 | 0 | 0 | 0 |
I'd like to take a shot at characterizing incoming documents in my app as either "well" or "poorly" written. I realize this is no easy task, but even a rough idea would be useful. I feel like the way to do this would be via naïve Bayes classifier with two classes, but am open to suggestions. So two questions:
is this method the optimal (taking into account simplicity) way to do this
assuming a large enough training db?
are there libraries in ruby
(or any integratable JRuby or
whatever) that i can plug into my
rails app to make this happen with little fuss?
Thanks!
| 0 | 1 | 0 | 1 | 0 | 0 |
Hi I've been doing some research about matrix inversion (linear algebra) and I wanted to use C++ template programming for the algorithm , what i found out is that there are number of methods like: Gauss-Jordan Elimination or LU Decomposition and I found the function LU_factorize (c++ boost library)
I want to know if there are other methods , which one is better (advantages/disadvantages) , from a perspective of programmers or mathematicians ?
If there are no other faster methods is there already a (matrix) inversion function in the boost library ? , because i've searched alot and didn't find any.
| 0 | 0 | 0 | 0 | 1 | 0 |
This question is an extension to the following one. The difference is that now our function to optimize will have higher order relations between elements:
We have an array of elements a1,a2,...aN from an alphabet E. Assuming |N| >> |E|.
For each symbol of the alphabet we define an unique integer priority = V(sym). Let's define V{i} := V(symbol(ai)) for the simplicity.
The task is to find a priority function V for which:
Count(i)->MIN | V{i} > V{i+1} <= V{i+2}
In other words, I need to find the priorities / permutation of the alphabet for which the number of positions i, satisfying the condition V{i}>V{i+1}<=V{i+2}, is minimum.
Maximum required abstraction (low priority for me). I guess once the solution model for the initial question is extended to cover the first part of this one, extending it farther (see below) will be easier.
Given a matrix of signs B of size MxK (basically B[i,j] is from the set {<,>,<=,>=}), find the priority function V for which:
Sum(for all j in range [1,M]) {Count(i)}->EXTREMUM | V{i} B[j,1] V{i+1} B[j,2] ... B[j,K] V{i+K}
As an example, find the priority function V, for which the number of i, satisfying V{i}<V{i+1}<V{i+2} or V{i}>V{i+1}>V{i+2}, is minimum.
| 0 | 0 | 0 | 0 | 1 | 0 |
I have an XML file containing some scientific text that I want to display as proper as possible as HTML. Within the XML I find some text that looks like a binary string, possibly produced by MathType.
An example of such a string is this one:
... are assumed to be independent and normally distributed as (0;σb2MathType@MTEF@5@5@+=feaafiart1ev1aaatCvAUfKttLearuWrP9MDH5MBPbIqV92AaeXatLxBI9gBaebbnrfifHhDYfgasaacH8akY=wiFfYdH8Gipec8Eeeu0xXdbba9frFj0=OqFfea0dXdd9vqai=hGuQ8kuc9pgc9s8qqaq=dirpe0xb9q8qiLsFr0=vr0=vr0dc8meaabaqaciaacaGaaeqabaqabeGadaaakeaaiiGacqWFdpWCdaqhaaWcbaGaemOyaigabaGaeGOmaidaaaaa@30E2@) and ...
Has anybody seen this format and knows how to read it in?
UPDATE 2011/02/15:
I should add to my question that I need to read in this data programmatically and if possible would like to convert it to TeX or similar. So the answers so far are going in the right direction but are not quite what I need to do yet. I will check out the SDK for sure.
| 0 | 0 | 0 | 0 | 1 | 0 |
I want to show some effect (animate) with the help of jQuery during the time that should be calculated based on how many results are found for a particular needle. The rule is that the effect should continue no longer than 5 minutes and at the very least be 5 seconds long.
So, here's what I do in particular. I search a database for a particular word the user inputs and count the results. Then I search a myself defined word in the same database and count the results. If there are more the latter results than the former results, I need to calculate how long to show the effect. The more the latter results found, the shorter the time the effect should continue. Plus, I need to obey the rule: no longer than 5 minutes, no less than 5 seconds.
I need that to be accurate at best.
That may be a stupid question but I cannot figure out on my own how to calculate the time! :)
| 0 | 0 | 0 | 0 | 1 | 0 |
So in my programming class we are learning to use draw classes. Basically draw a line and stuff and we did a y=mx+b line in class.
I wanted to jump ahead and start doing more crazy mathematical ones!
I'm having trouble using this one though, which I found on the U of Princeton website.
public class Spiral {
public static void main(String[] args) {
int N = Integer.parseInt(args[0]); // # sides if decay = 1.0
double decay = Double.parseDouble(args[1]); // decay factor
double angle = 360.0 / N;
double step = Math.sin(Math.toRadians(angle/2.0));
Turtle turtle = new Turtle(0.5, 0.0, angle/2.0);
for (int i = 0; i < 10*N; i++) {
step /= decay;
turtle.goForward(step);
turtle.turnLeft(angle);
}
}
}
import java.awt.Color;
public class Turtle {
private double x, y; // turtle is at (x, y)
private double angle; // facing this many degrees counterclockwise from the x-axis
// start at (x0, y0), facing a0 degrees counterclockwise from the x-axis
public Turtle(double x0, double y0, double a0) {
x = x0;
y = y0;
angle = a0;
}
// rotate orientation delta degrees counterclockwise
public void turnLeft(double delta) {
angle += delta;
}
// move forward the given amount, with the pen down
public void goForward(double step) {
double oldx = x;
double oldy = y;
x += step * Math.cos(Math.toRadians(angle));
y += step * Math.sin(Math.toRadians(angle));
StdDraw.line(oldx, oldy, x, y);
}
// pause t milliseconds
public void pause(int t) {
StdDraw.show(t);
}
public void setPenColor(Color color) {
StdDraw.setPenColor(color);
}
public void setPenRadius(double radius) {
StdDraw.setPenRadius(radius);
}
public void setCanvasSize(int width, int height) {
StdDraw.setCanvasSize(width, height);
}
public void setXscale(double min, double max) {
StdDraw.setXscale(min, max);
}
public void setYscale(double min, double max) {
StdDraw.setYscale(min, max);
}
// sample client for testing
public static void main(String[] args) {
double x0 = 0.5;
double y0 = 0.0;
double a0 = 60.0;
double step = Math.sqrt(3)/2;
Turtle turtle = new Turtle(x0, y0, a0);
turtle.goForward(step);
turtle.turnLeft(120.0);
turtle.goForward(step);
turtle.turnLeft(120.0);
turtle.goForward(step);
turtle.turnLeft(120.0);
}
}
Turtle uses this class: StdDraw which is just way too many lines of code for me to paste here.
I keep getting an error when I go to execute spiral:
java.lang.ArrayIndexOutOfBoundsException: 0
at Spiral.main(Spiral.java:4)
Not sure why. Can anyone help me out so I can play around with this?
| 0 | 0 | 0 | 0 | 1 | 0 |
I'm writing a course describing several topics of Artificial Intelligence. Currently I'm working on the "Constraint Processing" part. To illustrate constraint processing I would like to include a simple example. This examples should have the following qualities:
I want to draw an OR-tree so the example can't have that much variables and options
Illustrating node consistency, backtracking, backjumping, backmarking, weak relaxation and arc consistency. (The examples should illustrate that these methods make sense and add some value to constraint processing).
Easy to understand and represent. (Not a two page long array of constraints).
I have browsed the web for some time, but all examples by now don't meet these qualities. (I've also tried to simplify existing problems).
Are there any typical exampes to illustrate these methods/techniques? Giving two different examples and distribute the techniques between these two examples wouldn't be a problem too.
| 0 | 1 | 0 | 0 | 0 | 0 |
I have a 3 Dimentional point set (x,y,z).I need to project these points into 2 dimentional XY plane using orthogonal projection. so my question is, how to convert these points into 2D? is it correct if I make Z=0 only? If it is not correct please any one help me to slove this problem. Also I want to programming this in C++
| 0 | 0 | 0 | 0 | 1 | 0 |
Possible Duplicate:
Is JavaScript's Math broken?
Okay, I have this script:
var x = new Date;
setInterval(function() {
$("#s").text((new Date - x) / 60000 + "Minutes Wasted");
}, 30000);
It works perfectly fine. Except it sometimes gives me an answer like 4.000016666666666. How can I round that? If I have to rewrite the script, that is okay. Thanks!
| 0 | 0 | 0 | 0 | 1 | 0 |
I am making a simple game in HTML5 canvas, it involves driving a little car.
The up arrow moves the car, the left and right arrow steers it.
I have rotation sorted, but now it needs to move its x and y position when holding the up key, based on what angle it is at.
Example:
Angle is 0, the up arrow will only affect the y coordinate.
Angle is 45, the up arrow will affect both x and y coordinates at an equal pace.
What logic can I use if the angle is say, 32?
| 0 | 0 | 0 | 0 | 1 | 0 |
I'm using C and trying to get access to the constant M_PI (3.14159...). I have imported the math.h header file, but the M_PI constant was still undefined. Through some searching on StackOverflow I have found that I need to add #define _USE_MATH_DEFINES to my code (see example code below). This works fine when compiling normally, but I need to be able to compile with the std=c89 flag for the work that I'm doing.
How should I access M_PI from some C89 code?
| 0 | 0 | 0 | 0 | 1 | 0 |
Hey,
I'm writing a formula with three indexes i,j,k.
At the end of the line I'd like to put this:
i=1,...,a
j=1,...,b
k=1,...,n
But I'd like it in smaller font and stacked above each other. Can someone tell me a command which can accomplish this? \mbox can't do math mode, I think.
| 0 | 0 | 0 | 0 | 1 | 0 |
I have the following call to numpy.linalg.lstsq:
http://docs.scipy.org/doc/numpy/reference/generated/numpy.linalg.lstsq.html
x = [[ 0.69314718]
[ 1.09861229]
[ 1.38629436]
[ 1.60943791]
[ 1.79175947]
[ 1.94591015]]
y = [ 0. 0.20273255 0.5815754 0.7520387 0.96885669 1.09861229]
l = numpy.linalg.lstsq(x, y)
which returns
l -> tuple: (array([ 0.46323573]), array([ 0.25872885]), 1, array([ 3.63269497]))
Could somebody point out the equivalent function (if available) in
http://commons.apache.org/math/
(or possibly in some other Java math library ...)
| 0 | 0 | 0 | 0 | 1 | 0 |
Is there any software or service or AI program who can rebuild an English paragraph using different set of vocabulary, grammar rules etc.
I mean to say, if the source paragraph is
“Gwalior is a good tourist place near
to Jhansi. Jhansi is very famous due
their queen Rani Laxmi Bai
(Manikandana)”
Any software can generate its version or pattern like
“Rani Laxmi Bai (Manikandana) was the
queen of Jhansi which is nearer to a
good tourist palace Gwalior.”
Or something else. I know that 100% correctness is not possible until human intervention.
| 0 | 1 | 0 | 0 | 0 | 0 |
Ok, I agree, my math is rusty and it stinks and my brain is completely empty right now.
I have a function that delivers me angles in the range of 0 to 360 degrees (or 0 to 2PI if you prefer). When I use this function with the gyroscope data, I see that when it says the device is 270 degrees, it is in fact zero degrees. So, if I rotate it from 270 to 360, I need the angles to be varying from 0 to 90.
How do I convert this?
If I simply subtract 270 degrees from the values coming, I will end with negative angles and I don't want that. What I need is to shift the values so:
270 degrees... will become zero,
360 (=0)... will become 90,
90 will be 180 and
180 will be 270.
How do I shift that mathematically speaking.
thanks.
| 0 | 0 | 0 | 0 | 1 | 0 |
I have a list of sentences about 17 million. I need to identify sentence as spam/ham/unsure. Are there trained models present on the internet to which I could just feed in my data as a "test" set and the system would classify my sentence as spam/ham ?
Note: The sentences aren't e-mails.
| 0 | 0 | 0 | 1 | 0 | 0 |
I want to list top sellers items based on the sales history MySQL table:
sales(id,item)
----------------
1,Chocolate
2,Chocolate
3,Flowers
Will output:
Chocolate :: 2 Sales :: 67%
Flowers :: 1 Sales :: 33%
How to do that using php?
Thanks
| 0 | 0 | 0 | 0 | 1 | 0 |
This is more Maths related than a CS question, but I would like the answer in CS.
What I want to do is find a value relative to the max value. For instance say the value is 3. The max is 6. Therefore this value is 0.5 of the max value.
It can be implemented quite easily like this:
currentValue / max
However, say if now I have negatives.
Say the max is now -6 and the current value is -7. I would need to use the minimum value for this. So say the minimum value is -8. In this case, -7 will be 0.5 of -6.
However, how can I express finding the current value as an equation for negatives (using max and min)?
| 0 | 0 | 0 | 0 | 1 | 0 |
I have an image with two points, aligned something like this:
|----------------|
| |
| . |
| |
| . |
| |
|----------------|
I have both X, Y coordinates for both points and I need to rotate the image X degrees so it looks like this instead:
|----------------|
| |
| |
| . . |
| |
| |
|----------------|
Basically so they align next to eachother, what's the math for this? (A code example in C# would be even better but not required)
| 0 | 0 | 0 | 0 | 1 | 0 |
I asked about System.Double recently and was told that computations may differ depending on platform/architecture. Unfortunately, I cannot find any information to tell me whether the same applies to System.Decimal.
Am I guaranteed to get exactly the same result for any particular decimal computation independently of platform/architecture?
| 0 | 0 | 0 | 0 | 1 | 0 |
I have tried to find the 1st weekday from a specified date, but I have not figured out any solution, but I am thinking, that you can do something like strtotime("-x days", $time)
Just now I am using this method to calculate how many days to go back, but I want to know, if this can be optimized in any way
if ($i == 0)
return 6;
else
return $i-1;
Where $i is the numeric representation of the day of the week (same as PHP's date('w'))
I also need to find the last day of a week, but there I think, you can do
strtotime('+'.date('w', $dateTo).'days', $dateTo);
| 0 | 0 | 0 | 0 | 1 | 0 |
i need to run a program that classifies certain dataset values. on the computer i am using weka to classify the same and provide it to me but i need to implement the same on android. eclipse shuts down when i run the program(weka) by giving an error such as PermGen heap space. i read several forums and found the option of changing the value in the --launcher.XXMaxPermSize in the eclipse.ini file but i have not found any success. i just need to use the j48 classifier from weka, is there anything else existing that would do the work for me? or is there a workaround to fix the PermGen error in eclipse?
please guide.
| 0 | 0 | 0 | 1 | 0 | 0 |
Challenge located here
Okay so I figured out the number to call in I just don't understand what to do with the result (this could probably have something to do with my limited experince in mathamatics)
so I calc the first Prime fibonacci number larger than the one given over the phone
so lets call that number x
but now I don't under stand the "sum of the prime devisors +1"
as I understand it X is prime so there for the prime devisors are 1 and X
unless its (x+1) to then find the devisors (array D) then find the numbers in D that are prime (array Pd)
Pd1+Pd2= answer
Am I barking up the right tree?
My source code thus far ( I Can provide the is prime code if needed i assume its not)
private static long CalcPassword2(long p)
{
p++;
List<int> factors = new List<int>();
for (int i = 1; i <= p; i++)
{
if (p % i == 0)
if (isprime(i))
{
factors.Add(i);
}
}
if (factors.Count >= 2)
{
factors.Sort();
factors.Reverse();
return factors[0]+factors[1];
}
return 1;
}
| 0 | 0 | 0 | 0 | 1 | 0 |
This is more of a mathematical question than a programming question, but it still includes some programming.
This program scrapes the information from user lists on the IMDB website, and is supposed to display the most popular celebrity of all of the inputted lists. This works, just displays inaccurate results.
This is what I have:
public List<Star[]> stars = new List<Star[]>();
private void button1_Click(object sender, EventArgs e)
{
label1.Text = "Processing...";
stars.Add(ParseList(textBox1.Text));
label1.Text = "Waiting.";
treeView1.Nodes.Clear();
List<Star> strs = new List<Star>();
foreach (Star[] stlst in stars)
{
foreach (Star s in stlst)
{
bool inalrdy = false;
int index = 0;
for (int i = 0; i < strs.Count; i++)
{
if (s.Name == strs[i].Name)
{
inalrdy = true;
index = i;
break;
}
}
if (inalrdy)
{
strs[index].Points += s.Points;
}
else
{
strs.Add(s);
}
}
}
foreach (Star s in strs)
{
treeView1.Nodes.Add(s.Points + ". " + s.Name);
}
}
What would I do to have it rank them accurately even when there is never the same players?
This is very important to me and I would be very grateful for an answer.
| 0 | 0 | 0 | 0 | 1 | 0 |
Wondering if anybody could point me in the direction of academic papers or related implementations of heuristic approaches to finding the real meat content of a particular webpage.
Obviously this is not a trivial task, since the problem description is so vague, but I think that we all have a general understanding about what is meant by the primary content of a page.
For example, it may include the story text for a news article, but might not include any navigational elements, legal disclaimers, related story teasers, comments, etc. Article titles, dates, author names, and other metadata fall in the grey category.
I imagine that the application value of such an approach is large, and would expect Google to be using it in some way in their search algorithm, so it would appear to me that this subject has been treated by academics in the past.
Any references?
| 0 | 1 | 0 | 0 | 0 | 0 |
I am embarrassed to ask such question; but I haven't use math for a long time I can not recall many concepts learned many years ago.
In the url http://www.javadev.org/files/Ranking.pdf, an example is used for illustrate the page rank mechanism. The relation between page A, B, and C is A links to B and C, B links to C, and C links to A. So the PageRank equation is as below
Equation A)
PR(A) = 0.5 + 0.5 PR(C)
PR(B) = 0.5 + 0.5 (PR(A) / 2)
PR(C) = 0.5 + 0.5 (PR(A) / 2 + PR(B))
and it comes up with the result
Result B)
PR(A) = 14/13 = 1.07692308
PR(B) = 10/13 = 0.76923077
PR(C) = 15/13 = 1.15384615
My question is how Result B is derived from Equation A?
I try e.g. replacing PR(C) in equation PR(A)
PR(A) = 0.5 + 0.5 (0.5 + 0.5 (PR(A) / 2 + PR(B)))
this seems to end up with an infinite loop. So I am confused how it can derive the result e.g. PR(A) value is 1.07692308?
Appologize for such stupid question.
I appreciate any advice.
| 0 | 0 | 0 | 0 | 1 | 0 |
I wish to determine when a point (mouse position) in on, or near a curve defined by a series of B-Spline control points.
The information I will have for the B-Spline is the list of n control points (in x,y coordinates). The list of control points can be of any length (>= 4) and define a B-spline consisting of (n−1)/3 cubic Bezier curves. The Bezier curves are are all cubic. I wish to set a parameter k,(in pixels) of the distance defined to be "near" the curve. If the mouse position is within k pixels of the curve then I need to return true, otherwise false.
Is there an algorithm that gives me this information. Any solution does not need to be precise - I am working to a tolerance of 1 pixel (or coordinate).
I have found the following questions seem to offer some help, but do not answer my exact question. In particular the first reference seems to be a solution only for 4 control points, and does not take into account the nearness factor I wish to define.
Position of a point relative to a Bezier curve
Intersection between bezier curve and a line segment
EDIT:
An example curve:
e, 63.068, 127.26
29.124, 284.61
25.066, 258.56
20.926, 212.47
34, 176
38.706, 162.87
46.556, 149.82
54.393, 138.78
The description of the format is: "Every edge is assigned a pos attribute, which consists of a list of 3n + 1 locations. These are B-spline control points: points p0, p1, p2, p3 are the first Bezier spline, p3, p4, p5, p6 are the second, etc. Points are represented by two integers separated by a comma, representing the X and Y coordinates of the location specified in points (1/72 of an inch). In the pos attribute, the list of control points might be preceded by a start point ps and/or an end point pe. These have the usual position representation with a "s," or "e," prefix, respectively."
EDIT2: Further explanation of the "e" point (and s if present).
In the pos attribute, the list of control points might be preceded by a start
point ps and/or an end point pe. These have the usual position representation with a
"s," or "e," prefix, respectively. A start point is present if there is an arrow at p0.
In this case, the arrow is from p0 to ps, where ps is actually on the node’s boundary.
The length and direction of the arrowhead is given by the vector (ps −p0). If there
is no arrow, p0 is on the node’s boundary. Similarly, the point pe designates an
arrow at the other end of the edge, connecting to the last spline point.
| 0 | 0 | 0 | 0 | 1 | 0 |
This question: How to generate a random BigInteger describes a way to achieve the same semantics as Random.nextInt(int n) for BigIntegers.
I would like to do the same for BigDecimal and Random.nextDouble().
One answer in the above question suggests creating a random BigInteger and then creating a BigDouble from it with a random scale. A very quick experiment shows this to be a very bad idea :)
My intuition is that using this method would require the integer to be scaled by something like n-log10(R), where n is the number of digits of precision required in the output and R is the random BigInteger. This should allow the correct number of digits to be present so that (for example) 1 -> 10^-64 and 10^64 -> 1.
The scaling value also needs to be chosen correctly for the result to fall in the range [0,1].
Has anyone done this before, and do they know if the results are correctly distributed? Is there a better way to achieve this?
EDIT: Thanks to @biziclop for correcting my understanding of the scale argument. The above isn't necessary, a constant scale factor has the desired effect.
For later reference, my (apparently working code) is:
private static BigDecimal newRandomBigDecimal(Random r, int precision) {
BigInteger n = BigInteger.TEN.pow(precision);
return new BigDecimal(newRandomBigInteger(n, r), precision);
}
private static BigInteger newRandomBigInteger(BigInteger n, Random rnd) {
BigInteger r;
do {
r = new BigInteger(n.bitLength(), rnd);
} while (r.compareTo(n) >= 0);
return r;
}
| 0 | 0 | 0 | 0 | 1 | 0 |
JavaScript coordinates Sin, Cos or Tan?
I am trying to learn some basic trigonometry for game development in the web browser. I know the soh cah toa rule etc. I know we are also working between -1 and 1.
I am confused though, I need to work out x and y coordinates separately depending on an angle.
Here is what I have to work out the direction of my angle in x and y, which does work (Thanks to Loktar).
velY = -Math.cos(angle * Math.PI / 180) * thrust;
velX = Math.sin(angle * Math.PI / 180) * thrust;
What I understand from this is I am finding the cos of x and y based on a small formula to convert my angle variable to radians.
But, why does cos need to be used for x and sin for y? Where does tan come into this? Is this to do with the 4 quadrants of a circle?
How do I know when to use sin cos or tan when I am only given an angle and I need to work out where on a circle that angle places using x,y?
Any simple diagrams or explanations would be extremely helpful!
Thanks
| 0 | 0 | 0 | 0 | 1 | 0 |
I'm trying to delete records that has expired after 20 minutes, the column contains a timestamp which is time()+1200 (20 minutes forward).
When I execute this query:
$sql = "DELETE FROM " . SESSIONS_TABLE . "
WHERE session_expire >= " . time() . "
AND session_open = 1";
All of the records that has not passed the timestamp still get deleted... how come it's doing this?
| 0 | 0 | 0 | 0 | 1 | 0 |
Possible Duplicates:
Precision of Floating Point
Floating point arithmetic is too reliable.
Hi Guys,
I came across a rather strange looking problem, i am running a loop from 82.01 to 169.06 in steps of 0.01 but when i reach 128.01 and do (128.01+0.01) it gives 128.019999999998 instead of 128.02. I am using double for all these computations. If i use decimal to do these computations it works out fine, am i missing a very basic funda here, i found some articles and discussions on the web explaining that decimal is the correct data type to do these computations but still a basic computation like (128.01+0.01) should give correct results.
| 0 | 0 | 0 | 0 | 1 | 0 |
I have a list of numbers which form a series. I want to find the equation which can regenerate the same series. Is this possible? Also, what would you recommend to program it (GA, GP, etc). Please give an example.
| 0 | 0 | 0 | 0 | 1 | 0 |
I'm trying to build a basic heatmap based on points. Each point has a heat radius, and therefore is represented by a circle.
Problem is that the circle needs to be converted in a list of pixels colored based on the distance from the circle's center.
Finding it hard to find an optimal solution for many points, what I have for now is something similar to this:
for pixels in pixels:
if (pixel.x - circle.x)**2 + (pixel.y - circle.y)**2 <= circle.radius:
pixel.set_color(circle.color)
Edit:
data I have:
pixel at the center of the circle
circle radius (integer)
Any tips?
| 0 | 0 | 0 | 0 | 1 | 0 |
I was recently talking with someone in Resource Management and we discussed the problem of assigning developers to projects when there are many variables to consider (of possibly different weights), e.g.:
The developer's skills & the technology/domain of the project
The developer's travel preferences & the location of the project
The developer's interests and the nature of the project
The basic problem the RM person had to deal with on a regular basis was this: given X developers where each developers has a unique set of attributes/preferences, assign them to Y projects where each project has its own set of unique attributes/requirements.
It seems clear to me that this is a very mathematical problem; it reminds me of old optimization problems from algebra and/or calculus (I don't remember which) back in high school: you know, find the optimal dimensions for a container to hold the maximum volume given this amount of material—that sort of thing.
My question isn't about the math, but rather whether there are any software projects/libraries out there designed to address this kind of problem. Does anyone know of any?
| 0 | 0 | 0 | 0 | 1 | 0 |
I have following problem to solve. As as input i have 2 decimal arrays. Sum of elements of both of them is equal. Actuall problem is to assign values from one array to second one by partial sums - if some element from one array is a sum of any number of elements from second array - they should be assigned to each other.
Sample1:
Array1: 25.0, 25.0, 50.0, 50.0
Array2: 50.0, 100.0
Expected result: 50.0 is sum of 25.0 and 25.0, 100.0 is a sum of 50.0 and 50.0
(0->0,1; 1->2,3)
Sample2:
Array1: 20.0, 70.0, 80.0, 130.0
Array2: 100.0, 200.0
Expected result:
100 = 20+80, 200 = 70+130 (0->0,2; 1->1,3)
Idea is to return assigned array element indexes and return as less assingments as possible.
| 0 | 0 | 0 | 0 | 1 | 0 |
Unfortunately in this log I have there are some strings with that notation (1.00e4), I know I can use printf with the "%e" specifier to create that notation, how would I read it?
Unfortunately strtof and scanf seem to return 0.00000 on "1e100", would I need to write my own parser for this?
(updated)
What I have as input:
string "4.1234567e5", or "4.5e5"
Desired output:
float 412345.67, or integer "450000"
| 0 | 0 | 0 | 0 | 1 | 0 |
JavaScript returns .0009995003330834232.
Every other way of calculating returns 0.000434077479319.
| 0 | 0 | 0 | 0 | 1 | 0 |
A simple question best asked with two lines of code:
CGFloat answer = (abs(-27.460757f) - 9.0f) * (800.0f / (46.0f - 9.0f));
NSLog(@"According to my calculator, answer should be 399.15, but instead it is: %f", answer);
When I run this in Xcode (specifically, in the iPhone simulator), I get:
According to my calculator, answer
should be 399.15, but instead it is:
389.189209
Is this just due to my lack of understanding of how floats are rounded?
Thanks!
Stewart
| 0 | 0 | 0 | 0 | 1 | 0 |
Sorry for unclear title, but I don't know how to state it properly (feel free to edit), so I will give example:
sqrt(108) ~ 10.39... BUT I want it to be like this sqrt(108)=6*sqrt(3) so it means expanding into two numbers
So that's my algorithm
i = floor(sqrt(number)) //just in case, floor returns lowest integer value :)
while (i > 0) //in given example number 108
if (number mod (i*i) == 0)
first = i //in given example first is 6
second = number / (i*i) //in given example second is 3
i = 0
i--
Maybe you know better algorithm?
If it matters I will use PHP and of course I will use appropriate syntax
| 0 | 0 | 0 | 0 | 1 | 0 |
I have 5 different values which are saved as bits like 10010.
I get the value as an Int from the Database (cannot change that) so like 24 means 11000
I know that i can get the biggest bit here by using
if ((decbin($d) & 16) == 16)
but if the first is 0 i would have to check the next bit, and if that is 0 i would have to ...
So after all i would have a block of ifs and if there were more bits the block was bigger.
Is there a simple way to just get the "id" (or value, would not matter) of the highest bit with a 1?
| 0 | 0 | 0 | 0 | 1 | 0 |
Sure, this isn't a programming question, per se... but I couldn't think of a better place to ask it all the same.
I'm writing an application that ultimately will assist a shopped to determine how to achieve the greatest savings on a specific site. The site provides two prices for just about every product - a regular price and a discounted price. The discounted price is available to anyone, but only one discounted item can be added to any given order. With just that information, the incentive is to minimize your order siz and instead place multiple orders. On the other hand, the total shipping costs are determined by the order size (by weight) and so the incentive there is to maximize the order size and place just one order.
I'm looking for a model to determine the most efficient way to balance the orders given the available discount for one item and the weight's influencing the shipping costs for the order(s).
I'm remembering back to school enough that I think this is a linear programming problem... but all I can remember about that class was how confusing it was.
Anyone have any tips on how to go about the math for this program?
| 0 | 0 | 0 | 0 | 1 | 0 |
I have created a puzzle which is a derivative of the travelling salesman problem, which I call Trace Perfect.
It is essentially an undirected graph with weighted edges. The goal is to traverse every edge at least once in any direction using minimal weight (unlike classical TSP where the goal is to visit every vertex using minimal weight).
As a final twist, an edge is assigned two weights, one for each direction of traversal.
I create a new puzzle instance everyday and publish it through a JSON interface.
Now I know TSP is NP-hard. But my puzzles typically have only a good handful of edges and vertices. After all they need to be humanly solvable. So a brute force with basic optimization might be good enough.
I would like to develop some (Javascript?) code that retrieves the puzzle from the server, and solves with an algorithm in a reasonable amount of time. Additionally, it may even post the solution to the server to be registered in the leader board.
I have written a basic brute force solver for it in Java using my back-end Java model on the server, but the code is too fat and runs out of heap-space quick, as expected.
Is a Javascript solver possible and feasible?
The JSON API is simple. You can find it at: http://service.traceperfect.com/api/stov?pdate=20110218 where pdate is the date for the puzzle in yyyyMMdd format.
Basically a puzzle has many lines. Each line has two vertices (A and B). Each line has two weights (timeA for when traversing A -> B, and timeB for when traversing B -> A). And this should be all you need to construct a graph data structure. All other properties in the JSON objects are for visual purposes.
If you want to become familiar with the puzzle, you can play it through a flash client at http://www.TracePerfect.com/
If anyone is interested in implementing a solver for themselves, then I will post detail about the API for submitting the solution to the server, which is also very simple.
Thank you for reading this longish post. I look forward to hear your thoughts about this one.
| 0 | 0 | 0 | 0 | 1 | 0 |
Given are two arrays a and b both of length M . Given also is a binary relation R.
Specify formally a program to determine whether corresponding elements of a and b are all related by relation R.
| 0 | 0 | 0 | 0 | 1 | 0 |
I've been working weka for couple of months now.
Currently, I'm working on my machine learning course here in Ostfold University College.
I need a better way to construct a decision tree based on separated training and test sets.
Anybody come up with good idea can be of very great relief.
Thanx in advance.
-Neo
| 0 | 0 | 0 | 1 | 0 | 0 |
I have integrated the RSS Reader in my application.
How do I grab the Webpage with the RSS Feed URL?
Is there any free api which does this directly in Java using the URL?
I have to process the content of the webpage (news articles to be precise) and do some algorithmic stuff with that.
The problem now is to do a small part of Crawler. Is there any free light weight api's?
| 0 | 1 | 0 | 0 | 0 | 0 |
I'm using Eclipse to write math related programs.
I want to make code more understandable, especially math code, using images representing my math code in for example LaTex formulas.
I know how to translate my math code into MathML and then into picture, so the main problem is inserting images.
Hope for answers.
| 0 | 0 | 0 | 0 | 1 | 0 |
I have the center (xyz - in 3 dimensional space) and the radius of two spheres A and B.
Now I have to figure out a point or more than 1 point where these spheres meet. It is fairly easy to figure out if the two spheres collide or not, but how do I find out the points of intersection of 2 spheres?
Any help would be greatly appreciated.
| 0 | 0 | 0 | 0 | 1 | 0 |
Do you know an algorithm that calculates SVD using BLAS or LAPACK?
Lets say I have a symmetric Matrix A:
1 22 13 14
22 1 45 24
13 45 1 34
14 24 34 1
After I get the upper triangular Matrix G from A:
1 22 13 14
0 1 45 24
0 0 1 34
0 0 0 1
How do I calculate SVD of A, but with the values of G?
Do I have to pass all of matrix A or is sufficient to pass G (the middle matrix)?
In fact, I get after processing G matrix, but as its symmetric, how do I compute SVD of symmetric A, having only G (in other words, only having A´s upper triangular matrix)?
| 0 | 0 | 0 | 0 | 1 | 0 |
I found a tool for anophora resolution named as guitar.
http://cswww.essex.ac.uk/Research/nle/GuiTAR/
I can find that the tool solves anaphora for the example they have given, but ehrn i try to execute the script, it asks for ltchunk script which is nowhere available on net.. can anyone please tell me how to use this tool or any other simple anaphoora resolution tool.. please..
code:
cat $1 |
java -cp gtar1.1.jar uk.ac.essex.malexa.nlp.dp.GuiTAR.txtToXML.StringReplacer "\[\[" "@|" |
java -cp gtar1.1.jar uk.ac.essex.malexa.nlp.dp.GuiTAR.txtToXML.StringReplacer "\]\]" "|@" |
java -cp gtar1.1.jar uk.ac.essex.malexa.nlp.dp.GuiTAR.txtToXML.StringReplacer "\(\(" "@~" |
java -cp gtar1.1.jar uk.ac.essex.malexa.nlp.dp.GuiTAR.txtToXML.StringReplacer "\)\)" "~@" |
java -cp gtar1.1.jar uk.ac.essex.malexa.nlp.dp.GuiTAR.txtToXML.StringReplacer "\(" "~~~" |
java -cp gtar1.1.jar uk.ac.essex.malexa.nlp.dp.GuiTAR.txtToXML.StringReplacer "\)" "~~" |
java -cp gtar1.1.jar uk.ac.essex.malexa.nlp.dp.GuiTAR.txtToXML.StringReplacer "\[" "@@@" |
java -cp gtar1.1.jar uk.ac.essex.malexa.nlp.dp.GuiTAR.txtToXML.StringReplacer "\]" "@@" |
ltchunk -show_tags |
java -cp gtar1.1.jar uk.ac.essex.malexa.nlp.dp.GuiTAR.txtToXML.StringReplacer "\[\[" "<ne>" |
java -cp gtar1.1.jar uk.ac.essex.malexa.nlp.dp.GuiTAR.txtToXML.StringReplacer "\]\]" "</ne>" |
java -cp gtar1.1.jar uk.ac.essex.malexa.nlp.dp.GuiTAR.txtToXML.StringReplacer "\(\(" "<ve>" |
java -cp gtar1.1.jar uk.ac.essex.malexa.nlp.dp.GuiTAR.txtToXML.StringReplacer "\)\)" "</ve>" |
java -cp gtar1.1.jar uk.ac.essex.malexa.nlp.dp.GuiTAR.txtToXML.StringReplacer "@\|" " [_( [_( " |
java -cp gtar1.1.jar uk.ac.essex.malexa.nlp.dp.GuiTAR.txtToXML.StringReplacer "\|@" " ]_) ]_) " |
java -cp gtar1.1.jar uk.ac.essex.malexa.nlp.dp.GuiTAR.txtToXML.StringReplacer "@~" " (_( (_( " |
java -cp gtar1.1.jar uk.ac.essex.malexa.nlp.dp.GuiTAR.txtToXML.StringReplacer "~@" " )_) )_) " |
java -cp gtar1.1.jar uk.ac.essex.malexa.nlp.dp.GuiTAR.txtToXML.StringReplacer "~~~" " (_( " |
java -cp gtar1.1.jar uk.ac.essex.malexa.nlp.dp.GuiTAR.txtToXML.StringReplacer "~~" " )_) " |
java -cp gtar1.1.jar uk.ac.essex.malexa.nlp.dp.GuiTAR.txtToXML.StringReplacer "@@@" " [_( " |
java -cp gtar1.1.jar uk.ac.essex.malexa.nlp.dp.GuiTAR.txtToXML.StringReplacer "@@" " ]_) " |
java -cp gtar1.1.jar uk.ac.essex.malexa.nlp.dp.GuiTAR.txtToXML.StringReplacer "\._\." " ._. " |
java -cp gtar1.1.jar uk.ac.essex.malexa.nlp.dp.GuiTAR.txtToXML.StringReplacer "\?_\." " ?_. " |
java -cp gtar1.1.jar uk.ac.essex.malexa.nlp.dp.GuiTAR.txtToXML.StringReplacer "\!_\." " !_. " |
java -cp gtar1.1.jar uk.ac.essex.malexa.nlp.dp.GuiTAR.txtToXML.StringReplacer "\;_:" " ;_: " |
java -cp gtar1.1.jar uk.ac.essex.malexa.nlp.dp.GuiTAR.txtToXML.StringReplacer "\:_:" " :_: " |
java -cp gtar1.1.jar uk.ac.essex.malexa.nlp.dp.GuiTAR.txtToXML.StringReplacer \"_ " "\"_ |
java -cp gtar1.1.jar uk.ac.essex.malexa.nlp.dp.GuiTAR.txtToXML.StringReplacer "'_" " '_" |
java -cp gtar1.1.jar uk.ac.essex.malexa.nlp.dp.GuiTAR.txtToXML.StringReplacer "'s_" " 's_" |
java -cp gtar1.1.jar uk.ac.essex.malexa.nlp.dp.GuiTAR.txtToXML.XMLConverter $2
######## COMMENTS #########
### A script that opens a file provided as a parameter
### and replaces a given pattern of characters with a replacement string.
### The replacements go as follows:
### Pre-ltchunk processing:
### A sequence '[[', ']]', '((', or '))' in the original file
### is replaced by '@|', '|@', '@~', '~@' respectively.
### Then ltchunk is run over the resulting file.
### Post-ltchunk processing:
### A sequence '[[', ']]', '((', or '))'
### is replaced by '<ne>', '</ne>', '<ve>', '</ve>' respectively.
### And finally return the original symbols hided during the pre-processing phase:
### A sequence '@|', '|@', '@~', '~@'
### is replaced by '[_([_(', ']_)]_)', '(_((_(', ')_))_)' respectively.
### The original symbols are returned in a format as if they were also processed by ltchunk.
### Notes:
### ne - stands for nominal expression
### ve - stands for verbal expression
| 0 | 1 | 0 | 0 | 0 | 0 |
Additional details:
X is any positive integer 6 digits or less.
X is left-padded with zeros to maintain a width of 6.
Please explain your answer :)
(This might be better in the Math site, but figured it involves programming functions)
| 0 | 0 | 0 | 0 | 1 | 0 |
Working with time in php is kicking my butt.
I'm trying to make a timer that starts when I click a button. I'm hoping to make something that, when I click a button, enters a current time and a time + 5 minutes into a database, and then outputs the difference in min:sec. I need to store the times so they include date so that when the site is not in use, it doesn't show up some weird value.
The first page enters the times
$target = date('Y-m-d H:i:s') + date('i', 5);
$starttime = date('Y-m-d H:i:s');
INSERT INTO countdowntimer (target, starttime) VALUES ('$target', '$starttime');
And the second page displays it:
$starttime = mysql_query("SELECT starttime FROM countdowntimer");
$target = mysql_query("SELECT target FROM countdowntimer");
$difference = $target-$starttime
$min = floor($difference/60)
$sec = floor($difference-($min*60))
if ($difference < 0) {
echo '0:00'; }
else {
echo $min . ':' . $sec; }
Well, my $target is getting entered as 0000-00-00 00:00:00 and my display page shows "0.1". The variables are $startime=Resource id #3, $target=Resource id#4, $difference=1, $min=0, $sec=1.
First question: how do I enter the current time + 5 minutes
Second question: Do you have any tips on working with the values to be displayed as min:sec. I'd like the min to show up as 1 digit and then 0, and the seconds, when less than 10 displayed as :09, :08, etc..
Thanks.
| 0 | 0 | 0 | 0 | 1 | 0 |
I am trying to implement redraw regions with up to 3 regions but can't think of an efficient way to find the best set of regions given a set of rectangles.
So there would be a set of rectangles and I would need to calculate up to 3 bounding rectangles that produce the smallest area.
The black rectangles are the set of rectangles whereas the red rectangles are the bounding boxes (up to 3) that produce the smallest possible area. Need to work out the best possible combination of bounding boxes.
| 0 | 0 | 0 | 0 | 1 | 0 |
I need to convert this code to a decimal number but I can't tell what base was used to generate it as all letters:
JPZYPZ
How can I figure out what type of "number" this is?
| 0 | 0 | 0 | 0 | 1 | 0 |
Can You help me in understanding the following? Thanks in advance! :)
Given T=F/C.----(1)
where T is the average download time, F is the file size and C is the average service capacity.
The average capacity that the downloading peer expects from the network is
(100 +150)/2 = 125kbps.
If the file size F is 1MB, we predict that the average download time is 64 seconds from (1).
plzzzzzzzz explain this ....
| 0 | 0 | 0 | 0 | 1 | 0 |
How can i make a smooth circular orbit at a constant speed using pygame?
How would i calculate x, y on a circle?
| 0 | 0 | 0 | 0 | 1 | 0 |
I am looking for an efficient formula working in Java which calculates the following expression:
(low + high) / 2
which is used for binary search.
So far, I have been using "low + (high - low) / 2" and "high - (high - low) / 2"
to avoid overflow and underflows in some cases, but not both.
Now I am looking for an efficient way to do this, which would for for any integer (assuming integers range from -MAX_INT - 1 to MAX_INT).
UPDATE:
Combining the answers from Jander and Peter G. and experimenting a while I got the following formulas for middle value element and its immediate neighbors:
Lowest-midpoint (equal to floor((low + high)/2), e.g. [2 3] -> 2, [2 4] -> 3, [-3 -2] -> -3)
mid = (low & high) + ((low ^ high) >> 1);
Highest-midpoint (equal to ceil((low + high)/2), e.g. [2 3] -> 3, [2 4] -> 3, [-3 -2] -> -2)
low++;
mid = (low & high) + ((low ^ high) >> 1);
Before-midpoint (equal to floor((low + high - 1)/2)), e.g. [2 3] -> 2, [2 4] -> 2, [-7 -3] -> -6)
high--;
mid = (low & high) + ((low ^ high) >> 1);
After-midpoint (equal to ceil((low + high + 1)/2)), e.g. [2 3] -> 3, [2 4] -> 4, [-7 -3] -> -4)
mid = (low & high) + ((low ^ high) >> 1) + 1;
Or, without bitwise and (&) and or (|), slightly slower code (x >> 1 can be replaced with floor(x / 2) to obtain bitwise operator free formulas):
Leftmost-midpoint
halfLow = (low >> 1), halfHigh = (high >> 1);
mid = halfLow + halfHigh + ((low-2*halfLow + high-2*halfHigh) >> 1);
Rightmost-midpoint
low++
halfLow = (low >> 1), halfHigh = (high >> 1);
mid = halfLow + halfHigh + ((low-2*halfLow + high-2*halfHigh) >> 1);
Before-midpoint
high--;
halfLow = (low >> 1), halfHigh = (high >> 1);
mid = halfLow + halfHigh + ((low-2*halfLow + high-2*halfHigh) >> 1);
After-midpoint
halfLow = (low >> 1), halfHigh = (high >> 1);
mid = halfLow + halfHigh + ((low-2*halfLow + high-2*halfHigh) >> 1) + 1;
Note: the above >> operator is considered to be signed shift.
| 0 | 0 | 0 | 0 | 1 | 0 |
I couldn't really come up with a proper title for my question but allow me to present my case; I want to calculate a significance ratio in the form: p = 1 - X / Y
Here X comes from an iterative process; the process takes a large number of steps and counts how many different ways the process can end up in different states (stored in a HashMap). Once the iteration is over, I select a number of states and sum their values. It's hard to tell how large these numbers are so I am intending to implement the sum as BigInteger.
Y, on the other hand comes from a binomial coefficient with numbers in thousands-scale. I am inclined to use logGamma to calculate these coefficients, which as a result give me the natural logarithm of the value.
What I am interested in is to do division X / Y in the best/most effective way. If I can get X in the natural logarithm then I could subtract the powers and have my result as 1 - e ^ (lnX - lnY).
I see that BigInteger can't be logarithmized by Math.log, what can I do in this case?
| 0 | 0 | 0 | 0 | 1 | 0 |
I would like to classify text documents into four categories. Also I have lot of samples which are already classified that can be used for training. I would like the algorithm to learn on the fly.. please suggest an optimal algorithm that works for this requirement.
| 0 | 0 | 0 | 1 | 0 | 0 |
I'm programming a really simple 2D collision response algorithm (thankfully), but even the really simple geometry concepts have been baffling me. Been studying! But...
In this case, it's vectors:
If an object hits a piece of geometry, I want to completely eliminate that object's momentum in the direction parallel to the normal of the geometry's wall. There's no friction or bounce involved luckily, but even still I'm not sure how to find a vector that will completely negate that momentum along the normal.
Thank you in advance!
| 0 | 0 | 0 | 0 | 1 | 0 |
i am trying to get the 'cross product' of two vectors. these two vectors represent two planes. so, my vectors are as a1,b1,-1 and a2,b2,-1. (I used, my plane equation as ax+by-z+d=0).
this was my defined function to get the cross product;
vector<double> cross_vector(vector<double> plane1,vector<double> plane2){
vector<double> cross_product;
double a1=plane1.at(0); double a2=plane2.at(0);
double b1=plane1.at(1); double b2=plane2.at(1);
int c1,c2=-1;
double cross_a=(b1*c2)-(b2*c1);
double cross_b=(a2*c1)-(a1*c2);
double cross_c=(a1*b2)-(a2*b1);
cross_product.push_back(cross_a);
cross_product.push_back(cross_;
cross_product.push_back(cross_c);
return cross_product;
}
for the result i got as below result for different plane combinations;
523554 -1.3713e+006 -0.00160687
556340 -1.43908e+006 0.00027957
-568368 1.46225e+006 -0.00034963
143455 -380017 -0.00027957
i can't understand the values like 1.46225e+006? is there any wrong with my function?
i know, my resultant cross vector should be directed exactly horizontal. So, could you also tell me how can i check whether my cross-vector is horizontal or not?
hope your advices.
| 0 | 0 | 0 | 0 | 1 | 0 |
Does anybody know of a definitive list of selection operators for Genetic Algorithms ?
I am looking for methods other than the usual "Roulette Wheel" or "Tournament" selection methods.
Most lists/literature I have seen use the prase "and other lesser used methods" without saying what they are.
Thanks,
NWS.
| 0 | 1 | 0 | 0 | 0 | 0 |
In normal 2 or multi class classification problem, we can use any famous machine learning algorithm like Naive Bayes or SVM to train and test the model.
My problem is that I have been given weather data where the label variable is in the format of "20 % rain, 80 % dry" or "30% cloudy, 70% rain" etc.
How should I approach this problem? Will I need to covert the problem into regression somehow? In that case, if there are three labels (rain, dry, cloudy) in data, what may be the right approach to convert percentage information to continuous values?
Thanks for your time
| 0 | 0 | 0 | 1 | 0 | 0 |
I'm writing a program in python to do a unigram (and eventually bigram etc) analysis of movie reviews. The goal is to create feature vectors to feed into libsvm. I have 50,000 odd unique words in my feature vector (which seems rather large to me, but I ham relatively sure I'm right about that).
I'm using the python dictionary implementation as a hashtable to keep track of new words as I meet them, but I'm noticing an enormous slowdown after the first 1000 odd documents are processed. Would I have better efficiency (given the distribution of natural language) if I used several smaller hashtable/dictionaries or would it be the same/worse?
More info:
The data is split into 1500 or so documents, 500-ish words each. There are between 100 and 300 unique words (with respect to all previous documents) in each document.
My current code:
#processes each individual file, tok == filename, v == predefined class
def processtok(tok, v):
#n is the number of unique words so far,
#reference is the mapping reference in case I want to add new data later
#hash is the hashtable
#statlist is the massive feature vector I'm trying to build
global n
global reference
global hash
global statlist
cin=open(tok, 'r')
statlist=[0]*43990
statlist[0] = v
lines = cin.readlines()
for l in lines:
line = l.split(" ")
for word in line:
if word in hash.keys():
if statlist[hash[word]] == 0:
statlist[hash[word]] = 1
else:
hash[word]=n
n+=1
ref.write('['+str(word)+','+str(n)+']'+'
')
statlist[hash[word]] = 1
cin.close()
return statlist
Also keep in mind that my input data is about 6mb and my output data is about 300mb. I'm simply startled at how long this takes, and I feel that it shouldn't be slowing down so dramatically as it's running.
Slowing down: the first 50 documents take about 5 seconds, the last 50 take about 5 minutes.
| 0 | 1 | 0 | 0 | 0 | 0 |
I need to program something that calculates a number to arbitrary precision...
but I need it to output the digits that are already "certain" (ie below some error bound) to a file so that there are digits to work on while the program keeps running.
Also, most libraries for arbitrary precision seem to require a fixed precision, but what if I wanted dynamic precision, ie, it would go on and on...
| 0 | 0 | 0 | 0 | 1 | 0 |
Why if I increment an array string I get an error while if I pass the value to a function I can make it work? A string array object is not already a pointer to the array elements?
e.g.
void foo(char *a){
printf("%c", *a);
a++; // this works
printf("%c", *a);
}
int main(){
char a[] = "ciao";
a++; // I get the error
foo(a);
return 1;
}
thanks!
| 0 | 0 | 0 | 0 | 1 | 0 |
If problem is in power, how to write it correctly?
| 0 | 0 | 0 | 0 | 1 | 0 |
Given the base 36 number YPAYPA, is there a library function in Java that would convert this to a decimal number?
| 0 | 0 | 0 | 0 | 1 | 0 |
It's late here and my brain doesn't work as it should so...
I have an image 244x175 pixels and I want to scale it in order to fit in an 125mm area for a PDF I am generating by using www.tcpdf.org.
How many much I have to scale it in order to fit correctly?
Thanks in advance
| 0 | 0 | 0 | 0 | 1 | 0 |
I manually adjust the thread count:
if (items.Count == 0) { threads = 0; }
else if (items.Count < 1 * hundred) { threads = 1; }
else if (items.Count < 3 * hundred) { threads = 2; }
else if (items.Count < 5 * hundred) { threads = 4; }
else if (items.Count < 10 * hundred) { threads = 8; }
else if (items.Count < 20 * hundred) { threads = 11; }
else if (items.Count < 30 * hundred) { threads = 15; }
else if (items.Count < 50 * hundred) { threads = 30; }
else threads = 40;
I need a function that returns the necessary/optimized thread count.
Ok, now forget above. I need a graph curve to plot. I give the coords, function plots the curve. Imagine the point(0,0) and point(5,5) -in (x,y) form. It should be straight line. So then I can measure x for y=3.
What happens if I give the points (0,0), (2,3), (8,10), (15,30) and (30,50). It will be a curve like thing. Now can I calculate x for given y or vice versa?
I think you get the idea. Should I use MathLab or could it be done in C#?
| 0 | 0 | 0 | 0 | 1 | 0 |
I have a script that works in several steps to e-mail students at a school who are tardy. The school essentially penalizes students who have 3 and 5 tardies. However, alongside that, there's a total tardy count. For example, a student can have 16 tardies but their "penalizing" count will 16 % 5 === 1.
This is how it works:
A cron job runs at 3:00 each day checking the following:
If the amount of times the student (tardy % 5 == 3), that means they have 3 tardies. The script then updates a column called tardyemail for that particular student to equal 1.
If the amount of times the student is tardy % (mod) 5 = 0, that means they have 5 tardies. The script then updates the tardyemail column to equal 2.
Here's the relevant code:
if($row['times_tardy'] % 5 == 0) {
echo $row['fname']." - 5<br />";
$sql = "UPDATE student SET tardyemail = '2' WHERE rfid = '" . $row['StudentID'] . "'";
mysql_query($sql) or die (mysql_error());
}
if($row['times_tardy'] % 5 == 3) {
echo $row['fname']." - 3<br />";
$sql = "UPDATE student SET tardyemail = '1' WHERE rfid = '" . $row['StudentID'] . "'";
mysql_query($sql) or die (mysql_error());
}
A separate cron script runs at 3:30 performing the following:
Select students who's tardyemail column is equal to 1, and if it's equal to 1, send the template e-mail for 3 tardies out to those students. Then, update the tardyemail column to 0.
Select students who's tardyemail column is equal to 2, and if it's equal to 2, send the template e-mail for 5 tardies out to those students. Then, update the tardyemail column to 0.
Relevant code:
$sql = "SELECT * FROM student WHERE tardyemail = '1' AND grade_level > 10";
$result = mysql_query($sql) or die (mysql_error());
if(mysql_num_rows($result) > 0) {
while($row = mysql_fetch_array($result)) {
// send the email
}
}
// update tardyemail to equal 0
$sql = "SELECT * FROM student WHERE tardyemail = '2' AND grade_level > 10";
$result = mysql_query($sql) or die (mysql_error());
if(mysql_num_rows($result) > 0) {
while($row=mysql_fetch_array($result)) {
// sendthe mail
}
}
// update tardyemail to equal 0
The problem with this is the fact that, each day, student's at 3 or 5 tardies are continuously e-mailed because if they don't accrue any more tardies, they remain at 3 and 5. I need some help figuring out a way to do this to not e-mail them multiple times if they haven't accrued any more tardies.
| 0 | 0 | 0 | 0 | 1 | 0 |
Both Wolfram Alpha and Bing are now providing the ability to solve complex, algebraic logic problems (ie "solve for x, given this equation"), and not just evaluate simple arithmetic expressions (eg "what's 5+5?"). How is this done?
I can read most types of code that might get thrown at me, so it doesn't really make a difference what you use to explain and represent the algorithm. I find that bash makes a really good pseudo-code, not to mention its actually functional, so that'd be ideal. Also, I'm fairly familiar with its in's and out's. Sorry to go ranting on a tangent, but it really irritates me to see people spend effort on crunching out "pseudocode" when they could be getting something 100% functional for just slightly more effort. Anyways, thanks so much for advance.
| 0 | 0 | 0 | 0 | 1 | 0 |
So lets say I have 2 numbers in decimals (eg .75 and .25). I am trying to make a function that gets these 2 numbers and chooses a "winner" randomly but based on those 2 numbers' percentages. In short terms, I need the .75 number to have a better chance at getting picked then the .25 number (the .25 can still get picked, but it has only a 25% chance). How should I go about doing this?
| 0 | 0 | 0 | 0 | 1 | 0 |
Let's say I have a dataset, which can be neatly classified using weka's J48 or randomForest in R.
Now let's say I have an other training file, which contains two classifications per datapoint.
How could I combine these two to be able to classify new data points into these two classes?
(So I'd need a "two-pass" training.)
Should I use a MLP (like a restricted Bolzmann machine) instead?
| 0 | 0 | 0 | 1 | 0 | 0 |
I understand that (2 * i == (i ^( i - 1) + 1) in Java will let me find if a number is a power of two. But can someone explain why this works?
| 0 | 0 | 0 | 0 | 1 | 0 |
I have some software written in VB.NET that performs a lot of calculations, mostly extracting jpegs to bitmaps and computing calculations on the pixels like convolutions and matrix multiplication. Different computers are giving me different results despite having identical inputs. What might be the reason?
Edit: I can't provide the algorithm because it's proprietary but I can provide all the relevant operations:
ULong \ ULong (Turuncating division)
Bitmap.Load("filename.bmp') (Load a bitmap into memory)
Bitmap.GetPixel(Integer, Integer) (Get a pixel's brightness)
Double + Double
Double * Double
Math.Sqrt(Double)
Math.PI
Math.Cos(Double)
ULong - ULong
ULong * ULong
ULong << ULong
List.OrderBy(Of Double)(Func)
Hmm... Is it possible that OrderBy is using a non-stable QuickSort and that QuickSort is using a random pivot? Edit: Just tested, nope. The sort is stable.
| 0 | 0 | 0 | 0 | 1 | 0 |
I'm suppose to do some work with Fourier transformations and I'm still really confused.
I'm given a signal (in this case it is f[t] = sin(2 pi s t / N) where s = 8 and N = 128)
And I'm suppose to find the Real, Imaginary, Phase, and Magnitude.
I understand how to get the Real and Imaginary, but the Phase and the Magnitude are beyond me...
the sudo code for getting the Real and the Imaginary is:
for u = 0 to M-1 do
F[u].real = 0
F[u].imag = 0
for x = 0 to M-1 do
F[u].real += f[x] * cos(- 2 * pi * u * x / M)
F[u].imag += f[x] * sin(- 2 * pi * u * x / M)
end do
F[u].real /= M
F[u].imag /= M
end do
Now somewhere in there is the phase and the magnitude, but where?!
Thanks!
Also, some programmer-equse explination of the basics of FTs would be wonderful as well!
| 0 | 0 | 0 | 0 | 1 | 0 |
I have a boolean[][] where the true indexes make up a solid polygon. With this information how can I
A. determine which blocks make up the perimeter, and
B. which points (in order) can draw the polygon using the polygon class.
I intend to use Polygon class to call .contains but the code I have currently gives me the polygon points out of order (as i am simply scanning from left to right, top to bottom). Any help on the subject is appreciated.
| 0 | 0 | 0 | 0 | 1 | 0 |
my purpose is to parse several text files using the POS parser HunPos http://code.google.com/p/hunpos/wiki/UserManualI
is there a way to bash script hunpos through a bunch of text files?
| 0 | 1 | 0 | 0 | 0 | 0 |
I need to calculate averages, standard deviations, medians etc for a bunch of numerical data. Is there a good open source .NET library I can use? I have found NMath but it is not free and may be overkill for my needs.
| 0 | 0 | 0 | 0 | 1 | 0 |
Consider these two slightly different methods for computing fifth roots:
(define (fifth-root-right x)
(fixed-point-of-transform (lambda (y) (/ x (expt y 4)))
(repeated average-damp 2)
1.0))
(define (fifth-root-wrong x)
(fixed-point (repeated
(average-damp (lambda (y) (/ x (expt y 4))))
2)
1.0))
Both attempt to compute fifth roots by an average dampened search for a fixed point, since a fifth root of x is a fixed point of the map y -> x/(y^4). I've defined
(define (average-damp f)
(lambda (x) (average x (f x))))
(define tolerance 0.00001)
(define (fixed-point f first-guess)
(define (close-enough? v1 v2)
(< (abs (- v1 v2)) tolerance))
(define (try guess)
(let ((next (f guess)))
(if (close-enough? guess next)
next
(try next))))
(try first-guess))
(define (fixed-point-of-transform g transform guess)
(fixed-point (transform g) guess))
(define (repeated f n)
(if (= n 1)
f
(compose f (repeated f (- n 1)))))
(define (compose f g) (lambda (x) (f (g x))))
Trying both methods, we get
> (fifth-root-right 32)
2.000001512995761
> (fifth-root-wrong 32)
2.8804315666156364
Why does the second method give fail to correctly compute fifth roots? Stranger still, if we try this wrong method on fourth or third roots, it works correctly:
(define (fourth-root x)
(fixed-point (repeated
(average-damp (lambda (y) (/ x (expt y 3))))
2)
1.0))
(define (cube-root x)
(fixed-point (repeated
(average-damp (lambda (y) (/ x (expt y 2))))
2)
1.0))
> (fourth-root 16)
1.982985155172348
> (cube-root 8)
2.0000009087630515
For reference, this code attempts to solve Exercise 1.45 in Structure and Interpretation of Computer Programs. Now that I have the right method, my code works, but I don't understand why my wrong method is wrong.
| 0 | 0 | 0 | 0 | 1 | 0 |
Inspired by this question, the asker assumes that the users of a system would very rarely take some action at the exact same time as each other.
Given what I know of making assumptions like that I can guarantee that users would infact do things at the same time. However, I am at a loss as to how you would actually calculate the expected frequency of collisions.
E.g. If we assume each user is taking an action every 3 minutes and our timer is really only accurate to the millisecond, what is the formula for calculating the frequency of collisions?
Given the Wikipedia entry for the birthday problem can be generalised into the formula
Where d is the 180,000 milliseconds and p the probability of a collision.
So with 3 users say, we get a probability of 2.4996E-05 in any given 3 minute period that there is a collision.
The issue then becomes what are the chances of a collision during the day?
There being 60-*60*8/3 = 9600 3 minute periods in the working day, the probability of a collision in any given day then be comes 1-((1-2.4996E-05)^9600) = 21%. A pretty good chance of things going pear shaped.
| 0 | 0 | 0 | 0 | 1 | 0 |
I wanted to ask Stack Overflow users for a nice idea for a project that could entertain a fellow student programmer during a semester. Computer vision might look interesting, although I couldn't say if a project on that field is something that could be achievable in 4 months. What do you think?
| 0 | 1 | 0 | 0 | 0 | 0 |
Have you ever written simulations or randomized algorithms where you've run into trouble because of the quality of the (pseudo)-random numbers you used?
What was happening?
How did you detect / realize your prng was the problem?
Was switching PRNGs enough to fix the problem, or did you have to switch to a source of true randomness?
I'm trying to figure out what types of applications require one to worry about the quality of their source of randomness and how one realizes when this becomes a problem.
| 0 | 0 | 0 | 0 | 1 | 0 |
Is there a way to find out the distance of intersection between 2 spheres ? I understand when two spheres intersect the circle of intersection is formed . But what i'm trying to figure ouut is by how much i will need to push circle 1 outside so that they dont intersect and are at a point where they are just touching each other . The only data i have are the centres of the spheres and their respective radii.
Thanks
| 0 | 0 | 0 | 0 | 1 | 0 |
I'm doing some calculations that result in a value like {-0.707107, 9.61481e-017, 0.707107} when I'm expecting {-0.707107, 0, 0.707107}. Could that second component, while essentially zero, cause problems down the road? Should I do something about it? Using C++ doubles.
| 0 | 0 | 0 | 0 | 1 | 0 |
I'm not a mathematician so this may be a stupid question...but - is there any way to translate IP addresses into integers between 1 and 3, whereby there will A) be an equal distribution of 1's, 2's and 3's and B) each IP address will always translate to the same integer? (in essence, a hash).
I'm using 3 as an example - ideally I'd like the range limit to be customizable.
$highest_allowed_integer = 3;
$integer = get_evenly_distributed_but_always_identical_integer($_SERVER["REMOTE_ADDR"],$highest_allowed_integer);
Thanks!
| 0 | 0 | 0 | 0 | 1 | 0 |
i've tried the following code and installed
from http://code.google.com/p/hunpos/downloads/list
english-wsj-1.0
hunpos-1.0-linux.tgz
i've extracted the file onto '~/' directory
and when i tried the following python code:
import nltk
from nltk.tag import hunpos
from nltk.tag.hunpos import HunposTagger
import os, sys, re, glob
cwd = os.getcwd()
for infile in glob.glob(os.path.join(cwd, '*.txt')):
(PATH, FILENAME) = os.path.split(infile)
read = open(infile)
ht = HunposTagger('english.model')
ht.tag(read.readline())
i get the following error
Traceback (most recent call last):
File "<stdin>", line 4, in <module>
File "/usr/local/lib/python2.6/dist-packages/nltk-2.0b9-py2.6.egg/nltk/tag/hunpos.py", line 46, in __init__
verbose=verbose)
File "/usr/local/lib/python2.6/dist-packages/nltk-2.0b9-py2.6.egg/nltk/internals.py", line 503, in find_binary
raise LookupError('
%s
%s
%s' % (div, msg, div))
LookupError:
===========================================================================
NLTK was unable to find the hunpos-tag executable! Use
config_hunpos-tag() or set the HUNPOS environment variable.
>>> config_hunpos-tag('/path/to/hunpos-tag')
Searched in:
- .
- /usr/bin
- /usr/local/bin
- /opt/local/bin
- /Applications/bin
- /home/ubi/bin
- /home/ubi/Applications/bin
For more information, on hunpos-tag, see:
<http://code.google.com/p/hunpos/>
===========================================================================
>>> config_hunpos-tag('~/')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'config_hunpos' is not defined
how do i configure hunpos in python? which python command do i need to enter?
| 0 | 1 | 0 | 0 | 0 | 0 |
In want to setup python's nltk library including wordnet in such a way that it can be easily copied from development system to production server, without having requirement for downloading wordnet separately.
Any suggestion would be helpful...
| 0 | 1 | 0 | 0 | 0 | 0 |
How would you generate a random matrix that is not singular in MATLAB.?
I know a matrix determinant can be used to do check this, but after reading MATLAB determinant:
"Using det(X) == 0 as a test for matrix singularity is appropriate only for matrices of modest order with small integer entries. Testing singularity using abs(det(X)) <= tolerance is not recommended as it is difficult to choose the correct tolerance. The function cond(X) can check for singular and nearly singular matrices."
So if I want to generate a big random matrix (axb) a=5000, b=5000, How to do it??.
| 0 | 0 | 0 | 0 | 1 | 0 |
I have 2 inputs from 0-180 for x and y i need to add them together and stay in the range of 180 and 0 i am having some trouble since 90 is the mid point i cant seem to keep my data in that range im doing this in vb.net but i mainly need help with the logic
| 0 | 0 | 0 | 0 | 1 | 0 |
If I have 2 sets of points I can rotate one around with Procrustes analysis to align one with the other.
But suppose these 2 sets of points each are attached to images and I would like to rotate the images as well. Is there any way I can also rotate the image, instead of rotating just the points? The tutorial there uses a dot product for rotation (solve u, s, v = svd(p1', p2) and then do p2 . v . u', p' is transposed p)
However that doesn't tell me what the angle between the images is.
The page on wikipedia calculates an angle between each pair of points I think.
Maybe what I'm asking is impossible? If I rotate the first set of points to align it with the first, can't I also rotate the respective images by an angle as well? Point being, which angle is that?
I noticed that v . u' gives me a 2 x 2 matrix which seems to be the rotation matrix (there's a wikipedia page but I can't link there due to posting priviledges). I got the sin and cos of the third and first elements and then used arctan2, but the results I'm getting are kind of weird. I know they have to be transformed from radians but I'm not convinced what I'm doing is right. Trying the rotation it gives me on gimp makes it seem like it's not what I want, but I'll test some more.
| 0 | 0 | 0 | 0 | 1 | 0 |
I'm looking for the best algorithm to optimise the decisions made in a simultaion to find a fast result in a reasonable amount of time. The simultaion does a number of "ticks" and occasionaly needs to make a decision. Eventually a goal state is reached. ( It would be possible to never reach a goal state if you make very bad decisions )
There are many many goal states. I want to find the goal state with the least number of ticks ( a tick equates roughly to a second in real life." I basically want to decide which decisions to make to get to the goal in as few seconds as possible,
Some points about the problem domain:
Straight off the bat I can generate a series of choices that will lead to a solution. It won't be optimal.
I have a reasonable heuristic function to determine what would be a good decision
I have a reasonable function to determine the minimum possible time cost from a node to a goal.
Algorithms:
I need to process this problem for about 10 seconds and then give the best answer I can.
I believe A* would find me the optimal soluton. The problem is that the decision tree will be so large that I won't be able to calculate it quick enough.
IDA* would give me a good first few choices in 10 seconds but I need a path all the way to a goal.
At the moment I am thinking that I will start off with the known non optimal path to a goal and then perhaps use Simulated Anealing and attempt to improve it over 10 seconds.
What would be a good algorithm to research to try to solve this sort of problem?
| 0 | 1 | 0 | 0 | 0 | 0 |
It is said that different algorithms have different parameters. I don't really see this as true, say if it is a tree decision algorithm and naive bayesian algorithm, what is the parameter for each? Can someone give me an example..
If this is the case then doing a 5-fold cross validation for a data that is going to be run using a decision tree algorithm is different with bayesian?
Also for the parameter optimization I will do a 5-fold cross validation. Is there a way to automatically do this to determine the set values key of parameters using weka?
| 0 | 1 | 0 | 0 | 0 | 0 |
If you put a decimal in a format where has to be rounded to the nearest 10th, and it is: 1.55, it'll round to 1.5. 1.56 will then round to 1.6. In school I recall learning that you round up when you reach five, and down if it's 4 or below. Why is it different in Python, et al.
Here's a code example for Python 2.6x (whatever the latest version is)
'{0:01.2f}'.format(5.555) # This will return '5.55'
After trying some of the examples provided, I realized something even more confusing:
'{0:01.1f}'.format(5.55) # This will return '5.5'
# But then
'{0:01.1f}'.format(1.55) # This will return '1.6'
Why the difference when using 1.55 vs 5.55. Both are typed as literals (so floats)
| 0 | 0 | 0 | 0 | 1 | 0 |
List1 contains a high number (~7^10) of N-dimensional points (N <=10), List2 contains the same or fewer number of N-dimensional points (N <=10).
My task is this: I want to check which point in List2 is closest (euclidean distance) to a point in List1 for every point in List1 and subsequently perform some operation on it. I have been doing it the simple- the nested loop way when I didn't have more than 50 points in List1, but with 7^10 points, this obviously takes up a lot of time.
What is the fastest way to do this? Any concepts from Computational Geometry might help?
EDIT: I have the following in place, I have built a kd-tree out of List2 and then now I am doing a nearest-neighborhood search for each point in List1. Now as I originally pointed out, List1 has 7^10 points, and hence though I am saving on the brute force, Euclidean distance method for every pair, the sheer large number of points in List1 is causing a lot of time consumption. Is there any way I can improve this?
| 0 | 0 | 0 | 0 | 1 | 0 |
I've got a school assignment to make a language analyzer that's able to guess the language of an input. The assignment states this has to be done by pre-parsing language defined texts and making statistics about letters used, combinations of letter etc and then making a guess based on this data.
The data structure we're supposed to use is simple multi-dimensional hashtables but I'd like to take this opportunity to learn a bit more about implementing structures etc. What'd I'd like to know is what to read up about. My knowledge of algorithms is very limited but I'm keen on learning if someone could point me in the right direction.
Without any real knowledge and just reading up on different posts I'm currently planing on studying undirected graphs as a datastructure for letter combinations (and somehow storing the statistics within the graph as well) and boyer-moore for the per-word search algorithm.
Am I totally on the wrong track and these would be impossible to implement in this situation or is there something else superior for this problem?
| 0 | 1 | 0 | 0 | 0 | 0 |
I have a point that moves (in one dimension), and I need it to move smoothly. So I think that it's velocity has to be a continuous function and I need to control the acceleration and then calculate it's velocity and position.
The algorithm doesn't seem something obvious to me, but I guess this must be a common problem, I just can't find the solution.
Notes:
The final destination of the object may change while it's moving and the movement needs to be smooth anyway.
I guess that a naive implementation would produce bouncing, and I need to avoid that.
| 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.