text
stringlengths 0
27.6k
| python
int64 0
1
| DeepLearning or NLP
int64 0
1
| Other
int64 0
1
| Machine Learning
int64 0
1
| Mathematics
int64 0
1
| Trash
int64 0
1
|
|---|---|---|---|---|---|---|
I have a from location (latitude, longitude) and to location (latitude, longitude). After calculating, it should show me what would be the nearest way to go from using a compass. The following is PHP code to do that, but its showing the wrong direction, I need little help on this.
function GreatCircleDirection ($OrigLat, $DestLat, $OrigLong, $DestLong, $Distance)
{
$Result = 0.0;
$L1 = deg2rad($OrigLat);
$L2 = deg2rad($DestLat);
$D = deg2rad($Distance / 60); # divide by 60 for nautical miles NM to degree
$I1 = deg2rad($OrigLong);
$I2 = deg2rad($DestLong);
$Dlong = $I1 - $I2;
$A = sin($L2) - cos($D + $L1 - pi() / 2);
$B = acos($A / (cos($L1) * sin($D)) + 1);
if ((abs($Dlong) < pi() and $Dlong < 0) or (abs($Dlong) > pi() and $Dlong > 0))
{
//$B = (2 * pi()) - $B;
}
$Result = $B;
return rad2deg($Result);
}
function GreatCircleDistance ($OrigLat , $DestLat, $OrigLong, $DestLong)
{
$L1 = deg2rad($OrigLat);
$L2 = deg2rad($DestLat);
$I1 = deg2rad($OrigLong);
$I2 = deg2rad($DestLong);
$D = acos(cos($L1 - $L2) - (1 - cos($I1 - $I2)) * cos($L1) * cos($L2));
# One degree of such an arc on the earth's surface is 60 international nautical miles NM
return rad2deg($D * 60);
}
Bug on if condition:
this is the values in the if condition of greatCircleDirection function, need to know what to change to fix it.
if (0.57700585070933 < 3.1415926535898 and 0.57700585070933 < 0) or (0.57700585070933 > 3.1415926535898 and 0.57700585070933 > 0)
example:
from lat: 33.71,
to lat: 21,
from long: 73.06,
to long: 40 ,
distance: 1908.842544944
direction 104.96527938779 (direction should be 255.87 or so)
| 0
| 0
| 0
| 0
| 1
| 0
|
I am working in a chemistry/biology project. We are building a web-application for fast matching of the user's experimental data with predicted data in a reference database. The reference database will contain up to a million entries. The data for one entry is a list (vector) of tuples containing a float value between 0.0 and 20.0 and an integer value between 1 and 18. For instance (7.2394 , 2) , (7.4011, 1) , (9.9367, 3) , ... etc.
The user will enter a similar list of tuples and the web-app must then return the - let's say - top 50 best matching database entries.
One thing is crucial: the search algorithm must allow for discrepancies between the query data and the reference data because both can contain small errors in the float values (NOT in the integer values). (The query data can contain errors because it is derived from a real-life experiment and the reference data because it is the result of a prediction.)
Edit - Moved text to answer -
How can we get an efficient ranking of 1 query on 1 million records?
| 0
| 0
| 0
| 0
| 1
| 0
|
How come ceil() rounds up an even floating with no fractional parts?
When I try to do this:
double x = 2.22;
x *= 100; //which becomes 222.00...
printf("%lf", ceil(x)); //prints 223.00... (?)
But when I change the value of 2.22 to 2.21
x *= 100; //which becomes 221.00...
printf("%lf", ceil(x)); //prints 221.00... as expected
I tried to do it another way like this using modf() and encountered another strange thing:
double x = 2.22 * 100;
double num, fraction;
fraction = modf(x, &num);
if(fraction > 0)
num += 1; //goes inside here even when fraction is 0.00...
So what happens is 0.000... is greater than 0?
Can anyone explain why both of these situations are happening? Also I'm compiling using cc version 4.1.2 in RedHat.
| 0
| 0
| 0
| 0
| 1
| 0
|
How would one design a neural network for the purpose of a recommendation engine. I assume each user would require their own network, but how would you design the inputs and the outputs for recommending an item in a database. Are there any good tutorials or something?
Edit: I was more thinking how one would design a network. As in how many input neurons and how the output neurons point to a record in a database. Would you have say 6 output neurons, convert it to an integer (which would be anything from 0 - 63) and that is the ID of the record in the database? Is that how people do it?
| 0
| 1
| 0
| 0
| 0
| 0
|
I am working on an AI bot for the game Defcon. The game has cities, with varying populations, and defensive structures with limited range. I'm trying to work out a good algorithm for placing defence towers.
Cities with higher populations are more important to defend
Losing a defence tower is a blow, so towers should be placed reasonably close together
Towers and cities can only be placed on land
So, with these three rules, we see that the best kind of placement is towers being placed in a ring around the largest population areas (although I don't want an algorithm just to blindly place a ring around the highest area of population, sometime there might be 2 sets of cities far apart, in which case the algorithm should make 2 circles, each one half my total towers).
I'm wondering what kind of algorithms might be used for determining placement of towers?
| 0
| 1
| 0
| 0
| 0
| 0
|
Some math calculations in JS problem solving
I am working on a zoom image functionality that creates a new div with a large image that is moved through x and y according to the mousemove on the image.
The large image should move a certain %, which is what i am trying to figure out. How much should it move by.
Here is some info:
The small image is always the same size and its square. (it is actually always 221px X 221px)
The large image varies (also always square, can be any size like 1000x1000)
The view port of the zoomer is always the same.
I want to calculate how much smaller (or vice-versa ) the small image is from the the large.
This is in middle of a whole big script. I started writing the formula for the calculation:
Again, All i want is to get the difference in percent converted into pixels step by step.
First get the % then convert that into pixels.
zoomObj.caluculateSizes = function(){
$(zoomObj.largeImage).load(function(){
// zoomObj.callingEvent is the small image
zoomObj.smlImgSize = zoomObj.callingEvent.width()
zoomObj.lrgImgSize = zoomObj.largeImage.width()
// How do i go from here?
})
js goes on.......
| 0
| 0
| 0
| 0
| 1
| 0
|
I'll apologize in advance in case this is obvious; I've been unable to find the right terms to put into Google.
What I want to do is to find a bounding volume (AABB is good enough) for an arbitrary parametric range over a trimmed NURBS surface. For instance, (u,v) between (0.1,0.2) and (0.4,0.6).
EDIT: If it helps, it would be fine for me if the method confined the parametric region entirely within a bounding region as defined in the paragraph below. I am interested in sub-dividing those regions.
I got started thinking about this after reading this paragraph from this paper ( http://www.cs.utah.edu/~shirley/papers/raynurbs.pdf ), which explains how to create a tree of bounding volumes with a depth relative to the degree of the surface:
The convex hull property of B-spline surfaces guarantees that the surface is contained in the convex hull of its control mesh.
As a result, any convex objects which bound the mesh will bound the underlying surface. We can actually make a stronger
claim; because we closed the knot intervals in the last section [made the multiplicity of the internal knots k − 1], each nonempty
interval [ui; ui+1) [vj; vj+1) corresponds to a surface patch which is completely contained in the convex hull of
its corresponding mesh points. Thus, if we produce bounding volumes for each of these intervals, we will have completely
enclosed the surface. We form the tree by sorting the volumes according tothe axis direction which has greatest extent across the bounding volumes, splitting the data in half, and repeating the process.
Thanks! Sean
| 0
| 0
| 0
| 0
| 1
| 0
|
I'm trying to write a general solver for a linear system in Maxima using linsolve(eqlist, varlist), but without having to explicitly specify the dimension of the problem.
This works, but fixes the dimension to 3:
linsolve( [ eq[0],eq[1],eq[2] ], [ a[0],a[1],a[2] ])
This doesn't:
solution(p):=(
array(eq,p+1), /* creating arrays of length p+1 */
array(a,p+1),
for i:0 thru p do (
eq[i]: sum(binom(j+1,i)*a[j],j,i,p) = binom(p,i)
),
linsolve(eq,a)
)
Any insight on how to get this to work?
Background behind the problem: this linear system arises when solving the finite summation of integer powers, i.e. the sum of finitely many squares, cubes, or general powers p. Although the finite sum of squares is straightforward, the general solution is surprisingly complicated: a discussion can be found here: Finite Summation by Recurrence Relations, Part 2.
| 0
| 0
| 0
| 0
| 1
| 0
|
Picture a circle. Now divide the circle vertically and horizontally into four regions. Take the top left region. If you drew a box around it, you'd have a box with a rounded corner heading east.
Given an X and Y coordinate in that box of that single top left region, how can I tell whether a point is to the left of the circle's line, or to the right?
| 0
| 0
| 0
| 0
| 1
| 0
|
I'm writing a solution for the Usaco problem "Electric Fences".
In the problem you have to find the optimal location for a point among a large amount of linesegments, so the sum of point-linesegment distances is smallest possible.
I had an idea, that it might be possible to do a hillclimb, and it worked for all testcases. The given analysis used a similar method, but it did not explain why this would work.
Thus I'm still unable to either prove or disprove the existence of local optimums in the given tasks. I had an idea that it could be done using induction, but I haven't been able to make it work. Can you help me?
Updated definition
Given a set of (x1,y1,x2,y2) linesegments find the (x,y) point P, that minimizes the function:
def Val(x,y):
d = 0
for x1,y1,x2,y2 in LineSegments:
if triangle (x1,y1,x2,y2,x,y) is not obtuse in (x1,y1) or (x2,y2):
d += DistPointToLine(x,y,x1,y1,x2,y2)
else:
d += min(DistPointToPoint(x,y,x1,y1), DistPointToPoint(x,y,x2,y2))
return d
By some reason the problem contains only one local optima, and thus the following procedure can be used to solve it:
precision = ((-0.1,0), (0.1,0), (0,-0.1), (0,0.1))
def Solve(precision=0.1):
x = 0; y = 0
best = Val(x,y)
while True:
for dx,dy in precision:
if Val(x+dx, y+dy) > best:
x += dx; y += dy
best = Val(x,y)
break
else:
break
return (x,y)
The questions is: Why does this not get stuck somewhere on the way to the global optimum? Why is there no local hilltops to bring this naive procedure to its knees?
| 0
| 0
| 0
| 0
| 1
| 0
|
I'd like to create an application that can do simple reasoning using first order logic. Can anyone recommend an "engine" that can accept an arbitrary number of FOL expressions, and allow querying of those expressions (preferably accessible via Python)?
| 0
| 0
| 0
| 1
| 0
| 0
|
For a balanced search tree, it is O(log(N)) for all cases. For unbalanced search trees, the worst case is O(N), e.g., insert 1, 2, 3, 4,.. and best case complexity is when it is balanced, e.g., insert 6, 4, 8, 3, 5 7. How do we define the average case complexity for unbalanced search tree?
| 0
| 0
| 0
| 0
| 1
| 0
|
Suppose we have a text file with the content:
"Je suis un beau homme ..."
another with:
"I am a brave man"
the third with a text in German:
"Guten morgen. Wie geht's ?"
How do we write a function that would tell us: with such a probability the text in the first
file is in English, in the second we have French etc?
Links to books / out-of-the-box solutions are welcome. I write in Java, but I can learn Python if needed.
My comments
There's one small comment I need to add. The text may contain phrases in different languages, as part of whole or as a result of a mistake. In classic litterature we have a lot of examples, because the aristocracy members were multilingual. So the probability better describes the situation, as most parts of the text are in one language, while others may be written in another.
Google API - Internet Connection. I would prefer not to use remote functions/services, as I need to do it myself or use a downloadable library. I'd like to make a research on that topic.
| 0
| 1
| 0
| 0
| 0
| 0
|
Start with this:
[G|C] * [T] *
Write a program that generates this:
Cat
Cut
Cute
City <-- NOTE: this one is wrong, because City has an "ESS" sound at the start.
Caught
...
Gate
Gotti
Gut
...
Kit
Kite
Kate
Kata
Katie
Another Example, This:
[C] * [T] * [N]
Should produce this:
Cotton
Kitten
Where should I start my research as I figure out how to write a program/script that does this?
| 0
| 1
| 0
| 0
| 0
| 0
|
Can anyone provide an example of a function that returns the cross product of TWO 2d vectors? I am trying to implement this algorithm.
C code would be great. Thanks.
EDIT: found another way todo it that works for 2D and is dead easy.
bool tri2d::inTriangle(vec2d pt) {
float AB = (pt.y-p1.y)*(p2.x-p1.x) - (pt.x-p1.x)*(p2.y-p1.y);
float CA = (pt.y-p3.y)*(p1.x-p3.x) - (pt.x-p3.x)*(p1.y-p3.y);
float BC = (pt.y-p2.y)*(p3.x-p2.x) - (pt.x-p2.x)*(p3.y-p2.y);
if (AB*BC>0.f && BC*CA>0.f)
return true;
return false;
}
| 0
| 0
| 0
| 0
| 1
| 0
|
I've written this very badly optimized C code that does a simple math calculation:
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define MIN(a, b) (((a) < (b)) ? (a) : (b))
#define MAX(a, b) (((a) > (b)) ? (a) : (b))
unsigned long long int p(int);
float fullCheck(int);
int main(int argc, char **argv){
int i, g, maxNumber;
unsigned long long int diff = 1000;
if(argc < 2){
fprintf(stderr, "Usage: %s maxNumber
", argv[0]);
return 0;
}
maxNumber = atoi(argv[1]);
for(i = 1; i < maxNumber; i++){
for(g = 1; g < maxNumber; g++){
if(i == g)
continue;
if(p(MAX(i,g)) - p(MIN(i,g)) < diff && fullCheck(p(MAX(i,g)) - p(MIN(i,g))) && fullCheck(p(i) + p(g))){
diff = p(MAX(i,g)) - p(MIN(i,g));
printf("We have a couple %llu %llu with diff %llu
", p(i), p(g), diff);
}
}
}
return 0;
}
float fullCheck(int number){
float check = (-1 + sqrt(1 + 24 * number))/-6;
float check2 = (-1 - sqrt(1 + 24 * number))/-6;
if(check/1.00 == (int)check)
return check;
if(check2/1.00 == (int)check2)
return check2;
return 0;
}
unsigned long long int p(int n){
return n * (3 * n - 1 ) / 2;
}
And then I've tried (just for fun) to port it under Python to see how it would react. My first version was almost a 1:1 conversion that run terribly slow (120+secs in Python vs <1sec in C).
I've done a bit of optimization, and this is what I obtained:
#!/usr/bin/env/python
from cmath import sqrt
import cProfile
from pstats import Stats
def quickCheck(n):
partial_c = (sqrt(1 + 24 * (n)))/-6
c = 1/6 + partial_c
if int(c.real) == c.real:
return True
c = c - 2*partial_c
if int(c.real) == c.real:
return True
return False
def main():
maxNumber = 5000
diff = 1000
for i in range(1, maxNumber):
p_i = i * (3 * i - 1 ) / 2
for g in range(i, maxNumber):
if i == g:
continue
p_g = g * (3 * g - 1 ) / 2
if p_i > p_g:
ma = p_i
mi = p_g
else:
ma = p_g
mi = p_i
if ma - mi < diff and quickCheck(ma - mi):
if quickCheck(ma + mi):
print ('New couple ', ma, mi)
diff = ma - mi
cProfile.run('main()','script_perf')
perf = Stats('script_perf').sort_stats('time', 'calls').print_stats(10)
This runs in about 16secs which is better but also almost 20 times slower than C.
Now, I know C is better than Python for this kind of calculations, but what I would like to know is if there something that I've missed (Python-wise, like an horribly slow function or such) that could have made this function faster.
Please note that I'm using Python 3.1.1, if this makes a difference
| 0
| 0
| 0
| 0
| 1
| 0
|
A friend of mine is beginning to build a NetHack bot (a bot that plays the Roguelike game: NetHack). There is a very good working bot for the similar game Angband, but it works partially because of the ease in going back to the town and always being able to scum low levels to gain items.
In NetHack, the problem is much more difficult, because the game rewards ballsy experimentation and is built basically as 1,000 edge cases.
Recently I suggested using some kind of naive bayesian analysis, in very much the same way spam is created.
Basically the bot would at first build a corpus, by trying every possible action with every item or creature it finds and storing that information with, for instance, how close to a death, injury of negative effect it was. Over time it seems like you could generate a reasonably playable model.
Can anyone point us in the right direction of what a good start would be? Am I barking up the wrong tree or misunderstanding the idea of bayesian analysis?
Edit: My friend put up a github repo of his NetHack patch that allows python bindings. It's still in a pretty primitive state but if anyone's interested...
| 0
| 1
| 0
| 0
| 0
| 0
|
I've just started to work with MPFR arbitrary precision library and quite soon encounter very weird behaviour. The main goal of using it was to improve precision of large argument 'trigs' and this works extremely good in MPFR.
But then I decided to check out simple math and it was unbelievable - even in straightforward examples with strict answers rounding errors exist and doesn't depends on used precision.
Even in the example like 1.1 * 1 the result is 1.10000000000000008881784...
And this result given at insane 2000 bit precision (53 in normal double)!
Maybe it is my system's issue, but even in online MPFR similar problems exist. You can try such an example online: http://ex-cs.sist.ac.jp/~tkouya/try_mpfr.html
1 * 1.1 @ 64 bits = 1.10000000000000000002
But online version moves error further with increase of precision but in my installation - no.
My system: Ubuntu 9.10 + gmp 5.0.0.1 + mpfr 2.4.2
| 0
| 0
| 0
| 0
| 1
| 0
|
Is there an x where SHA1(x) == x?
I'm looking for a proof or a strong argument against it.
| 0
| 0
| 0
| 0
| 1
| 0
|
I'm currently in the process of developing a digg-like Ruby on Rails application for my degree's Final Project and I'm stuck in the 5 point ranking algorithm.
There are a couple of factors that need to be involved, here's a breakdown :
Users
They'll have a personal 5 points ranking per category with 5 being the best and 1 being worst (Think of it as a 5 star ranking), so i could perfectly have IE. A 2 star ranking on the History category and a 5 star ranking on the Technology category.
Stories
Each story will be classified with just 1 category, when the user posts the story, (and here's the one of the problems) it'll be given a "base ranking" based on the ranking of the user in that category. IE let's say i have a 5 star ranking in the technology category then if I post a story in it's be given a base ranking of 5 stars because i have a 5 star ranking in that category.
In the end, i have 3 rankings. The avg user ranking, the ranking of the user per category and the ranking of each story.
I've found this link : http://www.seomoz.org/blog/reddit-stumbleupon-delicious-and-hacker-news-algorithms-exposed
It decomposes various ranking algorithms, the Reddit algorithm seems to adapt my needs, I believe that it's just a matter of replacing the X = D - U variable with a proper equation that avgs the 1-5 points that can be given.
What do you guys think?
Thank you,
Josh
| 0
| 0
| 0
| 0
| 1
| 0
|
What is Log-likelihood?
An example would be great.
| 0
| 0
| 0
| 0
| 1
| 0
|
I'm looking for any free tools/components/libraries that allow me to take anvantage of text mining, fact extraction and semantic analysis in my .NET application.
The GATE project is what I need but it is written in Java. Is there something like GATE in the .NET world?
My challange is to extract certain facts out of website text content. I plan to use some NLP algorithms to achieve such functionality, but I'm not sure how do I implement them, so I'm gonna use any existing solutions if they were available.
I'll appreciate if you could give me some tips. I'm new in this area, so any related info would be very usefull for me.
| 0
| 1
| 0
| 0
| 0
| 0
|
Can anyone give me a quick tip?
For example....how would I find the sine of 90 degrees?
| 0
| 0
| 0
| 0
| 1
| 0
|
Much has been written about deploying data crunching applications on EC2/S3, but I would like to know, what is the typical workflow for developing such applications?
Lets say I have a 1 TB of time series data to begin with and I have managed to store this on S3. How would I write applications and do interactive data analysis to build machine learning models and then write large programs to test them? In other words, how does one go about setting up a dev environment in such a situation? Do I boot up an EC2 instance, develop software on it and save my changes, and shutdown every time I want to do some work?
Typically, I fire up R or Pylab, read data from my local drives and do my analysis. Then I create applications based on that analysis and let it loose on that data.
On EC2, I am not sure if I can do that. Do people keep data locally for analysis and only use EC2 when they have large simulation jobs to run?
I am very curious to know what other people are doing, especially start ups who have their entire infrastructure based on EC2/S3.
| 0
| 0
| 0
| 1
| 0
| 0
|
I've spent a decent amount of time trying to hunt down a simple way of doing this - ideally, a magical library exists out there somewhere that will take my set of 3D data points and return 2 points on the best fit line using either orthogonal regression or least squares and also return the error of the fitted line. Does such a thing exist, and if so, where?
| 0
| 0
| 0
| 0
| 1
| 0
|
I have recently expanded the names corpus in nltk and would like to know how I can turn the two files I have (male.txt, female.txt) in to a corpus so I can access them using the existing nltk.corpus methods. Does anyone have any suggestions?
Many thanks,
James.
| 0
| 1
| 0
| 0
| 0
| 0
|
I am trying to implement the SIR epidemic model. Basically, the way I understand the model is that at each time step, it tells us how many nodes get infected and how many nodes are recovered. I am now trying to convert this into an discrete-event simulation and am confused at a point.
The model is generally solved using Euler's method. Now, when I am converting it into a discrete event simulation, I am doing something like this (the numbers are used for clarity):
Initialize 100 members
At every time step t,
//Determine how many get infected
for i = 1 to 100
let i pass a message to its neighbors
When the neighbor receives the message from an infected member, it generates a random number and if it is less than beta*(infected/total), where beta is the infection rate, then the member gets infected
Update the count for infected, recovered, susceptible
//Determine how many are recovered
for i = 1 to 100
Generate a random number from a uniform distribution and check if it is less than gamma*infected. If it is, then this member is recovered.
Update the count for infected, recovered, susceptible
I was essentially wondering if the above approach is right. Any suggestions?
| 0
| 0
| 0
| 0
| 1
| 0
|
I am trying to find a formula
http://www.evanmiller.org/how-not-to-sort-by-average-rating.html
The one from the above link is too hard to implement.
Is there a nicer and simpler way to sort entities by a five star user rating control ?
Think at jokes. People say jokes and others rate them with 1 to 5 stars.
If
a) 5 users rate a joke with 5,
b) another 1000 rate another joke with 4 and finally,
c) another 1000 rate another joke with 3.8, I want this specific order:
joke b)
joke c)
joke a)
| 0
| 0
| 0
| 0
| 1
| 0
|
This is a similar question to this one here.
Given a list of 3D coordinates that define the surface( Point3D1, Point3D2, Point3D3, and so on), how to calculate the centroid of the surface?
In 2D the computation is given by the following formula:
What about the 3D analogue?
| 0
| 0
| 0
| 0
| 1
| 0
|
It's well known that Bayesian classifiers are an effective way to filter spam. These can be fairly concise (our one is only a few hundred LoC) but all core code needs to be written up-front before you get any results at all.
However, the TDD approach mandates that only the minimum amount of code to pass a test can be written, so given the following method signature:
bool IsSpam(string text)
And the following string of text, which is clearly spam:
"Cheap generic viagra"
The minimum amount of code I could write is:
bool IsSpam(string text)
{
return text == "Cheap generic viagra"
}
Now maybe I add another test message, e.g.
"Online viagra pharmacy"
I could change the code to:
bool IsSpam(string text)
{
return text.Contains("viagra");
}
...and so on, and so on. Until at some point the code becomes a mess of string checks, regular expressions, etc. because we've evolved it instead of thinking about it and writing it in a different way from the start.
So how is TDD supposed to work with this type of situation where evolving the code from the simplest possible code to pass the test is not the right approach? (Particularly if it is known in advance that the best implementations cannot be trivially evolved).
| 0
| 1
| 0
| 1
| 0
| 0
|
As explained here, Math.Ceiling returns: "The smallest integral value that is greater than or equal to a". But later it says: "Note that this method returns a Double type instead of an integral type." I'm just wondering why?
| 0
| 0
| 0
| 0
| 1
| 0
|
I am very new at C programming and I am working on a firmware application for my MCU. This method was working fine when I was using the KEIL compiler (Big Endian) but when I switched to the SDCC compiler (Little Endian) it is not working properly. Can someone please explain what I am doing wrong???
The target device is a Silicon Labs C8051F320 which is based on the 8051 architecture.
unsigned **int** MotorSteps = 0; //"Global" variables
unsigned **int** MotorSpeed = 0;
bit RampUp()
{
float t = 0;
t = MotorSteps;
if ( t < 51 )
{
t = (1-((50 - t)/50))*15;
t = (t * t);
MotorSpeed = 100 + t;
return 0;
}
else return 1;
}
ADDED:
First, I now changed the MotorSteps and MotorSpeed to be unsigned ints.
In my debugger, for some reason, if I set a break point at the if-statement line, on the first entrance of this function MotorSteps = 00, so t should get assigned to 0 also but the debugger shows that t=0.031497 (decimal). If I switch the debugger to display in Hex, t = 0x3d010300. It's like t is never getting assigned...
| 0
| 0
| 0
| 0
| 1
| 0
|
I have a floating point value X which is animated. When in rest it's at zero, but at times an outside source may change it to somewhere between -1 and 1.
If that happens I want it to go smoothly back to 0. I currently do something like
addToXspeed(-x * FACTOR);
// below is out of my control
function addToXspeed(bla) {
xspeed += bla;
x += xspeed;
}
every step in the animation, but that only causes X to oscillate. I want it to rest on 0 however.
(I've explained the problem in abstracts. The specific thing I'm trying to do is make a jumping game character balance himself upright in the air by applying rotational force)
| 0
| 0
| 0
| 0
| 1
| 0
|
I am forced to execute a periodic task using a timer that is invoked at a different interval as the period I'd like to execute this task.
Note that the timeout does not occur 100% accurately; i.e. timeout(javax.ejb.Timer timer) in the code below might be invoked at intervals 100, 98, 105ms etc.
So, I came up with this, which is sort of okay. But occasionally the task will be executed twice before the intended interval passes, or the interval becomes a little longer than I intend.
Do you have any better idea than this?
(Code is simplified pseudo-code, will be used within a EJB container)
import javax.annotation.Resource;
import javax.ejb.Timeout;
import javax.ejb.Timer;
import javax.ejb.TimerService;
public class TimerBean {
private static final long TASK_INTERVAL = 1530;
private static final long TIMEOUT = 100;
@Resource
private TimerService timerService;
public void startTimer() {
timerService.createTimer(100, TIMEOUT, null);
}
@Timeout
public void timeout(javax.ejb.Timer timer) {
if(isApproxTime(timer, TASK_INTERVAL)){
//do stuff
}
}
private boolean isApproxTime(Timer timer, long targetInterval) {
long modulus = timer.getNextTimeout().getTime() % targetInterval;
return modulus < TIMEOUT;
}
}
EDIT: I'd like to avoid state other than ejb.Timer, so saving the time of last invocation is not an option.
| 0
| 0
| 0
| 0
| 1
| 0
|
Assume that a task exists with two attributes: priority and due date.
Priority p is a numeric value. The priority importance increases to infinity, meaning that 5 is a priority higher than 4. Priority 0 is normal priority.
Due date d is a date in the past or in the future, when compared with the current date. A d date before now is more important than a date in the future.
The idea is to combine these two
attributes, priority and due date,
according to the rules above, in order
to produce a numeric output that can
be used to order a list of tasks.
This should be possible to model as a math function but I am rusty, to say the least, in that field. I am even not convinced if it should be a 2D function or a 3D function.
I started by a 2D graph where x-axis is for priority and y-axis is for the difference between the current date and the due date.
The upper left quadrant A1 has due dates
in the past and high priorities.
The upper right quadrant A2 has due dates in
the future and high priorities.
The lower left quadrant A3 has due dates in
the past and low priorities.
The lower right quadrant A4 has due dates in
the future and low priorities.
Any guys with math knowledge that can throw a fee pointers?
| 0
| 0
| 0
| 0
| 1
| 0
|
I want to know what is the best open source Java based framework for Text Mining, to use botg Machine Learning and dictionary Methods.
I'm using Mallet but there are not that much documentation and I do not know if it will fit all my requirements.
| 0
| 1
| 0
| 1
| 0
| 0
|
A simple question, how would I go about declaring a clause which would produce the number specified +1 +2 and +3? I have tried:
addup(Thenumber,Thenumber+1).
addup(Thenumber,Thenumber+2).
addup(Thenumber,Thenumber+3).
but when I run it with say, Thenumber=5, it just returns 5+1 5+2 5+3. I have tried using 'is' to force it to evaluate but it doesn't seem to work. Any help would be appreciated.
| 0
| 0
| 0
| 0
| 1
| 0
|
How can I render mathematical notations / expressions in Python with OpenGL?
I'm actually using pyglet however it uses OpenGL.
Such things as this:
I can't store static images as I am generating the expressions as well.
| 0
| 0
| 0
| 0
| 1
| 0
|
Thanks for stoping to read my question :) this is very sweet place full of GREAT peoples !
I have a question about "creating sentences with words". NO NO it is not about english grammar :)
Let me explain, If I have bag of words like
"person apple apple person person a eat person will apple eat hungry apple hungry"
and it can generate some kind of following sentence
"hungry person eat apple"
I don't in which field this topic will relate. Where should I try to find an answer. I tried to search google but I only found english grammar stuff :)
Any body there who can tell me which algo can work in this problem? or any program
Thanks
P.S: It is not an assignment :) if it would be i would ask for source code ! I don't even know in which field I should look for :)
| 0
| 1
| 0
| 0
| 0
| 0
|
I need to write software that will do a lot of math. Mostly it will be matrix multiplication with integers to compute DCT. How much faster should I expect the code to run in native c as compared to VB .Net? Factor of 2, factor of 10, factor of 1000...? Has someone tried and collected statistics on this?
| 0
| 0
| 0
| 0
| 1
| 0
|
I need a way to get euler angles for rotation in global frame of reference from a local. I am using c#, wpf 3d and a gyroscope. I have a globe on the screen that should move in the same way as the gyro. Since the gyro sends movement relative to itself I need to use quaternions to keep the state of the object and update it but I'm stuck. If i do the following:
var qu=eulerToQ(Gyro.X,Gyro.Y,Gyro.Z);
GlobalQu = Quaternion.Multiply(qu, GlobalQu);
IT rotates correctly on one axis. When I rotate by A in one direction and then by B in another the rotations of the object and the gyro are no longer in the same direction because the above works for absolute rotations (relative to the world).
For example:
var qu=eulerToQ(KeyboardValue1,KeyboardValue2,KeyboardValue3);
GlobalQu = qu;
This works because I am increasing the roll,pitch,yaw ie keyboard values via keyboard always on the global axis. Gyro send rotations on LOCAL axis.
Switching the order of quaternion rotation doesn't help
var qu=eulerToQ(Giro.X,Giro.Y,Giro.Z);
GlobalQu = Quaternion.Multiply(GlobalQu,qu);
| 0
| 0
| 0
| 0
| 1
| 0
|
I want to graph from one date to another date and i only partial data now
For example, i have data points for each month from jan 2010 to march 2010 but i want a line graph with a data point for each month for all of 2010.
i basically want to take the slope of the current points and create new points for each future month of 2010 to fill in for the graph.
| 0
| 0
| 0
| 0
| 1
| 0
|
Lets say I have a non-square image..
If I increment the width and I recalculate the height according to the incremented width (ratio), sometimes I get xxx.5 (decimals) for the width
ex.: width = 4, height = 2
I augment the width with a factor of 1.25 I'll get : width = 5
Next, the height will be : heigth = 2.5
How can I determine the nearest image format that would have integers on both sides? (bigger if possible)
Thanks
| 0
| 0
| 0
| 0
| 1
| 0
|
Does anyone know if there has been a port of the GNU Ballistics library to C#, java, vb, etc? Is there a similar library out there in any other language, even C++?
| 0
| 0
| 0
| 0
| 1
| 0
|
I have been looking at this piece of code, and it is not doing what I expect.
I have 3 globals.
int x, y, *pointer, z;
Inside of main I declare them.
x = 10;
y = 25;
pointer = &x;
now at this point
&x is 0x004A144
&y is 0x004A138
pointer is pointing to 0x004A144
Now when I increment:
y = *++pointer;
it points to 0x004A148, this is the address y should be at shouldn't it?
The idea is that incrementing the pointer to 'x' should increment it to point
at y, but it doesn't seem to want to declare them in in order like I expect.
If this a VS2005 / 2008 problem? Or maybe an Express problem?
This isn't really homework, as I have done it a couple of years ago but I was revising on my pointer stuff and I tried this again. But this time I am getting unexpected results. Does anyone have opinions on this?
*UPDATE
sorry should be more clear, 'thought' on declaration 'y' should be at 148, and that incrementing the pointer pointing to x should increment 'pointer' to 148 (which it does), but that isn't where y is. Why isn't y declaring where it should be.
| 0
| 0
| 0
| 0
| 1
| 0
|
I have to calculate the following:
float2 y = CONSTANT;
for (int i = 0; i < totalN; i++)
h[i] = cos(y*i);
totalN is a large number, so I would like to make this in a more efficient way. Is there any way to improve this? I suspect there is, because, after all, we know what's the result of cos(n), for n=1..N, so maybe there's some theorem that allows me to compute this in a faster way. I would really appreciate any hint.
Thanks in advance,
Federico
| 0
| 0
| 0
| 0
| 1
| 0
|
Is there any library which I can use to plot mathematical equations? (Preferably using javascript, could me in Java also; or anything clientside)
| 0
| 0
| 0
| 0
| 1
| 0
|
I'm toying with an app idea for the iPhone but I don't know where to start or even what to look for in google :) I'd like to visualize math patterns on the iPhone, similar to this http://itunes.apple.com/us/app/patterns-lite/id304565312?mt=8 ... If someone could point me into the right direction then that would be fantastic. Originally, I had the idea of plotting the math pixel by pixel onto a texture but I think I'm way off. Thanks, Carl.
| 0
| 0
| 0
| 0
| 1
| 0
|
sorry for the confusing title, its really hard for me to explain what i want. So i created this image :)
Ok so the two RED dots are points on an image. The distance between them isnt important.
What I want to do is, Using the coordinates for the two dots, work out the angle of the space between them (as shown by the black line between the red dots)
Then once the angle is found, on the last red dot, create two points which cross the angle of the first line. Then from that, scan a Half semicircle and get the coordinates of every pixel of the image that the orange line passes.
I dnot know if this makes any sense to you lot so i drew another picture:
As you can see in the second picture, my idea is applied to a line drawn on a black canavs. The two red dots are the starting coordinates then at the end of the two dots, a less then half semicircle is created. The part that is orange shows the pixels of the image that should be recorded.
I have no clue how to start this, so if anyone has any ideas on how i can or on what i need to do, any help is much appreciated :)
EDIT.
I have created this image in the hopes that it will make what i am trying to do clearer :)
Again sorry if this is confusing anyone as I really dont know how to explain it.
| 0
| 0
| 0
| 0
| 1
| 0
|
My implementation of Sieve of Atkin either overlooks primes near the limit or composites near the limit. while some limits work and others don't. I'm am completely confused as to what is wrong.
def AtkinSieve (limit):
results = [2,3,5]
sieve = [False]*limit
factor = int(math.sqrt(lim))
for i in range(1,factor):
for j in range(1, factor):
n = 4*i**2+j**2
if (n <= lim) and (n % 12 == 1 or n % 12 == 5):
sieve[n] = not sieve[n]
n = 3*i**2+j**2
if (n <= lim) and (n % 12 == 7):
sieve[n] = not sieve[n]
if i>j:
n = 3*i**2-j**2
if (n <= lim) and (n % 12 == 11):
sieve[n] = not sieve[n]
for index in range(5,factor):
if sieve[index]:
for jndex in range(index**2, limit, index**2):
sieve[jndex] = False
for index in range(7,limit):
if sieve[index]:
results.append(index)
return results
For example, when I generate a primes to the limit of 1000, the Atkin sieve misses the prime 997, but includes the composite 965. But if I generate up the limit of 5000, the list it returns is completely correct.
| 0
| 0
| 0
| 0
| 1
| 0
|
Trilinear interpolation approximates the value of a point (x, y, z) inside a cube using the values at the cube vertices. I´m trying to do an "inverse" trilinear interpolation. Knowing the values at the cube vertices and the value attached to a point how can I find (x, y, z)? Any help would be highly appreciated. Thank you!
| 0
| 0
| 0
| 0
| 1
| 0
|
similar questions have been asked before but I cant find an exact match to my question.
I have 4 vectors each of which hold between 200-500 4 digit integers. The exact number of elements in each vector varies but I could fix it to a specific value. I need to find all possible combinations of the elements in these 4 vectors.
eg:
v1[10, 30]
v2[11, 45]
v3[63, 56]
v4[82, 98]
so I'd get something like this:
[10, 11, 63, 82];
[30, 11, 63, 82];
[10, 45, 63, 82];
[10, 45, 56, 82] etc..
Is there a common name for this algorithm so I can find some references to it online? Otherwise any tips on implementing this in C++ would be helpful. Performance isn't much of an issue as I only need to run the algorithm once. Is there anything built into the STL?
| 0
| 0
| 0
| 0
| 1
| 0
|
I am working with some code which outputs a 3x3 rotation matrix and a translation vector representing a cameras orientation and location.
However, the documentation states that to get the location of the camera one must multiply the transposed and inverted rotation matrix by the translation vector. Does that mean that the original vector is not the location of the camera? If not, what does that original vector represent?
| 0
| 0
| 0
| 0
| 1
| 0
|
I have seen a few times people using -1 as opposed to 0 when working with neural networks for the input data. How is this better and does it effect any of the mathematics to implement it?
Edit: Using feedforward and back prop
Edit 2: I gave it a go but the network stopped learning so I assume the maths would have to change somewhere?
Edit 3: Finally found the answer. The mathematics for binary is different to bipolar. See my answer below.
| 0
| 0
| 0
| 0
| 1
| 0
|
So I have a counter. It is supposed to calculate the current amount of something. To calculate this, I know the start date, and start amount, and the amount to increment the counter by each second. Easy peasy. The tricky part is that the growth is not quite linear. Every day, the increment amount increases by a set amount. I need to recreate this algorithmically - basically figure out the exact value at the current date based on the starting value, the amount incremented over time, and the amount the increment has increased over time.
My target language is Javascript, but pseudocode is fine too.
Based on AB's solution:
var now = new Date();
var startDate1 = new Date("January 1 2010");
var days1 = (now - startDate1) / 1000 / 60 / 60 / 24;
var startNumber1 = 9344747520;
var startIncrement1 = 463;
var dailyIncrementAdjustment1 = .506;
var currentIncrement = startIncrement1 + (dailyIncrementAdjustment1 * days1);
startNumber1 = startNumber1 + (days1 / 2) * (2 * startIncrement1 + (days1 - 1) * dailyIncrementAdjustment1);
Does that look reasonable to you guys?
| 0
| 0
| 0
| 0
| 1
| 0
|
I come from an MVC background (Flex and Rails) and love the ideas of code separation, reusability, encapsulation, etc. It makes it easy to build things quickly and reuse components in other projects. However, it has been very difficult to stick with the MVC principles when trying to build complex, state-driven, asynchronous, animated applications.
I am trying to create animated transitions between many nested views in an application, and it got me thinking about whether or not I was misleading myself... Can you apply principles from MVC to principles from Artificial Intelligence (Behavior-Trees, Hierarchical State Machines, Nested States), like Games? Do those two disciplines play nicely together?
It's very easy to keep the views/graphics ignorant of anything outside of themselves when things are static, like with an HTML CMS system or whatever. But when you start adding complex state-driven transitions, it seems like everything needs to know about everything else, and the MVC almost gets in the way. What do you think?
Update:
An example. Well right now I am working on a website in Flex. I have come to the conclusion that in order to properly animate every nested element in the application, I have to think of them as AI Agents. Each "View", then, has it's own Behavior Tree. That is, it performs an action (shows and hides itself) based on the context (what the selected data is, etc.). In order to do that, I need a ViewController type thing, I'm calling it a Presenter. So I have a View (the graphics laid out in MXML), a Presenter (defining the animations and actions the View can take based on the state and nested states of the application), and a Presentation Model to present the data to the View (through the presenter). I also have Models for value objects and Controllers for handling URLs and database calls etc... all the normal static/html-like MVC stuff.
For a while there I was trying to figure out how to structure these "agents" such that they could respond to their surrounding context (what's selected, etc.). It seemed like everything needed to be aware of everything else. And then I read about a Path/Navigation Table/List for games and immediately thought they have a centrally-stored table of all precalculated actions every agent can take. So that got me wondering how they actually structure their code.
All of the 3D video game stuff is a big secret, and a lot of it from what I see is done with a graphical UI/editor, like defining behavior trees. So I'm wondering if they use some sort of MVC to structure how their agents respond to the environment, and how they keep their code modular and encapsulated.
| 0
| 1
| 0
| 0
| 0
| 0
|
Im writing a WPF application that has a zoom and pan ability, but what I want to also implement is the ability to zoom and pan "automatically" (via a button click).
I have the methods all defined to zoom and pan, but Im having trouble telling the app the desired X/Y coordinates for the panning.
Basically, I know that I want the control to be centered at a desired zoom level (say zoomed in 6X times), but the panning destination point is NOT the center point of the control because after the zooming, its been scaled.
Does anyone know a way of calculating the desired X/Y position to pan to, taking into account the zooming as well? Do I just scale the desired destination Point? It doesnt seem to work for me...
Thanks a lot
EDIT -- COMPLETED --
Here is now what I have which is working just fine :)
<Canvas x:Name="LayoutRoot" Background="{DynamicResource WindowBackground}" Width="1024" Height="768">
<Canvas x:Name="ProductCanvas" Width="1024" Height="768">
<Canvas.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform />
</TransformGroup>
</Canvas.RenderTransform>
<Rectangle x:Name="r1" Fill="White" Stroke="Black" Width="180" Height="103.5" Canvas.Left="131.5" Canvas.Top="121.5" MouseDown="r1_MouseDown"/>
<Rectangle x:Name="r2" Fill="#FF942222" Stroke="Black" Width="180" Height="103.5" Canvas.Left="617.5" Canvas.Top="121.5" MouseDown="r2_MouseDown"/>
<Rectangle x:Name="r3" Fill="#FF2B1E9F" Stroke="Black" Width="180" Height="103.5" Canvas.Left="131.5" Canvas.Top="408" MouseDown="r3_MouseDown"/>
<Rectangle x:Name="r4" Fill="#FF1F6E1D" Stroke="Black" Width="180" Height="103.5" Canvas.Left="617.5" Canvas.Top="408" MouseDown="r4_MouseDown"/>
</Canvas>
</Canvas>
----C#----
private void r1_MouseDown(object sender, MouseButtonEventArgs e1)
{
Rect bounds = r1.TransformToAncestor(ProductCanvas).TransformBounds(new Rect(0, 0, r1.ActualWidth, r1.ActualHeight));
ZoomInAndPan(5, new Point(bounds.TopLeft.X + (bounds.Width / 2), bounds.TopLeft.Y + (bounds.Height / 2)));
}
private void r2_MouseDown(object sender, MouseButtonEventArgs e1)
{
Rect bounds = r2.TransformToAncestor(ProductCanvas).TransformBounds(new Rect(0, 0, r2.ActualWidth, r2.ActualHeight));
ZoomInAndPan(5, new Point(bounds.TopLeft.X + (bounds.Width / 2), bounds.TopLeft.Y + (bounds.Height / 2)));
}
private void r3_MouseDown(object sender, MouseButtonEventArgs e1)
{
Rect bounds = r3.TransformToAncestor(ProductCanvas).TransformBounds(new Rect(0, 0, r3.ActualWidth, r3.ActualHeight));
ZoomInAndPan(5, new Point(bounds.TopLeft.X + (bounds.Width / 2), bounds.TopLeft.Y + (bounds.Height / 2)));
}
private void r4_MouseDown(object sender, MouseButtonEventArgs e1)
{
Rect bounds = r4.TransformToAncestor(ProductCanvas).TransformBounds(new Rect(0, 0, r4.ActualWidth, r4.ActualHeight));
ZoomInAndPan(5, new Point(bounds.TopLeft.X + (bounds.Width/2), bounds.TopLeft.Y + (bounds.Height/2)));
}
public void ZoomInAndPan(double zoomTo, Point translateTarget)
{
var group = (ProductCanvas.RenderTransform as TransformGroup);
var zoomTransform = group.Children[0] as ScaleTransform;
var translateTransform = group.Children[3] as TranslateTransform;
Point center = new Point(512, 384);
destinationPoint.X *= newScale;
destinationPoint.Y *= newScale;
var deltaX = center.X - (translateTarget.X);
var deltaY = center.Y - (translateTarget.Y);
translateTransform.BeginAnimation(TranslateTransform.XProperty, CreateZoomAnimation(deltaX));
translateTransform.BeginAnimation(TranslateTransform.YProperty, CreateZoomAnimation(deltaY));
zoomTransform.BeginAnimation(ScaleTransform.ScaleXProperty, CreateZoomAnimation(zoomTo));
zoomTransform.BeginAnimation(ScaleTransform.ScaleYProperty, CreateZoomAnimation(zoomTo));
}
private DoubleAnimation CreateZoomAnimation(double toValue)
{
var da = new DoubleAnimation(toValue, new Duration(TimeSpan.FromMilliseconds(700)))
{
AccelerationRatio = 0.1,
DecelerationRatio = 0.9
};
return da;
}
| 0
| 0
| 0
| 0
| 1
| 0
|
On paper, binary arithmetic is simple, but as a beginning programmer, I'm finding it a little difficult to come up with algorithms for the addition, subtraction, multiplication and division of binary numbers.
I have two binary numbers stored as strings, assume that any leading zeroes have been dropped. How would I go about performing these operations on the two numbers?
Edit: I need to avoid converting them to an int or long.
| 0
| 0
| 0
| 0
| 1
| 0
|
I'm not sure whats the best algorithm to use for the classification of relationships in words. For example in the case of a sentence such as "The yellow sun" there is a relationship between yellow and sun. THe machine learning techniques I have considered so far are Baynesian Statistics, Rough Sets, Fuzzy Logic, Hidden markov model and Artificial Neural Networks.
Any suggestions please?
thank you :)
| 0
| 1
| 0
| 1
| 0
| 0
|
Is there any open-source software that is trying to implement and emulate the human brain (e.g. intelligence and feelings)?
| 0
| 1
| 0
| 0
| 0
| 0
|
I got the example in this link.
I can't understand the addmove, costLeven and meatureGesture methods.
Can you explain it step by step?
| 0
| 0
| 0
| 0
| 1
| 0
|
I have trained xor neural network in MATLAB and got these weights:
iw: [-2.162 2.1706; 2.1565 -2.1688]
lw: [-3.9174 -3.9183]
b{1} [2.001; 2.0033]
b{2} [3.8093]
Just from curiosity I have tried to write MATLAB code which computes the output of this network (two neurons in the hidden layer, and one in the output, TANSIG activation function).
Code that I got:
l1w = [-2.162 2.1706; 2.1565 -2.1688];
l2w = [-3.9174 -3.9183];
b1w = [2.001 2.0033];
b2w = [3.8093];
input = [1, 0];
out1 = tansig (input(1)*l1w(1,1) + input(2)*l1w(1,2) + b1w(1));
out2 = tansig (input(1)*l1w(2,1) + input(2)*l1w(2,2) + b1w(2));
out3 = tansig (out1*l2w(1) + out2*l2w(2) + b2w(1))
The problem is when input is lets say [1,1], it outputs -0.9989, when [0,1] 0.4902. While simulating network generated with MATLAB outputs adequately are 0.00055875 and 0.99943.
What am I doing wrong?
| 0
| 0
| 0
| 1
| 0
| 0
|
How can I measure the speed of code written in Java?
I planning to develop software which will solve Sudoku using all presently available AI and ML algorithms and compare time against simple brute-force method. I need to measure time of each algorithm, I would like to ask for suggestions on what is the best way of doing that? Very important, program must be useful on any machine regardless to CPU power/memory.
Thank you.
| 0
| 1
| 0
| 1
| 0
| 0
|
Given that we start the call to the function ran2 with a negative integer [the seed] it will produce a series of random numbers. The sequence can be regenerated exactly if the same seed is used.
Now my question is that is there a way that we can directly enter into some point in the sequence and then continue from that point onwards ? For example if the random numbers for a certain seed are 0.35, 0.32, 0.44,0.32,0.66,0.32, 0.45.
If we know that seed which gave rise to this sequence, is there a way to get the function to return 0.66 and then continue from that point onwards?
The way I want to use it is in a simulation. Whereby if my simulation ends at a certain point and I need to restart it I should continue with the same sequence of random numbers.
Thanks.
| 0
| 0
| 0
| 0
| 1
| 0
|
(I asked this question earlier today, but I did a poor job of explaining myself. Let me try again)
I have a client who is an industrial maintenance company. They sell service agreements that are prepaid 20 hour blocks of a technician's time. Some of their larger customers might burn through that agreement in two weeks while customers with fewer problems might go eight months on that same contract. I would like to use Python to help model projected sales revenue and determine how many billable hours per month that they'll be on the hook for.
If each customer only ever bought a single service contract (never renewed) it would be easy to figure sales as monthly_revenue = contract_value * qty_contracts_sold. Billable hours would also be easy: billable_hrs = hrs_per_contract * qty_contracts_sold. However, how do I account for renewals? Assuming that 90% (or some other arbitrary amount) of customers renew, then their monthly revenue ought to grow geometrically. Another important variable is how long the average customer burns through a contract. How do I determine what the revenue and billable hours will be 3, 6, or 12 months from now, based on various renewal and burn rates?
I assume that I'd use some type of recursive function but math was never one of my strong points. Any suggestions please?
Edit: I'm thinking that the best way to approach this is to think of it as a "time value of money" problem. I've retitled the question as such. The problem is probably a lot more common if you think of "monthly sales" as something similar to annuity payments.
| 0
| 0
| 0
| 0
| 1
| 0
|
I want to detect one kind of object such as person in the picture,
who can tell me how to training a kind of people classifier for use,so we can use the classifier to detect people in any picture.
| 0
| 0
| 0
| 1
| 0
| 0
|
This is a community wiki which aims to provide a good design for a machine learning/artificial intelligence framework (ML/AI framework).
Please contribute to the design of a language-agnostic framework which would allow multiple ML/AI algorithms to be plugged into a single framework which:
runs the algorithms with a user-specified data set.
facilitates learning, qualification, and classification.
allows users to easily plug in new algorithms.
can aggregate or create an ensemble of the existing algorithms.
can save/load the progress of the algorithm (i.e. save the network and weights of a neural network, save the tree of a decision tree, etc.).
What is a good design for this sort of ML/AI framework?
| 0
| 1
| 0
| 1
| 0
| 0
|
I have a number of 3x3 matricess that I want to multiply together For example:
m1*m2*m3*m4*m5
Although MTL is a recommended way, I don't have this library and can't use it.
Can someone please suggest a conventional way to multiply these 3x3 matrices (all matrices m1 to m5). Code snippet (for matrix multiplication and multiplying n matrices together) or pointer to some online code will be very useful
| 0
| 0
| 0
| 0
| 1
| 0
|
Let the user write/draw a character on the canvas,and recognize it.
Seems not so easy,is there an open source project for this?
| 0
| 1
| 0
| 0
| 0
| 0
|
I have a simple photograph that may or may not include a logo image. I'm trying to identify whether a picture includes the logo shape or not. The logo (rectangular shape with a few extra features) could be of various sizes and could have multiple occurrences. I'd like to use Computer Vision techniques to identify the location of these logo occurrences. Can someone point me in the right direction (algorithm, technique?) that can be used to achieve this goal?
I'm quite a novice to Computer Vision so any direction would be very appreciative.
Thanks!
| 0
| 0
| 0
| 1
| 0
| 0
|
I have a surface which is a polyhedron and I want to find the minimal distance between it and a given point P. Since the polyhedron is defined by many polygons in a 3d space, one way that occurs to me is to compare the distance to each polygon and choose the shortest distance. Still I am not sure about it.
| 0
| 0
| 0
| 0
| 1
| 0
|
Best to use an example to describe the problem. Lets say I have a decimal value 100.227273.
100.227273 * X = Y
I need to find the smallest positive integer X that gives integer Y.
| 0
| 0
| 0
| 0
| 1
| 0
|
We have studied the Variable Elimination recently and the teacher emphasizes that it is the Bayesian Network that makes varibale elimination more efficient.
I am bit confused on this,why is this the case?
Hope you guys can give me some idea,many thanks.
Robert
| 0
| 1
| 0
| 0
| 0
| 0
|
I'm creating a game where players can make an alloy. To make it less predictable and more interesting, I thought that the durability and hardness of an alloy should not be calculated by a simple formula, because it will be extremely easy to find extrema, where alloy have best statistics.
So the questions is, is there any formula for a function where extrema can be found only by investigating all points? Input values will be in percents: 0.0%-100.0%. I think it should look like this: half sound wave
| 0
| 0
| 0
| 0
| 1
| 0
|
Possible Duplicate:
Is Programming == Math?
Programmers seem to think that their work is quite mathematical.
I understand this when you try to optimize something in performance, find the most efficient alogithm, etc..
But it patently seems false when you look at a billing application for a shop, or a systems software riddled with I/O calls.
So what is it exactly? Is computation and associated programming really mathematical?
Here I have in mind particularly the words of the philosopher Schopenhauer in mind:
That arithmetic is the basest of all mental activities is proved by
the fact that it is the only one that can be accomplished by means of
a machine. Take, for instance, the reckoning machines that are so
commonly used in England at the present time, and solely for the sake
of convenience. But all analysis finitorum et infinitorum is
fundamentally based on calculation. Therefore we may gauge the
“profound sense of the mathematician,” of whom Lichtenberg has made
fun, in that he says: “These so-called professors of mathematics have
taken advantage of the ingenuousness of other people, have attained
the credit of possessing profound sense, which strongly resembles the
theologians’ profound sense of their own holiness.”
I lifted the above quote from here. It seems that programmers are doing precisely the sort of mechanized base mental activity the grand old man is contemptuous about.
So what exactly is the deal? Is programming really the "good" kind of mathematics, or just the baser type, or altogether something else just meant for business not to be confused with a pure discipline?
| 0
| 0
| 0
| 0
| 1
| 0
|
I've never really bothered with math programming, but today I've decided to give it a shot.
Here's my code and it's working as intended:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace PrimeFactorization
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void btnSubmit_Click(object sender, RoutedEventArgs e)
{
List<int> primeFactors = FindPrimeFactors(Convert.ToInt32(txtNumber.Text));
primeFactors.Sort();
for (int i = 0; i < primeFactors.Count; i++)
{
listBoxFoundNumbers.Items.Add(primeFactors[i]);
}
}
private List<int> FindPrimeFactors(int number)
{
List<int> factors = new List<int>();
factors.Add(1);
factors.Add(number);
for (int i = 2; i < number; i++)
{
if (number % i == 0)
{
int holder = number / i;
//If the number is in the list, don't add it again.
if (!factors.Contains(i))
{
factors.Add(i);
}
//If the number is in the list, don't add it again.
if (!factors.Contains(holder))
{
factors.Add(holder);
}
}
}
return factors;
}
}
}
The only problem I can see with my code is that it will iterate through to the bitter end, even though there will definitely not be any factors.
For example, imagine I wrote in 35. My loop will go up to 35 and check 24,25,26,27...etc. Not very good.
What do you recommend?
| 0
| 0
| 0
| 0
| 1
| 0
|
if i have two positive integers, say 0x1234 and 0x5678, is 0x8765 + 0xfedc = 0x8641, if the '+' means two's complement addition, mod 2^16?
| 0
| 0
| 0
| 0
| 1
| 0
|
Im trying to plot the roots of a polynomial, and i just cant get it.
First i create my polynomial
p5 = [1 0 0 0 0 -1] %x^5 - 1
r5 = roots(p5)
stem (p5)
Im using the stem function, but I would like to remove the stems, and just get the circle around the roots.
Is this possible, is stem the right command?
Thanks in advance,
PS: This is not homework, but very close, will tag it if requested.
| 0
| 0
| 0
| 0
| 1
| 0
|
Possible Duplicate:
Estimating/forecasting download completion time
We've all seen the download time running estimate that initially says something like "7 days", but keeps dropping wildly (e.g. "23 hours", "45 minutes", "1 min. 50 sec", etc) with each successive estimation as the chunks are downloaded.
To avoid these initial (alarming) estimates, there are techniques one could try like suppressing display of the first n estimates, or waiting for the delta between estimates to drop below some threshold before you start displaying them, but these don't seem like a general, robust solution. There are corner cases involving too few samples, or samples that actually are wildly varying...
I think I recall a general solution for this kind of thing in mathematics (statistics?) that reduced or eliminated these wild values.
Does anyone know?
Edit:
OK, looks like this has already been asked and answered:
Estimating/forecasting download completion time
My question even starts out with the same wording as this one. Funny...
Algo for a stable ‘download-time-remaining’ in a download window
| 0
| 0
| 0
| 0
| 1
| 0
|
I cannot understand why this throws undefined reference to `floor'":
double curr_time = (double)time(NULL);
return floor(curr_time);
Hasn't it been casted to double, which is what floor receives?
| 0
| 0
| 0
| 0
| 1
| 0
|
I've been playing around with a set of templates for determining the correct promotion type given two primitive types in C++. The idea is that if you define a custom numeric template, you could use these to determine the return type of, say, the operator+ function based on the class passed to the templates. For example:
// Custom numeric class
template <class T>
struct Complex {
Complex(T real, T imag) : r(real), i(imag) {}
T r, i;
// Other implementation stuff
};
// Generic arithmetic promotion template
template <class T, class U>
struct ArithmeticPromotion {
typedef typename X type; // I realize this is incorrect, but the point is it would
// figure out what X would be via trait testing, etc
};
// Specialization of arithmetic promotion template
template <>
class ArithmeticPromotion<long long, unsigned long> {
typedef typename unsigned long long type;
}
// Arithmetic promotion template actually being used
template <class T, class U>
Complex<typename ArithmeticPromotion<T, U>::type>
operator+ (Complex<T>& lhs, Complex<U>& rhs) {
return Complex<typename ArithmeticPromotion<T, U>::type>(lhs.r + rhs.r, lhs.i + rhs.i);
}
If you use these promotion templates, you can more or less treat your user defined types as if they're primitives with the same promotion rules being applied to them. So, I guess the question I have is would this be something that could be useful? And if so, what sorts of common tasks would you want templated out for ease of use? I'm working on the assumption that just having the promotion templates alone would be insufficient for practical adoption.
Incidentally, Boost has something similar in its math/tools/promotion header, but it's really more for getting values ready to be passed to the standard C math functions (that expect either 2 ints or 2 doubles) and bypasses all of the integral types. Is something that simple preferable to having complete control over how your objects are being converted?
TL;DR: What sorts of helper templates would you expect to find in an arithmetic promotion header beyond the machinery that does the promotion itself?
| 0
| 0
| 0
| 0
| 1
| 0
|
I have a set of points like: pointA(3302.34,9392.32), pointB(34322.32,11102.03), etc.
I need to scale these so each x- and y-coordinate is in the range (0.0 - 1.0).
I tried doing this by first finding the largest x value in the data set (maximum_x_value), and the largest y value in the set (minimum_y_value). I then did the following:
pointA.x = (pointA.x - minimum_x_value) / (maximum_x_value - minimum_x_value)
pointA.y = (pointA.y - minimum_y_value) / (maximum_y_value - minimum_y_value)
This changes the relative distances(?), and therefore makes the data useless for my purposes. Is there a way to scale these coordinates while keeping their relative distances the intact?
| 0
| 0
| 0
| 0
| 1
| 0
|
I Hear that google uses up to 7-grams for their semantic-similarity comparison. I am interested in finding words that are similar in context (i.e. cat and dog) and I was wondering how do I compute the similarity of two words on a n-gram model given that n > 2.
So basically given a text, like "hello my name is blah blah. I love cats", and I generate a 3-gram set of the above:
[('hello', 'my', 'name'),
('my', 'name', 'is'),
('name', 'is', 'blah'),
('is', 'blah', 'blah'),
('blah', 'blah', 'I'),
('blah', 'I', 'love'),
('I', 'love', 'cats')]
PLEASE DO NOT RESPOND IF YOU ARE NOT GIVING SUGGESTIONS ON HOW TO DO THIS SPECIFIC NGRAM PROBLEM
What kind of calculations could I use to find the similarity between 'cats' and 'name'? (which should be 0.5) I know how to do this with bigram, simply by dividing freq(cats,name)/ ( freq(cats,) + freq(name,) ). But what about for n > 2?
| 0
| 1
| 0
| 1
| 0
| 0
|
Basically I did the Cavendish experiment, and I have a damped sinusoidal wave plotted on Excel. With Position (mm) against Time (s).
My problem is that I have added a tread line through the wave function, and wish to calculate the points of which the wave function intersects the tread line. From this I will then be able to calculate the time period.
At the moment I'm just having difficulty getting the intersects..
Thanks
| 0
| 0
| 0
| 0
| 1
| 0
|
I'm using emacs and auctex to write LaTeX documents. For some reason, M-e doesn't move to the end of the sentence in tex-mode as it did when I went through the tutorial. It moves to the end of the paragraph. (That is, it moves to just before the next double line break)
What is wrong? Do I need to turn on/off some mode to skip to the next full stop? How do I check which modes are active?
| 0
| 1
| 0
| 0
| 0
| 0
|
I am trying to solve the problem Secret Code on SPOJ, and it's obviously a math problem.
The full problem
For those who are lazy to go and read, it's like this:
a0, a1, a2, ..., an - sequence of N numbers
B - a Complex Number (has both real and imaginary components)
X = a0 + a1*B + a2*(B^2) + a3*(B^3) + ... + an*(B^n)
So if you are given B and X, you should find a0, a1, ..an.
I don't know how or where to start, because not even N is known, just X and B.
The problem is not as easy as expressing a number in a base B, because B is a complex number.
How can it be solved?
| 0
| 0
| 0
| 0
| 1
| 0
|
While writing a model editor, besides enabling raytracing I can think about couple of operations where I'd like to find an very good approximation about the intersection point between a ray and a triangular bezier patch.
How to do this? I know couple of ways but likely there's better ones.
Exact use-cases: I might want to use one bezier triangle patch as a reference surface for drawing detailed shapes with mouse. I might too want to pinpoint a splitting-point from such patch.
If there's C source code for it, I might like to see that too. Perhaps even use it instead of rolling my own code.
| 0
| 0
| 0
| 0
| 1
| 0
|
I am working with a hexagonal grid. I have chosen to use this coordinate system because it is quite elegant.
This question talks about generating the coordinates themselves, and is quite useful. My issue now is in converting these coordinates to and from actual pixel coordinates. I am looking for a simple way to find the center of a hexagon with coordinates x,y,z. Assume (0,0) in pixel coordinates is at (0,0,0) in hex coords, and that each hexagon has an edge of length s. It seems to me like x,y, and z should each move my coordinate a certain distance along an axis, but they are interrelated in an odd way I can't quite wrap my head around it.
Bonus points if you can go the other direction and convert any (x,y) point in pixel coordinates to the hex that point belongs in.
| 0
| 0
| 0
| 0
| 1
| 0
|
I have a system which uploads to a server file by file and displays a progress bar on file upload progress, then underneath a second progress bar which I want to indicate percentage of batch complete across all files queued to upload.
Information and algorithms I can work out are:
Bytes Sent / Total Bytes To Send = First progress bar (eg. 512KB of 1024KB (50%))
That works fine.
However supposing I have two other files left to upload, but both file sizes are unknown (as this is only known once the file is about to commence upload, at which point it is compressed and file size is determined) how would I go about making my third progress bar?
I didn't think this would be possible as I would need "Total Bytes Sent" / "Total Bytes To Send", to replicate the logic of my first progress bar on a larger scale, however I did get a version working:
"Current file number we are on" / "total number of files to send" returning the percentage through the batch, however obviously will not incrementally update and it's pretty crude.
So on further thinking I thought if I could incorporate the current file % with this algorithm I could perhaps get the correct progress percentage of my batch's current point.
I tried this algorithm, but alas to no such avail (sorry to any math heads, it's probably quite apparent why it won't work)
("Current file number we are on" / "total number of files to send") * ("Bytes Sent" / "Total Bytes To Send")
For example I thought I was on the right track when testing with this example: 2/3 (2nd of 3rd file) = 66% (this is right so far) but then when I added * 0.20 (for indicating only 20% of 2nd file has uploaded) we went back to 13%. What I need is only a little over 33%! I did try the inverse at 0.80 and a (2/3 * (2/3 * 0.2))
Can this be done without knowing entire bytes in batch to upload?
Please help! Thank you!
| 0
| 0
| 0
| 0
| 1
| 0
|
I'm in the situation where i need to do some math related stuff in c# and for that i need some external libarys. The tool i look for should do the following actions:
Process sound(wave/mp3):
Normalize the amplitude
Normalize the phase
Any idea which way to go? And is there a big difference if I should to it on mp3 instead of wav
Michael.
| 0
| 0
| 0
| 0
| 1
| 0
|
I am about to embark on a new project - a video website. Users will be able to register, and vote on videos by clicking "like" or "dislike", or something to that effect. In any event, it will be a 2-option voting system, not a 5-star system.
Every X number of days, I will be generating a "chart" of the most popular videos. So my question is: how should I determine the popularity of a given video?
If I went the route of tallying up the videos with the most views, this could have the effect of exceptionally bad videos making it to the of the charts (just because they're so bad).
If I go the route of a scoring system based on the amount of "like" and "dislike" votes (eg. 100 like votes, and 50 dislike votes equals a score of 2), videos with few views could appear on the top of the charts.
So, what I need to do is a combination of the two. Barring, of course, spammy views and votes.
What's your guys' thoughts on the subject?
Edit: the following tags were removed: [mysql] [postgresql], to make room for other, more representative tags; the SQL technology used in the intended implementation does not seem to bear much on the considerations regarding the rating model per-se.
| 0
| 0
| 0
| 0
| 1
| 0
|
I particularly like the transduce feature offered by agfl in their EP4IR
http://www.agfl.cs.ru.nl/EP4IR/english.html
The download page is here:
http://www.agfl.cs.ru.nl/download.html
Is there any way i can make use of this in a c# program? Do I need to convert classes to c#?
Thanks
:)
| 0
| 1
| 0
| 0
| 0
| 0
|
I need to generate a series of N random binary variables with a given correlation function. Let x = {xi} be a series of binary variables (taking the value 0 or 1, i running from 1 to N). The marginal probability is given Pr(xi = 1) = p, and the variables should be correlated in the following way:
Corr[ xi xj ] = const × |i−j|−α (for i!=j)
where α is a positive number.
If it is easier, consider the correlation function:
Corr[ xi xj ] = (|i−j|+1)−α
The essential part is that I want to investigate the behavior when the correlation function goes like a power law. (not α|i−j| )
Is it possible to generate a series like this, preferably in Python?
| 0
| 0
| 0
| 0
| 1
| 0
|
Forgive me if this is a dumb beginners problem, but I really don't get it.
I have a member variable declared like so:
public Double Value;
When I assign 3.14159265 to Value and try to compute the sine of it, this happens:
system.out.println(Value.toString()); //outputs 3.14159265
Value = Math.sin(Value);
system.out.println(Value.toString()); //outputs NaN
In fact, this happens with every single value I tried - even with 0!
Math.sin() seems to always produce NaN as a result, regardless of the arguments value.
The docs say:
If the argument is NaN or an infinity, then the result is NaN.
But my argument is clearly not NaN or infinity!
What the heck is happening there?
UPDATE
Turns out I'm the dumbest programmer on earth. In my project the whole code is of course much more complex than the example above. It's kind of an expression parser & evaluator and for the defined mathematical functions I use a switch-clause to decide which function to call - I forgot the break statement in the cases which caused the sqrt function to be executed with a negative parameter.
As I said - dumbest programmer on earth...
I accepted the topmost answer as it is the best imho. Sorry guys for wasting your time -.-
| 0
| 0
| 0
| 0
| 1
| 0
|
I am currently in the planning stages of a game for google app engine, but cannot wrap my head around how I am going to handle AI. I intend to have persistant NPCs that will move about the map, but short of writing a program that generates the same XML requests I use to control player actions, than run it on another server I am stuck on how to do it. I have looked at the Task Queue feature, but due to long running processes not being an option on the App engine, I am a little stuck.
I intend to run multiple server instances with 200+ persistant NPC entities that I will need to update. Most action is slowly roaming around based on player movements/concentrations, and attacking close range players...(you can probably guess the type of game im developing)
| 0
| 1
| 0
| 0
| 0
| 0
|
how can i calculate the polynomial that has the tangent lines (1) y = x where x = 1, and (2) y = 1 where x = 365
I realize this may not be the proper forum but I figured somebody here could answer this in jiffy.
Also, I am not looking for an algorithm to answer this. I'd just like like to see the process.
Thanks.
I guess I should have mentioned that i'm writing an algorithm for scaling the y-axis of flotr graph
| 0
| 0
| 0
| 0
| 1
| 0
|
I'm trying to write a function :
Input:
Source range, Source value, output range, curve type (Linear, smooth)
Output:
The output is the "source value" converted into the "output range"
according to the curve type.
I hope I am making sense here...
Any ideas ?
Thanks.
| 0
| 0
| 0
| 0
| 1
| 0
|
I'm looking for an algorithm that given two permutations of a sequence (e.g. [2, 3, 1, 4] and [4, 1, 3, 2]) calculates the cycles that are needed to convert the first into the second (for the example, [[0, 3], [1, 2]]).
The link from mathworld says that Mathematica's ToCycle function does that, but sadly I don't have any Mathematica license at hand... I'd gladly receive any pointer to an implementation of the algorithm in any FOSS language or mathematics package.
Thanks!
| 0
| 0
| 0
| 0
| 1
| 0
|
Out of no particular reason I decided to look for an algorithm that produces all possible choices of k integers between 1...n, where the order amongst the k integer doesn't matter (the n choose k thingy).
From the exact same reason, which is no reason at all, I also implemented it in C#. My question is:
Do you see any mistake in my algorithm or code? And, more importantly, can you suggest a better algorithm?
Please pay more attention to the algorithm than the code itself. It's not the prettiest code I've ever written, although do tell if you see an error.
EDIT: Alogirthm explained -
We hold k indices.
This creates k nested for loops, where loop i's index is indices[i].
It simulates k for loops where indices[i+1] belongs to a loop nested within the loop of indices[i].
indices[i] runs from indices[i - 1] + 1 to n - k + i + 1.
CODE:
public class AllPossibleCombination
{
int n, k;
int[] indices;
List<int[]> combinations = null;
public AllPossibleCombination(int n_, int k_)
{
if (n_ <= 0)
{
throw new ArgumentException("n_ must be in N+");
}
if (k_ <= 0)
{
throw new ArgumentException("k_ must be in N+");
}
if (k_ > n_)
{
throw new ArgumentException("k_ can be at most n_");
}
n = n_;
k = k_;
indices = new int[k];
indices[0] = 1;
}
/// <summary>
/// Returns all possible k combination of 0..n-1
/// </summary>
/// <returns></returns>
public List<int[]> GetCombinations()
{
if (combinations == null)
{
combinations = new List<int[]>();
Iterate(0);
}
return combinations;
}
private void Iterate(int ii)
{
//
// Initialize
//
if (ii > 0)
{
indices[ii] = indices[ii - 1] + 1;
}
for (; indices[ii] <= (n - k + ii + 1); indices[ii]++)
{
if (ii < k - 1)
{
Iterate(ii + 1);
}
else
{
int[] combination = new int[k];
indices.CopyTo(combination, 0);
combinations.Add(combination);
}
}
}
}
I apologize for the long question, it might be fit for a blog post, but I do want the community's opinion here.
Thanks,
Asaf
| 0
| 0
| 0
| 0
| 1
| 0
|
I need to determine the amount left of a time cycle. To do that in C I would use fmod. But in ada I can find no reference to a similar function. It needs to be accurate and it needs to return a float for precision.
So how do I determine the modulus of a Float in Ada 95?
elapsed := time_taken mod 10.348;
left := 10.348 - elapsed;
delay Duration(left);
| 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.