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 represent sentences in RDF format.
In other words "John likes coke" would be automatically represented as:
Subject : John
Predicate : Likes
Object : Coke
Does anyone know where I should start? Are there any programs which can do this automatically or would I need to do everything from scratch?
| 0
| 1
| 0
| 0
| 0
| 0
|
Related:
Forum post
Before reinventing the wheel, I need to know whether such method exists. Stripping words according to a list such as list does not sound challenging but there are linguistic aspects, such as which words to stress the most in stripping, how about context?
| 0
| 1
| 0
| 0
| 0
| 0
|
Is there an efficient way to get the least non-negative residue modulo n, where n is positive, in C?
This is quite easy if the number is non-negative, then it's just a % n (where a is the non-negative integer).
However when a is negative, it appears the behaviour, in C89, is implementation defined (thanks kennyTM). I.e. -2 % 11 = -2 or 9.
| 0
| 0
| 0
| 0
| 1
| 0
|
I'm trying to implement the Solovoy-Strassen primality test for arbritrary large integers. I will also be writing a bignum (cannot use 3rd party implementation as this is an academic project). I have decided on the following structure for the bignum:
struct {
uint64_t *tab;
int size; // number of limbs
int sign;
}
I will be using base-32 for my digits (hence uint64_t, for partial products, at least I assume they will be partial products). This decision was based on a previous question asked.
I'm at a standstill. I cannot conceive how one can take a string represented as an arbitrary size decimal and convert it into the bignum structure above.
Could someone please enlighten me. Even a smaller example would be nice, such as converting maybe an arbitrary string into octal digits which would be stored in a uint16_t array.
Thanks.
| 0
| 0
| 0
| 0
| 1
| 0
|
I know is a rather simple question but I just can't find an appropriate example in google or anywhere.
I've got this piece
int numberOfPlays = int.Parse(textBox2.Text);
numberOfPlays = (numberOfPlays++);
textBox2.Text = (numberOfPlays.ToString());
MessageBox.Show(numberOfPlays.ToString());
So basically what I want to do is to get the value of the textBox2, make it an integer and then add 1 to it.
I can't think of any more details right now, so if i'm not clear enough please ask
Thanks in advance
| 0
| 0
| 0
| 0
| 1
| 0
|
I would like to populate an 2 dimensional array, from a vector.
I think the best way to explain myself is to put some examples (with a array of [3,5] length).
When vector is: [1, 0]
[
[4, 3, 2, 1, 0],
[4, 3, 2, 1, 0],
[4, 3, 2, 1, 0]
]
When vector is: [-1, 0]
[
[0, 1, 2, 3, 4],
[0, 1, 2, 3, 4],
[0, 1, 2, 3, 4]
]
When vector is: [-2, 0]
[
[0, 0, 1, 1, 2],
[0, 0, 1, 1, 2],
[0, 0, 1, 1, 2]
]
When vector is: [1, 1]
[
[2, 2, 2, 1, 0],
[1, 1, 1, 1, 0],
[0, 0, 0, 0, 0]
]
When vector is: [0, 1]
[
[2, 2, 2, 2, 2],
[1, 1, 1, 1, 1],
[0, 0, 0, 0, 0]
]
Have you got any ideas, a good library or a plan?
Any comments are welcome. Thanks.
Note: I consulted Ruby "Matrix" and "Vector" classes, but I don't see any way to use it in my way...
Edit: In fact, each value is the number of cells (from the current cell to the last cell) according to the given vector.
If we take the example where the vector is [-2, 0], with the value *1* (at array[2, 3]):
array = [
[<0>, <0>, <1>, <1>, <2>],
[<0>, <0>, <1>, <1>, <2>],
[<0>, <0>, <1>, *1*, <2>]
]
... we could think such as:
The vector [-2, 0] means that -2 is
for cols and 0 is for rows. So if we
are in array[2, 3], we can move 1 time
on the left (left because 2 is
negative) with 2 length (because
-2.abs == 2). And we don't move on the top or bottom, because of 0 for
rows.
| 0
| 0
| 0
| 0
| 1
| 0
|
Imagine a photo, with the face of a building marked out.
Its given that the face of the building is a rectangle, with 90 degree corners. However, because its a photo, perspective will be involved and the parallel edges of the face will converge on the horizon.
With such a rectangle, how do you calculate the angle in 2D of the vectors of the edges of a face that is at right angles to it?
In the image below, the blue is the face marked on the photo, and I'm wondering how to calculate the 2D vector of the red lines of the other face:
example http://img689.imageshack.us/img689/2060/leslievillestarbuckscor.jpg
So if you ignore the picture for a moment, and concentrate on the lines, is there enough information in one of the face outlines - the interior angles and such - to know the path of the face on the other side of the corner? What would the formula be?
We know that both are rectangles - that is that each corner is a right angle - and that they are at right angles to each other. So how do you determine the vector of the second face using only knowledge of the position of the first?
| 0
| 0
| 0
| 0
| 1
| 0
|
#include<stdio.h>
#include<math.h>
int main ()
{
FILE *fp;
fp=fopen("output","w");
float t,y=0,x=0,e=5,f=1,w=1;
for (t=0;t<10;t=t+0.01)
{
if( y==inf && y== nan)
break;
fprintf(fp,"%lf\t%lf
",y,x);
y = y + ((e*(1 - x*x)*y) - x + f*cos(w*t))*t;
x = x + y*t;
}
return 0;
}
Why is the ouput giving infinite and NAN values?
| 0
| 0
| 0
| 0
| 1
| 0
|
In my program, I am using BitArrays to represent 160 bit numbers. I want to be able to add, subtract, increment and decrement these numbers, what is the algorithm for doing this?
At the moment I'm not interested in multiplication and division, but I might be in the future so bonus points for that.
I'm implementing in C#, but pseudocode is fine if you're not familiar with the language
| 0
| 0
| 0
| 0
| 1
| 0
|
I would like to implement a naive bayes classifier for spam filtering from scratch as a learning exercise. What would be the best langauge of the following to try this out in?
Java
Ruby
C++
C
something else
Please give reasons (it would help greatly!)
| 0
| 0
| 0
| 1
| 0
| 0
|
I have to built dynamically equations like following:
x + x/3 + (x/3)/4 + (x/3/4)/2 = 50
Now I would like to evaluate this equation and get x. The equation is built dynamically. x is the leaf node in a taxonomy, the other 3 nodes are the super concepts. The divisor represents the number of children of the child nodes.
Is there a library that allows to build such equations dynamically and resolve x?
Thanks, Chris
| 0
| 0
| 0
| 0
| 1
| 0
|
As I have mentioned in previous questions I am writing a maze solving application to help me learn about more theoretical CS subjects, after some trouble I've got a Genetic Algorithm working that can evolve a set of rules (handled by boolean values) in order to find a good solution through a maze.
That being said, the GA alone is okay, but I'd like to beef it up with a Neural Network, even though I have no real working knowledge of Neural Networks (no formal theoretical CS education). After doing a bit of reading on the subject I found that a Neural Network could be used to train a genome in order to improve results. Let's say I have a genome (group of genes), such as
1 0 0 1 0 1 0 1 0 1 1 1 0 0...
How could I use a Neural Network (I'm assuming MLP?) to train and improve my genome?
In addition to this as I know nothing about Neural Networks I've been looking into implementing some form of Reinforcement Learning, using my maze matrix (2 dimensional array), although I'm a bit stuck on what the following algorithm wants from me:
(from http://people.revoledu.com/kardi/tutorial/ReinforcementLearning/Q-Learning-Algorithm.htm)
1. Set parameter , and environment reward matrix R
2. Initialize matrix Q as zero matrix
3. For each episode:
* Select random initial state
* Do while not reach goal state
o Select one among all possible actions for the current state
o Using this possible action, consider to go to the next state
o Get maximum Q value of this next state based on all possible actions
o Compute
o Set the next state as the current state
End Do
End For
The big problem for me is implementing a reward matrix R and what a Q matrix exactly is, and getting the Q value. I use a multi-dimensional array for my maze and enum states for every move. How would this be used in a Q-Learning algorithm?
If someone could help out by explaining what I would need to do to implement the following, preferably in Java although C# would be nice too, possibly with some source code examples it'd be appreciated.
| 0
| 1
| 0
| 0
| 0
| 0
|
Is there an online tool for adding parentheses to simple math equations? For example,
a + b * c
into
a + (b * c)
Those who paid more attention in math class might be able to tackle order of operations for huge equations in their head, but I could often use some help (and verification of my thinking).
I often encounter other people's libraries having equations and functions I need for my code, and this would be kind of helpful for debugging and understanding.
I was hoping Wolfram Alpha would do this, but the output is not easy to plug back into most programming languages e.g. a + (bc)
| 0
| 0
| 0
| 0
| 1
| 0
|
How can you represent mathematical constant "e" as a value in JavaScript?
| 0
| 0
| 0
| 0
| 1
| 0
|
I'm testing the NeuronDotNet library for a class assignment using C#. I have a very simple console application that I'm using to test some of the code snippets provided in the manual fro the library, the goal of the assignment is to teach the program how to distinguish between random points in a square which may or may not be within a circle that is also inside the square. So basically, which points inside the square are also inside the circle. Here is what I have so far:
namespace _469_A7
{
class Program
{
static void Main(string[] args)
{
//Initlaize the backpropogation network
LinearLayer inputLayer = new LinearLayer(2);
SigmoidLayer hiddenLayer = new SigmoidLayer(8);
SigmoidLayer outputLayer = new SigmoidLayer(2);
new BackpropagationConnector(inputLayer, hiddenLayer);
new BackpropagationConnector(hiddenLayer, outputLayer);
BackpropagationNetwork network = new BackpropagationNetwork(inputLayer, outputLayer);
//Generate a training set for the ANN
TrainingSet trainingSet = new TrainingSet(2, 2);
//TEST: Generate random set of points and add to training set,
//for testing purposes start with 10 samples;
Point p;
Program program = new Program(); //Used to access randdouble function
Random rand = new Random();
for(int i = 0; i < 10; i++)
{
//These points will be within the circle radius Type A
if(rand.NextDouble() > 0.5)
{
p = new Point(rand.NextDouble(), rand.NextDouble());
trainingSet.Add(new TrainingSample(new double[2] { p.getX(), p.getY() }, new double[2] { 1, 0 }));
continue;
}
//These points will either be on the border or outside the circle Type B
p = new Point(program.randdouble(1.0, 4.0), program.randdouble(1.0, 4.0));
trainingSet.Add(new TrainingSample(new double[2] { p.getX(), p.getY() }, new double[2] { 0, 1 }));
}
//Start network learning
network.Learn(trainingSet, 100);
//Stop network learning
//network.StopLearning();
}
//generates a psuedo-random double between min and max
public double randdouble(double min, double max)
{
Random rand = new Random();
if (min > max)
{
return rand.NextDouble() * (min - max) + max;
}
else
{
return rand.NextDouble() * (max - min) + min;
}
}
}
//Class defines a point in X/Y coordinates
public class Point
{
private double X;
private double Y;
public Point(double xVal, double yVal)
{
this.X = xVal;
this.Y = yVal;
}
public double getX()
{
return X;
}
public double getY()
{
return Y;
}
}
}
This is basically all that I need, the only question I have is how to handle output?? More specifically, I need to output the value of the "step size" and the "momentum", although it would be nice to output other information as well. Anyone with experience using NeuronDotNet, your input is appreciated.
| 0
| 1
| 0
| 0
| 0
| 0
|
I have a C# system using 160 bit numbers, stored in a BigInteger. I want to display these things on a circle, which means mapping the 0->2^160 range into the 0->2Pi range. How would I do this?
The approach that jumps instantly to mind is
BigInteger number;
angle = (number / pow(2, 160)) * TwoPi;
However, that has complexities because the division will truncate the result into an integer.
| 0
| 0
| 0
| 0
| 1
| 0
|
I need to develop applications doing linear algebra + eigenvalue + linear equation solutions over a cluster of pcs ( I have a lot of machines available).
I discovered Scalapack libraries but they seem to me developed long time ago.
Do you know if these are other libs available that I should learn doing math & linear algebra in a cluster?
My language is C++ and off course I am newbie to this topic.
| 0
| 0
| 0
| 0
| 1
| 0
|
Below is my innermost loop that's run several thousand times, with input sizes of 20 - 1000 or more. This piece of code takes up 99 - 99.5% of execution time. Is there anything I can do to help squeeze any more performance out of this?
I'm not looking to move this code to something like using tree codes (Barnes-Hut), but towards optimizing the actual calculations happening inside, since the same calculations occur in the Barnes-Hut algorithm.
Any help is appreciated!
Edit: I'm running in Windows 7 64-bit with Visual Studio 2008 edition on a Core 2 Duo T5850 (2.16 GHz)
typedef double real;
struct Particle
{
Vector pos, vel, acc, jerk;
Vector oldPos, oldVel, oldAcc, oldJerk;
real mass;
};
class Vector
{
private:
real vec[3];
public:
// Operators defined here
};
real Gravity::interact(Particle *p, size_t numParticles)
{
PROFILE_FUNC();
real tau_q = 1e300;
for (size_t i = 0; i < numParticles; i++)
{
p[i].jerk = 0;
p[i].acc = 0;
}
for (size_t i = 0; i < numParticles; i++)
{
for (size_t j = i+1; j < numParticles; j++)
{
Vector r = p[j].pos - p[i].pos;
Vector v = p[j].vel - p[i].vel;
real r2 = lengthsq(r);
real v2 = lengthsq(v);
// Calculate inverse of |r|^3
real r3i = Constants::G * pow(r2, -1.5);
// da = r / |r|^3
// dj = (v / |r|^3 - 3 * (r . v) * r / |r|^5
Vector da = r * r3i;
Vector dj = (v - r * (3 * dot(r, v) / r2)) * r3i;
// Calculate new acceleration and jerk
p[i].acc += da * p[j].mass;
p[i].jerk += dj * p[j].mass;
p[j].acc -= da * p[i].mass;
p[j].jerk -= dj * p[i].mass;
// Collision estimation
// Metric 1) tau = |r|^2 / |a(j) - a(i)|
// Metric 2) tau = |r|^4 / |v|^4
real mij = p[i].mass + p[j].mass;
real tau_est_q1 = r2 / (lengthsq(da) * mij * mij);
real tau_est_q2 = (r2*r2) / (v2*v2);
if (tau_est_q1 < tau_q)
tau_q = tau_est_q1;
if (tau_est_q2 < tau_q)
tau_q = tau_est_q2;
}
}
return sqrt(sqrt(tau_q));
}
| 0
| 0
| 0
| 0
| 1
| 0
|
I try to simplify conditionals in:
for ( int t=0, size=fo.getPrintViewsPerFile().size();
t<size && t<countPerFile;
t++)
{
// ...
}
, more precisely:
t<s && t<c
You need to compare two times, then calc the boolean value from them. Is there any simpler way to do it? If no, how can you prove it? I can simplify it to some extent, proof tree.
[Added]
I tried to solve the problem directly through logic. It would interesting to see the implication in choosing the minima. Link:
http://www.umsu.de/logik/trees/?f=(\exists%20s%20\exists%20c%20\forall%20t%20%20(Pts%20\land%20Ptc))\leftrightarrow
eg(\foralls\forallc\existst(
eg(Pts)\lor
eg(Ptc)))
| 0
| 0
| 0
| 0
| 1
| 0
|
Since Graduating from a very small school in 2006 with a badly shaped & outdated program (I'm a foreigner & didn't know any better school at the time) I've come to realize that I missed a lot of basic concepts from a mathematical & software perspective that are mostly the foundations of other higher concepts.
I.e. I tried to listen/watch the open courseware from MIT on Introduction to Algorithms but quickly realized I was missing several mathematical concepts to better understand the course.
So what are the core mathematical concepts a good software engineer should know? And what are the possible books/sites you will recommend me?
| 0
| 0
| 0
| 0
| 1
| 0
|
I'm trying to write a Matrix3x3 multiply using the Vector Floating Point on the iPhone, however i'm encountering some problems. This is my first attempt at writing any ARM assembly, so it could be a faily simple solution that i'm not seeing.
I've currently got a small application running using a maths library that i've written. I'm investigating into the benifits using the Vector Floating Point Unit would provide so i've taken my matrix multiply and converted it to asm. Previously the application would run without a problem, however now my objects will all randomly disappear. This seems to be caused by the results from my matrix multiply becoming NAN at some point.
Heres the code
IMatrix3x3 operator*(IMatrix3x3 & _A, IMatrix3x3 & _B)
{
IMatrix3x3 C;
//C++ code for the simulator
#if TARGET_IPHONE_SIMULATOR == true
C.A0 = _A.A0 * _B.A0 + _A.A1 * _B.B0 + _A.A2 * _B.C0;
C.A1 = _A.A0 * _B.A1 + _A.A1 * _B.B1 + _A.A2 * _B.C1;
C.A2 = _A.A0 * _B.A2 + _A.A1 * _B.B2 + _A.A2 * _B.C2;
C.B0 = _A.B0 * _B.A0 + _A.B1 * _B.B0 + _A.B2 * _B.C0;
C.B1 = _A.B0 * _B.A1 + _A.B1 * _B.B1 + _A.B2 * _B.C1;
C.B2 = _A.B0 * _B.A2 + _A.B1 * _B.B2 + _A.B2 * _B.C2;
C.C0 = _A.C0 * _B.A0 + _A.C1 * _B.B0 + _A.C2 * _B.C0;
C.C1 = _A.C0 * _B.A1 + _A.C1 * _B.B1 + _A.C2 * _B.C1;
C.C2 = _A.C0 * _B.A2 + _A.C1 * _B.B2 + _A.C2 * _B.C2;
//VPU ARM asm for the device
#else
//create a pointer to the Matrices
IMatrix3x3 * pA = &_A;
IMatrix3x3 * pB = &_B;
IMatrix3x3 * pC = &C;
//asm code
asm volatile(
//turn on a vector depth of 3
"fmrx r0, fpscr
\t"
"bic r0, r0, #0x00370000
\t"
"orr r0, r0, #0x00020000
\t"
"fmxr fpscr, r0
\t"
//load matrix B into the vector bank
"fldmias %1, {s8-s16}
\t"
//load the first row of A into the scalar bank
"fldmias %0!, {s0-s2}
\t"
//calulate C.A0, C.A1 and C.A2
"fmuls s17, s8, s0
\t"
"fmacs s17, s11, s1
\t"
"fmacs s17, s14, s2
\t"
//save this into the output
"fstmias %2!, {s17-s19}
\t"
//load the second row of A into the scalar bank
"fldmias %0!, {s0-s2}
\t"
//calulate C.B0, C.B1 and C.B2
"fmuls s17, s8, s0
\t"
"fmacs s17, s11, s1
\t"
"fmacs s17, s14, s2
\t"
//save this into the output
"fstmias %2!, {s17-s19}
\t"
//load the third row of A into the scalar bank
"fldmias %0!, {s0-s2}
\t"
//calulate C.C0, C.C1 and C.C2
"fmuls s17, s8, s0
\t"
"fmacs s17, s11, s1
\t"
"fmacs s17, s14, s2
\t"
//save this into the output
"fstmias %2!, {s17-s19}
\t"
//set the vector depth back to 1
"fmrx r0, fpscr
\t"
"bic r0, r0, #0x00370000
\t"
"orr r0, r0, #0x00000000
\t"
"fmxr fpscr, r0
\t"
//pass the inputs and set the clobber list
: "+r"(pA), "+r"(pB), "+r" (pC) :
:"cc", "memory","s0", "s1", "s2", "s8", "s9", "s10", "s11", "s12", "s13", "s14", "s15", "s16", "s17", "s18", "s19"
);
#endif
return C;
}
As far as i can see that makes sence. While debugging i've managed to notice that if i were to say _A = C prior to the return and after the ASM, _A will not necessarily be equal to C which has only increased my confusion. I had thought it was possibly due to the pointers I'm giving to the VFPU being incrimented by lines such as "fldmias %0!, {s0-s2}
\t" however my understanding of asm is not good enough to properly understand the problem, nor to see an alternative approach to that line of code.
Anyway, I was hoping someone with a greater understanding than me would be able to see a solution, and any help would be greatly appreciated, thank you :-)
Edit: I've found that pC seems to be NULL when the asm code is hit despite being set pC = &C. I'm assuming this is due to the compiler rearranging the code in a manor thats breaking it? I've tried the various methods I've seen for stopping this happening (like adding everything relevent in the input list - thought this shouldnt even be nessisary since i'm listing "memory" in the clobber list) and I'm still getting the same problems.
Edit #2: Right, the memory issue seems to have been caused by me not including "r0" in the clobber list, however fixing that (if it is indeed fixed) doesnt seem to have fixed the problem. I noticed that multiplying a rotation matrix by the identity matrix doesn't work correctly and instead gives 0.88 as the last entry in the matrix instead of 1:
| 0.88 0.48 0 | | 1 0 0 | | 0.88 0.48 0 |
|-0.48 0.88 0 | * | 0 1 0 | = |-0.48 0.88 0 |
| 0 0 1 | | 0 0 1 | | 0 0 0.88|
I figured then that my logic must be wrong somewhere so i stepped through the assembly. everything seems fine up until the last "fmacs s17, s14, s2
\t" where:
s0 = 0 s14 = 0 s17 = 0
s1 = 0 s15 = 0 s18 = 0
s2 = 1 s16 = 1 s19 = 0
so surely the fmacs is performing the operation:
s17 = s17 + s14 * s2 = 0 + 0 * 1 = 0
s18 = s18 + s15 * s2 = 0 + 0 * 1 = 0
s19 = s19 + s16 * s2 = 0 + 1 * 1 = 1
However the result gives s19 = 0.88 which has left me even more confused :S am i misunderstanding how fmacs works? (P.S sorry for what has now become a really long question :-P)
| 0
| 0
| 0
| 0
| 1
| 0
|
Hey, I'm trying to convert a function I wrote to generate an array of longs that respresents Pascal's triangles into a function that returns an array of mpz_t's. However with the following code:
mpz_t* make_triangle(int rows, int* count) {
//compute triangle size using 1 + 2 + 3 + ... n = n(n + 1) / 2
*count = (rows * (rows + 1)) / 2;
mpz_t* triangle = malloc((*count) * sizeof(mpz_t));
//fill in first two rows
mpz_t one;
mpz_init(one);
mpz_set_si(one, 1);
triangle[0] = one; triangle[1] = one; triangle[2] = one;
int nums_to_fill = 1;
int position = 3;
int last_row_pos;
int r, i;
for(r = 3; r <= rows; r++) {
//left most side
triangle[position] = one;
position++;
//inner numbers
mpz_t new_num;
mpz_init(new_num);
last_row_pos = ((r - 1) * (r - 2)) / 2;
for(i = 0; i < nums_to_fill; i++) {
mpz_add(new_num, triangle[last_row_pos + i], triangle[last_row_pos + i + 1]);
triangle[position] = new_num;
mpz_clear(new_num);
position++;
}
nums_to_fill++;
//right most side
triangle[position] = one;
position++;
}
return triangle;
}
I'm getting errors saying: incompatible types in assignment for all lines where a position in the triangle is being set (i.e.: triangle[position] = one;).
Does anyone know what I might be doing wrong?
| 0
| 0
| 0
| 0
| 1
| 0
|
I was give a problem to express any number as sum of four prime numbers.
Conditions:
Not allowed to use any kind of database.
Maximum execution time : 3 seconds
Numbers only till 100,000
If the splitting is NOT possible, then return -1
What I did :
using the sieve of Eratosthenes, I calculated all prime numbers till the specified number.
looked up a concept called Goldbach conjecture which expresses an even number as the summation of two primes.
However, I am stuck beyond that.
Can anyone help me on this one as to what approach you might take?
The sieve of Eratosthenes is taking two seconds to count primes up to 100,000.
| 0
| 0
| 0
| 0
| 1
| 0
|
i wrote this python code, which from wolfram alpha says that its supposed to return the factorial of any positive value (i probably messed up somewhere), integer or not:
from math import *
def double_factorial(n):
if int(n) == n:
n = int(n)
if [0,1].__contains__(n):
return 1
a = (n&1) + 2
b = 1
while a<=n:
b*=a
a+= 2
return float(b)
else:
return factorials(n/2) * 2**(n/2) *(pi/2)**(.25 *(-1+cos(n * pi)))
def factorials(n):
return pi**(.5 * sin(n*pi)**2) * 2**(-n + .25 * (-1 + cos(2*n*pi))) * double_factorial(2*n)
the problem is , say i input pi to 6 decimal places. 2*n will not become a float with 0 as its decimals any time soon, so the equation turns out to be
pi**(.5 * sin(n*pi)**2) * 2**(-n + .25 * (-1 + cos(2*n*pi))) * double_factorial(loop(loop(loop(...)))))
how would i stop the recursion and still get the answer?
ive had suggestions to add an index to the definitions or something, but the problem is, if the code stops when it reaches an index, there is still no answer to put back into the previous "nests" or whatever you call them
| 0
| 0
| 0
| 0
| 1
| 0
|
I'm trying to understand how to train a multilayer; however, I'm having some trouble figuring out how to determine a suitable network architecture--i.e., number of nodes/neurons in each layer of the network.
For a specific task, I have four input sources that can each input one of three states. I guess that would mean four input neurons firing either 0, 1 or 2, but as far as I'm told, input should be kept binary?
Furthermore am I having some issues choosing on the amount of neurons in the hidden layer. Any comments would be great.
Thanks.
| 0
| 0
| 0
| 1
| 0
| 0
|
I was following this thread and copied the code in my project. Playing around with it turns out that it seems not to be very precise.
Recall the formula: y = ax^2 + bx +c
Since the first given point I have is at x1 = 0, we already have c=y1 . We just need to find a and b. Using:
y2 = ax2^2 + bx2 +c
y3 = ax3^2 + bx3 +c
Solving the equations for b yields:
b = y/x - ax - cx
Now setting both equations equal to each other so b falls out
y2/x2 - ax2 - cx2 = y3/x3 - ax3 - cx3
Now solving for a gives me:
a = ( x3*(y2 - c) + x2*(y3 - c) ) / ( x2*x3*(x2 - x3) )
(is that correct?!)
And then using again b = y2/x2 - ax2 - cx2 to find b. However so far I haven't found the correct a and b coeffs. What am I doing wrong?
Edit
Ok I figured out, but had to use a CAS because I don't know how to invert symbolic matrices by hand. (Gauss algo doesn't seem to work)
Writing it down in Matrix form:
| 0 0 1 | |a|
| x2^2 x2 1 | * |b| = Y
| x3^2 x3 1 | |c|
Let's call the Matrix M and multiply from the left with M^(-1)
|a|
|b| = M^(-1)*Y
|c|
Then I got out of maple:
a = (-y1 * x2 + y1 * x3 - y2 * x3 + y3 * x2) / x2 / x3 / (-x2 + x3)
Guess I did a stupid mistake somewhere above.
Which gives me the same result as the formula in the thread quoted above.
| 0
| 0
| 0
| 0
| 1
| 0
|
Basically I want to find a path between two NP tokens in the dependencies graph. However, I can't seem to find a good way to do this in the Stanford Parser. Any help?
Thank You Very Much
| 0
| 1
| 0
| 0
| 0
| 0
|
The following is entirely a math question.
As we know, PerspectiveProjection delivers perspective transformations in 3D represented by the interdependent values of fieldOfView and focalLength according to the following formula:
focalLength = stageWidth/2 * (cos(fieldOfView/2) / sin(fieldOfView/2)
(source: bgstaal.net)
Q: How to get the visible on-screen size of the DisplayObject (Cube on the above-linked image) to which PerspectiveProjection has been applied?
A more thorough description and illustrative code on the issue in ActionScript 3 lacks functionality for visible bounds of DisplayObject.
| 0
| 0
| 0
| 0
| 1
| 0
|
In terms of machine learning.
Is there any difference between most specific hypotheses obtained by Candidate Elimination and Find-S methods?
Many Thanks
| 0
| 0
| 0
| 1
| 0
| 0
|
I'm looking for a package (any programming language) that I can use on a corpus of 50 documents to perform interdocument similarity testing using various metrics like term frequency-inverse document frequency (TF-IDF), Okapi best matching (Okapi-BM25), language models (probability distributions over a sequence of words), LSA, etc.
As the result, I want a document similarity matrix (i.e. doc1 is x% similar to doc2 etc.). This is for research purposes, not for production. I specifically want the document similarity matrix as I want to correlate this with human ratings.
| 0
| 1
| 0
| 0
| 0
| 0
|
If I have variables a, b, an c of type double, let c:=a/b, and give a and b values of 7 and 10, then c's value of 0.7 registers as being LESS THAN 0.70.
On the other hand, if the variables are all type extended, then c's value of 0.7 does not register as being less than 0.70.
This seems strange. What information am I missing?
| 0
| 0
| 0
| 0
| 1
| 0
|
I'm writing a small bignum library for a homework project. I am to implement Karatsuba multiplication, but before that I would like to write a naive multiplication routine.
I'm following a guide written by Paul Zimmerman titled "Modern Computer Arithmetic" which is freely available online.
On page 4, there is a description of an algorithm titled BasecaseMultiply which performs gradeschool multiplication.
I understand step 2, 3, where B^j is a digit shift of 1, j times.
But I don't understand step 1 and 3, where we have A*b_j. How is this multiplication meant to be carried out if the bignum multiplication hasn't been defined yet?
Would the operation "*" in this algorithm just be the repeated addition method?
Here is the parts I have written thus far. I have unit tested them so they appear to be correct for the most part:
The structure I use for my bignum is as follows:
#define BIGNUM_DIGITS 2048
typedef uint32_t u_hw; // halfword
typedef uint64_t u_w; // word
typedef struct {
unsigned int sign; // 0 or 1
unsigned int n_digits;
u_hw digits[BIGNUM_DIGITS];
} bn;
Currently available routines:
bn *bn_add(bn *a, bn *b); // returns a+b as a newly allocated bn
void bn_lshift(bn *b, int d); // shifts d digits to the left, retains sign
int bn_cmp(bn *a, bn *b); // returns 1 if a>b, 0 if a=b, -1 if a<b
| 0
| 0
| 0
| 0
| 1
| 0
|
I would have dared say that the numeric values computed by Fortran and C++ would be way more similar. However, from what I am experiencing, it turns out that the calculated numbers start to diverge after too few decimal digits. I have come across this problem during the process of porting some legacy code from the former language to the latter. The original Fortran 77 code...
INTEGER M, ROUND
DOUBLE PRECISION NUMERATOR, DENOMINATOR
M = 2
ROUND = 1
NUMERATOR=5./((M-1+(1.3**M))**1.8)
DENOMINATOR = 0.7714+0.2286*(ROUND**3.82)
WRITE (*, '(F20.15)') NUMERATOR/DENOMINATOR
STOP
... outputs 0.842201471328735, while its C++ equivalent...
int m = 2;
int round = 1;
long double numerator = 5.0 / pow((m-1)+pow(1.3, m), 1.8);
long double denominator = 0.7714 + 0.2286 * pow(round, 3.82);
std::cout << std::setiosflags(std::ios::fixed) << std::setprecision(15)
<< numerator/denominator << std::endl;
exit(1);
... returns 0.842201286195064. That is, the computed values are equal only up to the sixth decimal. Although not particularly a Fortran advocator, I feel inclined to consider its results as the 'correct' ones, given its legitimate reputation of number cruncher. However, I am intrigued about the cause of this difference between the computed values. Does anyone know what the reason for this discrepancy could be?
| 0
| 0
| 0
| 0
| 1
| 0
|
I am trying to use Multi-Layer NN to implement probability function in Partially Observable Markov Process..
I thought inputs to the NN would be: current state, selected action, result state;
The output is a probability in [0,1] (prob. that performing selected action on current state will lead to result state)
In training, I fed the inputs stated before, into the NN, and I taught it the output=1.0 for each case that already occurred.
The problem :
For nearly all test case the output probability is near 0.95.. no output was under 0.9 !
Even for nearly impossible results, it gave that high prob.
PS:I think this is because I taught it happened cases only, but not un-happened ones..
But I can not at each step in the episode teach it the output=0.0 for every un-happened action!
Any suggestions how to over come this problem? Or may be another way to use NN or to implement prob function?
Thanks
| 0
| 0
| 0
| 1
| 0
| 0
|
I'm doing a university project, that must gather and combine data on a user provided topic. The problem I've encountered is that Google search results for many terms are polluted with low quality autogenerated pages and if I use them, I can end up with wrong facts. How is it possible to estimate the quality/trustworthiness of a page?
You may think "nah, Google engineers are working on the problem for 10 years and he's asking for a solution", but if you think about it, SE must provide up-to-date content and if it marks a good page as a bad one, users will be dissatisfied. I don't have such limitations, so if the algorithm accidentally marks as bad some good pages, that wouldn't be a problem.
Here's an example:
Say the input is buy aspirin in south la. Try to Google search it. The first 3 results are already deleted from the sites, but the fourth one is interesting: radioteleginen.ning.com/profile/BuyASAAspirin (I don't want to make an active link)
Here's the first paragraph of the text:
The bare of purchasing prescription drugs from Canada is big
in the U.S. at this moment. This is
because in the U.S. prescription drug
prices bang skyrocketed making it
arduous for those who bang limited or
concentrated incomes to buy their much
needed medications. Americans pay more
for their drugs than anyone in the
class.
The rest of the text is similar and then the list of related keywords follows. This is what I think is a low quality page. While this particular text seems to make sense (except it's horrible), the other examples I've seen (yet can't find now) are just some rubbish, whose purpose is to get some users from Google and get banned 1 day after creation.
| 0
| 1
| 0
| 1
| 0
| 0
|
Does increasing the number of test cases training data in case of Precision Neural Networks may led to problems (like over-fitting for example)..?
Does it always good to increase test cases training data number? Will that always lead to conversion ?
If no, what are these cases.. an example would be better..
Thanks,
| 0
| 0
| 0
| 1
| 0
| 0
|
How do you find the negative and positive training data sets of Haar features for the AdaBoost algorithm? So say you have a certain type of blob that you want to locate in an image and there are several of them in your entire array - how do you go about training it? I'd appreciate a nontechnical explanation as much as possible. I'm new to this. Thanks.
| 0
| 0
| 0
| 1
| 0
| 0
|
What kind of search does ID3 perform?
| 0
| 0
| 0
| 1
| 0
| 0
|
Given an X, what math is needed to find its Y, using this table?
x
y
0
1
1
0
2
6
3
5
4
4
5
3
6
2
This is a language agnostic problem. I can't just store the array, and do the lookup. The input will always be the finite set of 0 to 6. It won't be scaling later.
| 0
| 0
| 0
| 0
| 1
| 0
|
I am using a JS progress bar that is set using a percentage: 0 to 100 (percent). I need the progress bar to reach 100% when 160,000 people have signed a certain form. I have the total number of signers set in a PHP variable but am lost on how to do the math to convert that into a percentage that fits within 1 - 100 (so that the progress bar actually reflects the goal of 160,000).
I may be missing something obvious here (i suck at anything number-related) so does anyone here have a clue as to how to do this?
| 0
| 0
| 0
| 0
| 1
| 0
|
In Linux. There is an srand() function, where you supply a seed and it will guarantee the same sequence of pseudorandom numbers in subsequent calls to the random() function afterwards.
Lets say, I want to store this pseudo random sequence by remembering this seed value.
Furthermore, let's say I want the 100 thousandth number in this pseudo random sequence later.
One way, would be to supply the seed number using srand(), and then calling random() 100 thousand times, and remembering this number.
Is there a better way of skipping all 99,999 other numbers in the pseudo random list and directly getting the 100 thousandth number in the list.
thanks,
m
| 0
| 0
| 0
| 0
| 1
| 0
|
Given an integer x, how would you return an integer y that is lower than or equal to x and a multiple of 64?
| 0
| 0
| 0
| 0
| 1
| 0
|
In MATLAB how do you plot
f(r) = { 2*J1(a*r) / r }^2
where a = 2*pi
and J1 is Bessel function of the 1st kind
and r = sqrt(x^2 + y^2)
This should plot in 3D, i.e. kind of be like a bubble (not sure how to do this)
| 0
| 0
| 0
| 0
| 1
| 0
|
What is the weak hypotheses generated during boosting?
| 0
| 0
| 0
| 1
| 0
| 0
|
Do you know of any existing implementation in any language (preferably python) of any entity set expansion algorithms, such that the one from Google sets ? ( http://labs.google.com/sets )
I couldn't find any library implementing such algorithms and I'd like to play with some of those to see how they would perform on some specific task I would like to implement.
Any help is welcome !
Thanks a lot for your help,
Regards,
Nicolas.
| 0
| 1
| 0
| 0
| 0
| 0
|
I'm using a combination of SDL and OpenGL in a sort of crash course project to teach myself how this all works. I'm really only interested in OpenGL as a way to use acceleration in 2D games so I just need this to work in a 2D plane.
I have been having a lot of problems today with my current issue, I would like an object to point towards the mouse while the mouse button is clicked and then of course stay pointing in that direction after the mouse is lifted.
void Square::handle_input() {
//If a key was pressed
if( event.type == SDL_KEYDOWN ) {
//Adjust the velocity
switch( event.key.keysym.sym ) {
case SDLK_UP: upUp = false; yVel = -1; break;
case SDLK_DOWN: downUp = false; yVel = 1; break;
case SDLK_LEFT: leftUp = false; xVel = -1; break;
case SDLK_RIGHT: rightUp = false; xVel = 1; break;
case SDLK_w: wUp = false; sAng = 1; break;
case SDLK_s: sUp = false; sAng = -1; break;
}
}
//If a key was released
else if( event.type == SDL_KEYUP ) {
//Adjust the velocity
switch( event.key.keysym.sym ) {
case SDLK_UP: upUp = true; yVel = 0; break;
case SDLK_DOWN: downUp = true; yVel = 0; break;
case SDLK_LEFT: leftUp = true; xVel = 0; break;
case SDLK_RIGHT: rightUp = true; xVel = 0; break;
case SDLK_w: wUp = true; sAng = 0; break;
case SDLK_s: sUp = true; sAng = 0; break;
}
}
//If a mouse button was pressed
if( event.type == SDL_MOUSEBUTTONDOWN ) {
switch ( event.type ) {
case SDL_MOUSEBUTTONDOWN: mouseUp = false; mousex == event.button.x; mousey == event.button.y; break;
case SDL_MOUSEBUTTONUP: mouseUp = true; break;
}
}
}
And then this is called at the end of my Object::Move call which also handles x and y translation
if (!mouseUp) {
xVect = mousex - x;
yVect = mousey - y;
radAng = atan2 ( mousey - y, mousex - x );
sAng = radAng * 180 / 3.1415926l;
}
Right now when I click the object turns and faces down to the bottom left but then no longer changes direction. I'd really appreciate any help I could get here. I'm guessing there might be an issue here with state versus polled events but from all the tutorials that I've been through I was pretty sure I had fixed that. I've just hit a wall and I need some advice!
| 0
| 0
| 0
| 0
| 1
| 0
|
I have a problem due to my terrible math abilities, that I cannot figure out how to scale a graph based on the maximum and minimum values so that the whole graph will fit onto the graph-area (400x420) without parts of it being off the screen (based on a given equation by user).
Let's say I have this code, and it automatically draws squares and then the line graph based on these values. What is the formula (what do I multiply) to scale it so that it fits into the small graphing area?
vector<int> m_x;
vector<int> m_y; // gets automatically filled by user equation or values
int HeightInPixels = 420;// Graphing area size!!
int WidthInPixels = 400;
int best_max_y = GetMaxOfVector(m_y);
int best_min_y = GetMinOfVector(m_y);
m_row = 0;
m_col = 0;
y_magnitude = (HeightInPixels/(best_max_y+best_min_y)); // probably won't work
x_magnitude = (WidthInPixels/(int)m_x.size());
m_col = m_row = best_max_y; // number of vertical/horizontal lines to draw
////x_magnitude = (WidthInPixels/(int)m_x.size())/2; Doesn't work well
////y_magnitude = (HeightInPixels/(int)m_y.size())/2; Doesn't work well
ready = true; // we have values, graph it
Invalidate(); // uses WM_PAINT
////////////////////////////////////////////
/// Construction of Graph layout on WM_PAINT, before painting line graph
///////////////////////////////////////////
CPen pSilver(PS_SOLID, 1, RGB(150, 150, 150) ); // silver
CPen pDarkSilver(PS_SOLID, 2, RGB(120, 120, 120) ); // dark silver
dc.SelectObject( pSilver ); // silver color
CPoint pt( 620, 620 ); // origin
int left_side = 310;
int top_side = 30;
int bottom_side = 450;
int right_side = 710; // create a rectangle border
dc.Rectangle(left_side,top_side,right_side,bottom_side);
int origin = 310;
int xshift = 30;
int yshift = 30;
// draw scaled rows and columns
for(int r = 1; r <= colrow; r++){ // draw rows
pt.x = left_side;
pt.y = (ymagnitude)*r+top_side;
dc.MoveTo( pt );
pt.x = right_side;
dc.LineTo( pt );
for(int c = 1; c <= colrow; c++){
pt.x = left_side+c*(magnitude);
pt.y = top_side;
dc.MoveTo(pt);
pt.y = bottom_side;
dc.LineTo(pt);
} // draw columns
}
// grab the center of the graph on x and y dimension
int top_center = ((right_side-left_side)/2)+left_side;
int bottom_center = ((bottom_side-top_side)/2)+top_side;
| 0
| 0
| 0
| 0
| 1
| 0
|
Has anyone found it strange that the default context for uint and ulong is unchecked rather than checked considering that they are meant to represent values that can never be negative?
So if some code is trying to violate that constraint it seems to me the natural and preferred behaviour would be to throw an exception rather than returning the max value instead (which can easily leave important pieces of data in an invalid state and impossible to revert..).
Is there an existing attribute which can be applied to either class/assembly so that it always performs arithmetic operations in a checked context? I was thinking of writing one myself (as an aspect using PostSharp) but would be great if there's one already.
Many thanks,
| 0
| 0
| 0
| 0
| 1
| 0
|
Suppose I have two points, Point1 and Point2. At any given time, these points may be at different positions-- they are not necessarily static.
Point1 is located at some position at time t, and its position is defined by the continuous functions x1(t) and y1(t) giving the x and y coordinates at time t. These functions are not differentiable, they are constructed piecewise from line segments.
Point2 is the same, with x2(t) and y2(t), each function having the same properties.
The obstacles that might prevent visibility are simple (and immobile) polygons.
How can I find the boundary points for visibility?
i.e. there are two kinds of boundaries: where the points become visible, and become invisible.
For a become-visible boundary i, there exists some ϵ>0, such that for any real number a, a ∈ (i-ϵ, i) , Point1 and Point2 are not visible (i.e. the line segment that connects (x1(a), y1(a)) to (x2(a), y2(x)) crosses some obstacles).
For b ∈ (i, i+ϵ) they are visible.
And it is the other way around for becomes-invisible.
But can I find a precise such boundary, and if so, how?
| 0
| 0
| 0
| 0
| 1
| 0
|
Here is the query in Oracle I was trying to remove the redundant math operation from:
SELECT name,
CASE
when nvl(num1,0) + nvl(num2,0) - nvl(num3,0) > 0
THEN nvl(num1,0) + nvl(num2,0) - nvl(num3,0)
ELSE 0
END
as result,
.... from ....
How do I not repeat the summation above?
The 'result' should contain - value of the above expression if > 0
- 0 if the value of expression is <= 0.
| 0
| 0
| 0
| 0
| 1
| 0
|
This question states:
A Pythagorean triplet is a set of three natural numbers, a b c, for which,
a2 + b2 = c2
For example, 32 + 42 = 9 + 16 = 25 = 52.
There exists exactly one Pythagorean triplet for which a + b + c = 1000.
Find the product abc.
I'm not sure what's it trying to ask you. Are we trying to find a2 + b2 = c2 and then plug those numbers into a + b + c = 1000?
| 0
| 0
| 0
| 0
| 1
| 0
|
i have two uiview's named question and answer.
the question view is loaded from a cell's click.
on the question view i have two iboutlet buttons named "view answer" and "next"
when i click on button named "answer" the answerview loaded.
both uiviews have one label.now i want to display a question when the first time question view loaded and the related answer should be on the answer view's label. now when click on next button.the label should be updated and the relevant answer also. when all the questions are finished i want a view with score that how many answer was correct and how many was wrong.
| 0
| 0
| 0
| 0
| 1
| 0
|
Whats the mathematical formulae to calculate the MIN and MAX value of an integral type using your calculator. I know you can use Integer.Max or Integer.Min etc or look it up on msdn however I want to know how to calculate it.
| 0
| 0
| 0
| 0
| 1
| 0
|
I have a rectangle in .NET in which I draw an ellipse.
I know the width, height and center point of that rectangle.
Of course the center point of the rectangle is also the center point of the ellipse.
I know how to calculate a point on a circle, however I have no clue about an ellipse.
I have those parameters and an angle, i need the point on the ellipse, can someone post the formula?
I saw somewhere you need to calculate 2 points in which 2 radii will go, the sum of the radii will be fixed and they will change in size accordingly.
I don't know how to do that, I only have the rectangle height, width and center point and of course the angle I wish to find the point at.
thanks for any help
Shlomi
| 0
| 0
| 0
| 0
| 1
| 0
|
In terms of Artificial Intelligent and Logic Knowledge, What is the difference between sound and unsound reasoning?
Also, what kind of search Does ID3 algorithm use? Is it Breadth-first search?
Thanks
| 0
| 1
| 0
| 1
| 0
| 0
|
I'm using libsvm for multi-class classification of datasets with a large number of features/attributes (around 5,800 per each item). I'd like to choose better parameters for C and Gamma than the defaults I am currently using.
I've already tried running easy.py, but for the datasets I'm using, the estimated time is near forever (ran easy.py at 20, 50, 100, and 200 data samples and got a super-linear regression which projected my necessary runtime to take years).
Is there a way to more quickly arrive at better C and Gamma values than the defaults? I'm using the Java libraries, if that makes any difference.
| 0
| 0
| 0
| 1
| 0
| 0
|
I am trying to implement a naive bayseian approach to find the topic of a given document or stream of words. Is there are Naive Bayesian approach that i might be able to look up for this ?
Also, i am trying to improve my dictionary as i go along. Initially, i have a bunch of words that map to a topics (hard-coded). Depending on the occurrence of the words other than the ones that are already mapped. And depending on the occurrences of these words i want to add them to the mappings, hence improving and learning about new words that map to topic. And also changing the probabilities of words.
How should i go about doing this ? Is my approach the right one ?
Which programming language would be best suited for the implementation ?
| 0
| 1
| 0
| 1
| 0
| 0
|
Take for example the list (L):
John, John, John, John, Jon
We are to presume one item is to be correct (e.g. John in this case), and give a probability it is correct.
First (and good!) attempt: MostFrequentItem(L).Count / L.Count (e.g. 4/5 or 80% likelihood)
But consider the cases:
John, John, Jon, Jonny
John, John, Jon, Jon
I want to consider the likelihood of the correct item being John to be higher in the first list! I know I have to count the SecondMostFrequent Item and compare them.
Any ideas? This is really busting my brain!
Thx,
Andrew
| 0
| 0
| 0
| 0
| 1
| 0
|
We have a collection of sets A_1,..,A_n. The goal is to find new sets for each of the old sets.
newA_i = {a_i in A_i such that there exist (a_1,..,a_n) in (A1,..,An) with no a_k = a_j for all k and j}
So in words this says that we remove all the elements from A_i that can't be used to form a tuple (a_1,..a_n) from the sets (A_1,..,A_n) such that the tuple doesn't contain duplicates.
My question is how to compute these new sets quickly. If you just implement this definition by generating all possible v's this will take exponential time. Do you know a better algorithm?
Edit: here's an example. Take
A_1 = {1,2,3,4}
A_2 = {2}.
Now the new sets look like this:
newA_1 = {1,3,4}
newA_2 = {2}
The 2 has been removed from A_1 because if you choose it the tuple will always be (2,2) which is invalid because it contains duplicates. On the other hand 1,3,4 are valid because (1,2), (3,2) and (4,2) are valid tuples.
Another example:
A_1 = {1,2,3}
A_2 = {1,4,5}
A_3 = {2,4,5}
A_4 = {1,2,3}
A_5 = {1,2,3}
Now the new sets are:
newA_1 = {1,2,3}
newA_2 = {4,5}
newA_3 = {4,5}
newA_4 = {1,2,3}
newA_5 = {1,2,3}
The 1 and 2 are removed from sets 2 and 3 because if you choose the 1 or 2 from these sets you'll only have 2 values left for sets 1, 4 and 5, so you will always have duplicates in tuples that look like (_,1,_,_,_) or like (_,_,2,_,_).
This problem seems difficult, but it would be great if there was a polynomial time algorithm.
Another way to look at this is to picture the sets A_i on the left and the values on the right, with a line connecting a set and a value if the value is in the set.
| 0
| 0
| 0
| 0
| 1
| 0
|
I am setting up a set of computers where to run math programs on top of MPI.
Do you know whether exist some library doing PCA - Principal Component Analysis using MPI so to use all the resources of the networked pcs?
I will have a look at Scalapack, but do you know other libraries?
My language is C++ on linux but if there is a good lib also for windows is the same
Thanks
| 0
| 0
| 0
| 0
| 1
| 0
|
I've got an IR sensor which writes its current information to a token which I then interpret in a C# application. That's all good -- no problems there, heres my code:
SetLabelText(tokens [1],label_sensorValue);
sensorreading = Int32.Parse(tokens[0]);
sensordistance = (mathfunctionhere);
Great. So the further away the IR sensor is from an object, the lower the sensor reading (as less light is reflected back and received by the sensor).
My problem is in interpreting that length. I can go ahead and get lets say "110" as a value when an object is 5 inches away, and then "70" as a value when an object is 6 inches away. Now I want to be able to calculate the distance of an object using these constants for any length.
Any ideas?
| 0
| 0
| 0
| 0
| 1
| 0
|
I have a sample of some kind that can create somewhat noisy output. The sample is the result of some image processing from a camera, which indicates the heading of a blob of a certain color. It is an angle from around -45° to +45°, or a NaN, which means that the blob is not actually in view.
In order to combat the noisy data, I felt that exponential smoothing would do the trick. However, I'm not sure how to handle the NaN values.
On the one hand, involving them in the math would result in a NaN average, which would then prevent any meaningful results. On the other hand, ignoring NaN values completely would mean that a "no-detection" scenario would never be reported. And just to complicate things, the data is also noisy in that it can get false NaN value, which ideally would be smoothed somehow to prevent random noise.
Any ideas about how I could implement such an exponential smoother?
| 0
| 0
| 0
| 0
| 1
| 0
|
I have a set of items, for example: {1,1,1,2,2,3,3,3}, and a restricting set of sets, for example {{3},{1,2},{1,2,3},{1,2,3},{1,2,3},{1,2,3},{2,3},{2,3}. I am looking for permutations of items, but the first element must be 3, and the second must be 1 or 2, etc.
One such permutation that fits is:
{3,1,1,1,2,2,3}
Is there an algorithm to count all permutations for this problem in general? Is there a name for this type of problem?
For illustration, I know how to solve this problem for certain types of "restricting sets".
Set of items: {1,1,2,2,3}, Restrictions {{1,2},{1,2,3},{1,2,3},{1,2},{1,2}}. This is equal to 2!/(2-1)!/1! * 4!/2!/2!. Effectively permuting the 3 first, since it is the most restrictive and then permuting the remaining items where there is room.
Also... polynomial time. Is that possible?
UPDATE: This is discussed further at below links. The problem above is called "counting perfect matchings" and each permutation restriction above is represented by a {0,1} on a matrix of slots to occupants.
https://math.stackexchange.com/questions/519056/does-a-matrix-represent-a-bijection
https://math.stackexchange.com/questions/509563/counting-permutations-with-additional-restrictions
https://math.stackexchange.com/questions/800977/parking-cars-and-vans-into-car-van-and-car-van-parking-spots
| 0
| 0
| 0
| 0
| 1
| 0
|
I was in need of a little math help that I can't seem to find the answer to, any links to documentation would be greatly appreciated.
Heres my situation, I have no idea where I am in this maze, but I need to move around and find my way back to the start. I was thinking of implementing a waypoint list of places i've been offset from my start at 0,0. This is a 2D cartesian plane.
I've been given 2 properties, my translation speed from 0-1 and my rotation speed from -1 to 1. -1 is very left and +1 is very right. These are speed and not angles so thats where my problem lies. If I'm given 0 as a translation speed and 0.2 I will continually turn to my right at a slow speed.
How do I figure out the offsets given these 2 variables? I can store it every time I take a 'step'.
I just need to figure out the offsets in x and y terms given the translations and rotation speeds. And the rotation to get to those points.
Any help is appreciated.
| 0
| 0
| 0
| 0
| 1
| 0
|
I want to display LaTeX math in the gmail messages that I receive, so that for example $\mathbb P^2$ would show as a nice formula. Now, there are several Javascripts available (for example, this one, or MathJax which would do the job, I just need to call them at the right time to manipulate the gmail message.
I know that this is possible to do in "basic HTML" and "print" views. Is it possible to do in the standard Gmail view? I tried to insert a call to the javascript right before the "canvas_frame" iframe, but that did not work.
My suspicion is that manipulating a Gmail message by any Javascript would be a major security flaw (think of all the malicious links one could insert) and that Google does everything to prevent this. And so the answer to my question is probably 'no'. Am I right in this?
Of course, it would be very easy for Google to implement viewing of LaTeX and MathML math simply by using MathJax on their servers. I made the corresponding Gmail Lab request, but no answer, and no interest from Google apparently.
So, again: is this possible to do without Google's cooperation, on the client side?
| 0
| 0
| 0
| 0
| 1
| 0
|
Inspired by a recent TED talk, I want to write a small piece of educational software. The researcher created little miniature computers in the shape of blocks called "Siftables".
(source: ted.com)
[David Merril, inventor - with Siftables in the background.]
There were many applications he used the blocks in but my favorite was when each block was a number or basic operation symbol. You could then re-arrange the blocks of numbers or operation symbols in a line, and it would display an answer on another siftable block.
So, I've decided I wanted to implemented a software version of "Math Siftables" on a limited scale as my final project for a CS course I'm taking.
What is the generally accepted way for parsing and interpreting a string of math expressions, and if they are valid, perform the operation?
Is this a case where I should implement a full parser/lexer? I would imagine interpreting basic math expressions would be a semi-common problem in computer science so I'm looking for the right way to approach this.
For example, if my Math Siftable blocks where arranged like:
[1] [+] [2]
This would be a valid sequence and I would perform the necessary operation to arrive at "3".
However, if the child were to drag several operation blocks together such as:
[2] [\] [\] [5]
It would obviously be invalid.
Ultimately, I want to be able to parse and interpret any number of chains of operations with the blocks that the user can drag together. Can anyone explain to me or point me to resources for parsing basic math expressions?
I'd prefer as much of a language agnostic answer as possible.
| 0
| 0
| 0
| 0
| 1
| 0
|
I know there are LOT of questions like that but I can't find one specific to my situation. I have 4x4 matrices implemented as NIO float buffers (These matrices are used for OpenGL). Now I want to implement a multiply method which multiplies Matrix A with Matrix B and stores the result in Matrix C. So the code may look like this:
class Matrix4f
{
private FloatBuffer buffer = FloatBuffer.allocate(16);
public Matrix4f multiply(Matrix4f matrix2, Matrix4f result)
{
{{{result = this * matrix2}}} <-- I need this code
return result;
}
}
What is the fastest possible code to do this multiplication? Some OpenGL implementations (Like the OpenGL ES stuff in Android) provide native code for this but others doesn't. So I want to provide a generic multiplication method for these implementations.
| 0
| 0
| 0
| 0
| 1
| 0
|
For the iPhone, is it possible to program applications to translate words from a base language to any of several languages of various users. If so, how?
| 0
| 1
| 0
| 0
| 0
| 0
|
I have some points in 3D which are in a single plane. I want to arrange them in clock wise or counter clockwise order.
The points can create a concave or convex polygon in a single plane.
Can any body give any suggestions?
| 0
| 0
| 0
| 0
| 1
| 0
|
Im implementing a pool billiard game in Java and it all works fine. It is a multiplayer game, but nevertheless, it should also be possible to play it alone. For this purpose I'm trying to implement a simple KI. At the moment, the KI choose just randomly a direction and a random intensity of the impulse (don't know the correct english word for that). Of course this AI is very poor and unlikely to ever challenge a player.
So i thought about improving the KI, but there are several hard to solve problems. First I thought of just choosing the nearest ball and to try to put it directly into the nearest hole. This isn't that bad, but if there other balls in the line between, it isn't really working anymore. Additionally this dosn't solve te problem of calculating the intensity of the impulse.
So are there any general advice? Or any ideas? Best practices?
| 0
| 0
| 0
| 0
| 1
| 0
|
what popular advance mathematics libraries for c++ are present out there, so that they can be used as a 1 stop solution and avoiding reinventing the wheel ?
| 0
| 0
| 0
| 0
| 1
| 0
|
i have a mathematical problem which is a bit hard to describe, but i'll give it a try anyway.
in a timeline, i have a number of frames, of which i want to skip a certain number of frames, which should be evenly distributed along the timeline.
for example i have 10 frames and i want to skip 5, then the solution is easy: we skip every second frame.
10/5 = 2
if (frame%2 == 0)
skip();
but what if the above division does result in a floating number?
for example in 44 frames i want to skip 15 times. how can i determine the 15 frames which should be skipped?
bascially i am looking for an algorithm that distributes that 15 frames as evenly as possible along the 44 frames.
it will probably look like something like skipping after 2 and then after 3 frames alternately.
thanks!
| 0
| 0
| 0
| 0
| 1
| 0
|
There is a question I am stuck on using the following formula for the unipolar transfer function:
f(net)= 1
__________
-net
1 + e
The example has the following:
out = 1
____________ = 0.977
-3.75
1 + e
How do we arrive at 0.977?
What is e?
| 0
| 0
| 0
| 0
| 1
| 0
|
I'd like to try my hand at creating a Magic Square in PHP (i.e. a grid of numbers that all add up to the same value), but I really don't know where to start. I know of the many methods that create magic square, such as starting "1" at a fixed position, then moving in a specific direction with each iteration. But that doesn't create a truly randomized Magic Square, which is what I'm aiming for.
I want to be able to generate an N-by-N Magic Square of N² numbers where each row and column adds up to N(N²+1)/2 (e.g. a 5x5 square where all rows/columns add up to 65 — the diagonals don't matter).
Can anybody provide a starting point? I don't want anybody to do the work for me, I just need to know how to start such a project?
I know of one generator, written in Java (http://www.dr-mikes-math-games-for-kids.com/how-to-make-a-magic-square.html) but the last Java experience I had was over 10 years ago before I quickly abandoned it. Therefore, I don't really understand what the code is actually doing. I did notice, however, that when you generate a new square, it shows the numbers 1-25 (for a 5x5 square), in order, before quickly generating a fresh randomized square.
| 0
| 0
| 0
| 0
| 1
| 0
|
I have a problem with LaTeX – I don't know how to put mathematical equations and symbols in listings. I use the listings package and it's offers great looking listings, but it doesn't allow math symbols in $ ... $. Another package, algorithms, allows math, but listings doesn't look as good as with listings (the problem is that algorithms demands to get new line after every if, then, etc.)
| 0
| 0
| 0
| 0
| 1
| 0
|
I trying to create a points calculating system with javascript, but the problem is with the mathematical part. I have saved on the server the points number, and based on that number I want to decide the level. Sorry for my bad english, I cant explain very well :D. I want something like: level 1 need 0 points
level 2 needs 100 points
level 3 needs 240 points
level 4 needs 420 points
level 5 needs 640 points
and so on....
I need a mathematical function to calculate each level with it. Something that if I know the level to calculate the points needed, and if I know only the points to calculate the level.
| 0
| 0
| 0
| 0
| 1
| 0
|
I want to do a Mean-Variance-Optimization (Markowitz) but i never found anything written in php that does this. MVP needs differential calculus.
Can it be done in php and why arent there any classes/works from universities?
For a webapplication (regarding performance) would another language be the better choice to handle heavy calculations?
Thanks so much for any help/answer on this
| 0
| 0
| 0
| 0
| 1
| 0
|
i am trying to make a 100 x 100 tridiagonal matrix with 2's going down the diagonal and -1's surrounding the 2's. i can make a tridiagonal matrix with only 1's in the three diagonals and preform matrix addition to get what i want, but i want to know if there is a way to customize the three diagonals to what ever you want. maplehelp doesn't list anything useful.
| 0
| 0
| 0
| 0
| 1
| 0
|
I was wondering if someone could help me understand this problem. I prepared a small diagram because it is much easier to explain it visually.
alt text http://img179.imageshack.us/img179/4315/pon.jpg
Problem I am trying to solve:
1. Constructing the dependency graph
Given the connectivity of the graph and a metric that determines how well a node depends on the other, order the dependencies. For instance, I could put in a few rules saying that
node 3 depends on node 4
node 2 depends on node 3
node 3 depends on node 5
But because the final rule is not "valuable" (again based on the same metric), I will not add the rule to my system.
2. Execute the request order
Once I built a dependency graph, execute the list in an order that maximizes the final connectivity. I am not sure if this is a really a problem but I somehow have a feeling that there might exist more than one order in which case, it is required to choose the best order.
First and foremost, I am wondering if I constructed the problem correctly and if I should be aware of any corner cases. Secondly, is there a closely related algorithm that I can look at? Currently, I am thinking of something like Feedback Arc Set or the Secretary Problem but I am a little confused at the moment. Any suggestions?
PS: I am a little confused about the problem myself so please don't flame on me for that. If any clarifications are needed, I will try to update the question.
| 0
| 0
| 0
| 0
| 1
| 0
|
I am constructing a line graph in PHP. I was setting the max value of the line graph to the max value of my collection of items, but this ended up making the graph less readable you are unable to view the highest line on the graph as it intersects with the top of it. So what I need is basically a formula to take a set of numbers and calculate what the logical max value of on the line graph should be.. so some examples
3500
250
10049
45394
434
312
Max value on line graph should probably be 50000
493
412
194
783
457
344
max value on line graph would ideally be 1000
545
649
6854
5485
11545
In this case, 12000 makes sense as max value
So something as simple as rounding upward to the nearest thousandth might work but I'd need it to progressively increase as the numbers got bigger. (50000 instead of 46,000 in first example) The maximum these numbers will ever be is about a million.
Any recommendations would be greatly appreciated, thank you.
Here is what I settled on, thank you all for your comments:
private function FigureMaxValue($array)
{
$highestNumber = max($array);
if ($highestNumber == 0) return 0;
$highestNumber = $highestNumber * 1.1;
(float)$highestNumber = round((float)$highestNumber, 0);
$maxValue = ceil( (integer)$highestNumber / 100 ) * 100;
return $maxValue;
}
| 0
| 0
| 0
| 0
| 1
| 0
|
I am working on a geographic project in Java.
The input are coordinates : 24.4444 N etc
Output: a PLAIN map (not round) showing the point of the coordinates.
I don't know the algorithm to transform from coordinates to x,y on a JComponent, can somebody help me?
The map looks like this:
http://upload.wikimedia.org/wikipedia/commons/7/74/Mercator-projection.jpg
Thank you
| 0
| 0
| 0
| 0
| 1
| 0
|
I have three consecutive points of polygon, say p1,p2,p3. Now I wanted to know whether the orthogonal between p1 and p3 is inside the polygon or outside the polygon.
I am doing it by taking three vectors v1,v2 and v3. And the point before the point p1 in polygon say p0.
v1 = (p0 - p1)
v2 = (p2 - p1)
v3 = (p3 - p1)
With reference to this question, I am using the method shown in the accepted answer of that question. It is only for counterclockwise. What if my points are clockwise.
I am also knowing my whole polygon is clockwise or counterclockwise. And accordingly I select the vectors v1 and v2. But still I am getting some problem. I am showing one case where I am getting problem.
This polygon is counterclockwise. and It is starting from the origin of v1 and v2.
| 0
| 0
| 0
| 0
| 1
| 0
|
I am working on one feature i.e. to apply language segmentation rules (grammatical) for Latin based language (English currently).
Currently I am in phase of breaking sentences of user input.
e.g.:
"I am working in language translation". "I have used Google MT API for this"
In above example i will break above sentence by full stop . This is normal cases where I am breaking sentence on dot, but there are n number of characters for breaking sentence like (. ! ?, etc).
I have following SRX rules for segmentation.
Is there any reference which I can use for resolving my language segmentation rules?
| 0
| 1
| 0
| 0
| 0
| 0
|
All,
I'm looking for recommendations for C or C++ libraries (preferably open source) that use multi-threaded techniques to multiply large, non-square, (e.g. 65536xn in size where n < 65536) non-sparse matrices. Thanks.
-&&
| 0
| 0
| 0
| 0
| 1
| 0
|
I'm in a need to optimize this really tiny, but pesky function.
unsigned umod(int a, unsigned b)
{
while(a < 0)
a += b;
return a % b;
}
Before you cry out "You don't need to optimize it", please keep in mind that this function is called 50% of the entire program lifetime, as it's being called 21495808 times for the smallest test case benchmark.
The function is already being inlined by the compiler so please don't offer to add the inline keyword.
| 0
| 0
| 0
| 0
| 1
| 0
|
I have worked with globalization settings in the past but not within the .NET environment, which is the topic of this question. What I am seeing is most certainly due to knowledge I have yet to learn so I would appreciate illumination on the following.
Setup:
My default language setting is English (en-us specifically). I added a second language (Danish) on my development system (WinXP) and then opened the language bar so I could select either at will.
I selected Danish on the language bar then opened Notepad and found the language reverted to English on the language bar. I understand that the language setting is per application, so it seemed that Notepad set the default back to English. (I found that strange since Windows and thus Notepad is used all over the world.) Closing Notepad returned the setting on the language bar to Danish. I then launched my open custom WinForm application--which I know does not set the language--and it also reverted from English to Danish when opened, then back to Danish when terminated!
Question #1A: How do I get my WinForm application upon launch to inherit the current setting of the language bar? My experiment seems to indicate that each application starts with the system default and requires the user to manually change it once the app is running--this would seem to be a major inconvenience for anyone that wants to work with more than one language!
Question #1B: If one must, in fact, set the language manually in a multi-language scenario, how do I change my default system language (e.g. to Danish) so I can test my app's launch in another language?
I added a display of the current language in my application for this next experiment. Specifically I set a MouseEnter handler on a label that set its tooltip to CultureInfo.CurrentCulture.Name so each time I mouse over I thought I should see the current language setting. Since setting the language before I launch my app did not work, I launched it then set the language to Danish. I found that some things (like typing in a TextBox) did honor this Danish setting. But mousing over the instrumented label still showed en-us!
Question #2A: Why does CultureInfo.CurrentCulture.Name not reflect the change from my language bar while other parts of my app seem to recognize the change? (Trying CultureInfo.CurrentUICulture.Name produced the same result.)
Question #2B: Is there an event that fires upon changes on the language bar so I could recognize within my app when the language setting changes?
2010.05.13 Update
The short but sweet information provided by Eric from Microsoft (see his answer below) directly addressed only one of my four questions (#2A) but it provided just the impetus I needed to delve further and figure out the rest. For the benefit of others who may also be befuddled by this, here is what I uncovered:
Answer #1A: An application inherits the setting of the default input language, not the language you specify on the language bar. Once your application is running, then changes on the language bar will be noticed immediately by your app.
Answer #1B: Setting the default input language is done via Regional and Language Options control panel >> Languages tab >> Details >> Settings tab >> default input language.
Answer #2A: Answered by Eric, the current culture is distinct from the current input language that is reflected on the language bar; typing in a text box is influenced only by the current input language.
Answer #2B: There is no predefined event for either input language or current culture change notification. An important fact to note here is that input language changes are automatically recognized immediately while current culture changes are not. You must restart your application for a current culture change to take effect--unless you can notice the change and act upon it yourself. To that end I found an MSDN article (The Many Faces of the CultureInfo Class) that provides just such a hook to notice the change.
| 0
| 1
| 0
| 0
| 0
| 0
|
I have a set of Books objects, classs Book is defined as following :
Class Book{
String title;
ArrayList<tags> taglist;
}
Where title is the title of the book, example : Javascript for dummies.
and taglist is a list of tags for our example : Javascript, jquery, "web dev", ..
As I said a have a set of books talking about different things : IT, BIOLOGY, HISTORY, ...
Each book has a title and a set of tags describing it..
I have to classify automaticaly those books into separated sets by topic, example :
IT BOOKS :
Java for dummies
Javascript for dummies
Learn flash in 30 days
C++ programming
HISTORY BOOKS :
World wars
America in 1960
Martin luther king's life
BIOLOGY BOOKS :
....
Do you guys know a classification algorithm/method to apply for that kind of problems ?
A solution is to use an external API to define the category of the text, but the problem here is that books are in different languages : french, spanish, english ..
| 0
| 1
| 0
| 1
| 0
| 0
|
Just as a practice, I am working on an app that solves the famous middle school pythagorean theorem, a squared + b squared = c squared. Unfortunately, the out-coming answer has, in my eyes, nothing to do with the actual answer. Here is the code used during the "solve" action.
- (IBAction)solve {
int legoneint;
int legtwoint;
int hypotenuseint;
int lonesq = legoneint * legoneint;
int ltwosq = legtwoint * legtwoint;
int hyposq = hypotenuseint * hypotenuseint;
hyposq = lonesq + ltwosq;
if ([legone.text isEqual:@""]) {
legtwoint = [legtwo.text intValue];
hypotenuseint = [hypotenuse.text intValue];
answer.text = [NSString stringWithFormat:@"%d", legoneint];
self.view.backgroundColor = [UIColor blackColor];
}
if ([legtwo.text isEqual:@""]) {
legoneint = [legone.text intValue];
hypotenuseint = [hypotenuse.text intValue];
answer.text = [NSString stringWithFormat:@"%d", legtwoint];
self.view.backgroundColor = [UIColor blackColor];
}
if ([hypotenuse.text isEqual:@""]) {
legoneint = [legone.text intValue];
legtwoint = [legtwo.text intValue];
answer.text = [NSString stringWithFormat:@"%d", hypotenuseint];
self.view.backgroundColor = [UIColor blackColor];
}
}
By the way, legone, legtwo, and hypotenuse all represent the UITextField that corresponds to each mathematical part of the right triangle. Answer is the UILabel that tells, you guessed it, the answer. Does anyone see any flaws in the program? Thanks in advance!
| 0
| 0
| 0
| 0
| 1
| 0
|
I've got a bunch of overlapping triangles from a 3D model projected into a 2D plane. I need to merge each island of touching triangles into a closed, non-convex polygon.
The resultant polygons shouldn't have any holes in them (since the source data doesn't).
Many of the source triangles share (floating point identical) edges with other triangles in the source data.
What's the easiest way to do this? Performance isn't particularly important, since this will be done at design time.
| 0
| 0
| 0
| 0
| 1
| 0
|
i have X, Y, random logistic variables, how do I add them given the mean and scale for each?
Logistic distribution. i ran a simulation in python, but i cannot get it to be exact.
i ran a simulation on getting a random number X, Y, and keep score on the value of X + Y. then i did the same for getting a single random number with X + Y and test another scale based on the original scales, but i cannot fix the new scale to make them match
| 0
| 0
| 0
| 0
| 1
| 0
|
I want to make characters in a game perform actions that are partially random but also influenced by preferences. For instance, if a character feels angry they have a higher chance of yelling than telling a joke. So I'm thinking about how to determine which action the character will take. Here are the ideas that have come to me.
Solution #1: Iterate over every possible action. For each action do a random roll, then add the preference value to that random number. The action with the highest value is the one the character takes.
Solution #2: Assign a range of numbers to an action, with more likely actions having a wider range. So, if the random roll returns anywhere from 1-5, the character will tell a joke. If it returns 6-75, they will yell. And so on.
Solution #3: Group all the actions and make a branching tree. Will they take a friendly action or a hostile action? The random roll (with preference values added) says hostile. Will they make a physical attack or verbal? The random roll says verbal. Keep going down the line until you reach the action.
Solution #1 is the simplest, but hardly efficient. I think Solution #3 is a little more complicated, but isn't it more efficient?
Does anyone have any more insight into this particular problem? Is #3 the best solution? Is there a better solution?
| 0
| 1
| 0
| 0
| 0
| 0
|
Trying to do some really basic math here, but my lack of understanding of Java is causing some problems for me.
double[][] handProbability = new double[][] {{0,0,0},{0,0,0},{0,0,0}};
double[] handProbabilityTotal = new double[] {0,0,0};
double positivePot = 0;
double negativePot = 0;
int localAhead = 0;
int localTied = 1;
int localBehind = 2;
//do some stuff that adds values to handProbability and handProbabilityTotal
positivePot =
(handProbability[localBehind][localAhead] +
(handProbability[localBehind][localTied] / 2.0) +
(handProbability[localTied][localAhead] / 2.0) ) /
(handProbabilityTotal[localBehind] + (handProbability[localTied] / 2.0));
negativePot =
(handProbability[localAhead][localBehind] +
(handProbability[localAhead][localTied] / 2.0) +
(handProbability[localTied][localBehind] / 2.0) ) /
(handProbabilityTotal[localAhead] + (handProbabilityTotal[localTied] / 2.0));
The last two lines are giving me problems (sorry for their lengthiness).
Compiler Errors:
src/MyPokerClient/MyPokerClient.java:180: operator / cannot be applied to double[],double
positivePot = ( handProbability[localBehind][localAhead] + (handProbability[localBehind][localTied] / 2.0) + (handProbability[localTied][localAhead] / 2.0) ) / (handProbabilityTotal[localBehind] + (handProbability[localTied] / 2.0) );
^
src/MyPokerClient/MyPokerClient.java:180: operator + cannot be applied to double,
positivePot = ( handProbability[localBehind][localAhead] + (handProbability[localBehind][localTied] / 2.0) + (handProbability[localTied][localAhead] / 2.0) ) / (handProbabilityTotal[localBehind] + (handProbability[localTied] / 2.0) );
^
src/MyPokerClient/MyPokerClient.java:180: operator / cannot be applied to double,
positivePot = ( handProbability[localBehind][localAhead] + (handProbability[localBehind][localTied] / 2.0) + (handProbability[localTied][localAhead] / 2.0) ) / (handProbabilityTotal[localBehind] + (handProbability[localTied] / 2.0) );
Not really sure what the problem is. You shouldn't need anything special for basic math, right?
| 0
| 0
| 0
| 0
| 1
| 0
|
I have the following code which basically needs to add a list as an item to a greater list. So NewBoardsList should contain all the boards generated in the moves_generate_board function. The problem is that i get a False in Prolog. Any help ?
moves((Colour,_),Board,NewBoardsList):-
other_colour(Colour,OtherColour),
findall((X,Y,OtherColour,N),
(member((X,Y,OtherColour,N),Board),
threaten_by(Colour,(X,Y,OtherColour,N),Board)),
Options),
moves_generate_board(Options,Board,NewBoardsList).
moves_generate_board([],Board,BoardsList).
moves_generate_board([(X,Y,_,_)|T],Board,List):-
replace((X,Y,-,-),Board,NewBoard),
moves_generate_board(T,Board,[NewBoard|List]).
| 0
| 1
| 0
| 0
| 0
| 0
|
I am looking for word alignment tools and algorithms.
I am dealing with bilingual English - Hindi text, and currently working on
DTW (Dynamic Time Warping) algorithm
CLA (Competitive Linking Algorithm)
NATools
Giza++
Could you please suggest any other algorithm/tool which is language independent and which could achieve Statistical word alignment for parallel English Hindi Corpora and its evaluation.
Some tools are best for certain languages; could you please tell me how true that is and, if so, could you please provide an example of what would be better suited for Asian languages like Hindi. Counter-examples of what one shouldn't I use for such languages is also welcome.
I have heard a bit about Uplug word aligner... Could someone tell me if this tool is useful for my purpose.
Thank you.. :)
| 0
| 1
| 0
| 0
| 0
| 0
|
When I ask a question here, the tool tips for the question returned by the auto search given the first little bit of the question, but a decent percentage of them don't give any text that is any more useful for understanding the question than the title. Does anyone have an idea about how to make a filter to trim out useless bits of a question?
My first idea is to trim any leading sentences that contain only words in some list (for instance, stop words, plus words from the title, plus words from the SO corpus that have very weak correlation with tags, that is that are equally likely to occur in any question regardless of it's tags)
| 0
| 1
| 0
| 0
| 0
| 0
|
I know how to find the centroid (center of mass) of a regular polygon. This assumes that every part of the polygon weighs the same.
But how do I calculate the centroid of a weightless polygon (made from aerogel perhaps :), where each vertex has a weight?
Simplified illustration of what I mean using straight line:
5kg-----------------5kg
^center of gravity
10kg---------------5kg
^center of gravity offset du to weight of vertices
Of course, I know how to calculate the center of gravity on a straight line with weighted vertices, but how do I do it on a polygon with weighted vertices?
Thanks for your time!
| 0
| 0
| 0
| 0
| 1
| 0
|
Given a vector X of size L, where every scalar element of X is from a binary set {0,1}, it is to find a dot product z=dot(X,Y) if vector Y of size L consists of the integer-valued elements. I suggest, there must exist a very fast way to do it.
Let's say we have L=4; X[L]={1, 0, 0, 1}; Y[L]={-4, 2, 1, 0} and we have to find z=X[0]*Y[0] + X[1]*Y[1] + X[2]*Y[2] + X[3]*Y[3] (which in this case will give us -4).
It is obvious that X can be represented using binary digits, e.g. an integer type int32 for L=32. Then, all what we have to do is to find a dot product of this integer with an array of 32 integers. Do you have any idea or suggestions how to do it very fast?
| 0
| 0
| 0
| 0
| 1
| 0
|
I am parsing using a pretty large grammar (1.1 GB, it's data-oriented parsing). The parser I use (bitpar) is said to be optimized for highly ambiguous grammars. I'm getting this error:
1terminate called after throwing an instance of 'std::bad_alloc'
what(): St9bad_alloc
dotest.sh: line 11: 16686 Aborted bitpar -p -b 1 -s top -u unknownwordsm -w pos.dfsa /tmp/gsyntax.pcfg /tmp/gsyntax.lex arbobanko.test arbobanko.results
Is there hope? Does it mean that it has ran out of memory? It uses about 15 GB before it crashes. The machine I'm using has 32 GB of RAM, plus swap as well. It crashes before outputting a single parse tree; I think it crashes after reading the grammar, during an attempt to construct a chart parse for the first sentence.
The parser is an efficient CYK chart parser using bit vector representations; I presume it is already pretty memory efficient. If it really requires too much memory I could sample from the grammar rules, but this will decrease parse accuracy of course.
I think the problem is probably that I have a very large number of non-terminals, I should probably try to look for a different parser (any suggestions?)
UPDATE: for posterity's sake, I found the problem a long time ago. The grammar was way too big due to a bug, so the parser couldn't handle it with the available memory. With the correct grammar (which is an order of magnitude smaller) it works fine.
| 0
| 1
| 0
| 0
| 0
| 0
|
'Proximity' is a strategy game of territorial domination similar to Othello, Go and Risk.
Two players, uses a 10x12 hex grid. Game invented by Brian Cable in 2007.
Seems to be a worthy game for discussing a) optimal algorithm then b) how to build an AI.
Strategies are going to be probabilistic or heuristic-based, due to the randomness factor, and the insane branching factor (20^120).
So it will be kind of hard to compare objectively.
A compute time limit of 5 seconds max per turn seems reasonable => this rules out all brute-force attempts. (Play the game's AI on Expert level to get a feel - it does a very good job based on some simple heuristic)
Game: Flash version here, iPhone version iProximity here and many copies elsewhere on the web
Rules: here
Object: to have control of the most armies after all tiles have been placed. You start with an empty hexboard. Each turn you receive a randomly numbered tile (value between 1 and 20 armies) to place on any vacant board space. If this tile is adjacent to any ALLY tiles, it will strengthen each of those tile's defenses +1 (up to a max value of 20). If it is adjacent to any ENEMY tiles, it will take control over them IF its number is higher than the number on the enemy tile.
Thoughts on strategy: Here are some initial thoughts; setting the computer AI to Expert will probably teach a lot:
minimizing your perimeter seems to be a good strategy, to prevent flips and minimize worst-case damage
like in Go, leaving holes inside your formation is lethal, only more so with the hex grid because you can lose armies on up to 6 squares in one move
low-numbered tiles are a liability, so place them away from your main territory, near the board edges and scattered. You can also use low-numbered tiles to plug holes in your formation, or make small gains along the perimeter which the opponent will not tend to bother attacking.
a triangle formation of three pieces is strong since they mutually reinforce, and also reduce the perimeter
Each tile can be flipped at most 6 times, i.e. when its neighbor tiles are occupied. Control of a formation can flow back and forth. Sometimes you lose part of a formation and plug any holes to render that part of the board 'dead' and lock in your territory/ prevent further losses.
Low-numbered tiles are obvious-but-low-valued liabilities, but high-numbered tiles can be bigger liabilities if they get flipped (which is harder). One lucky play with a 20-army tile can cause a swing of 200 (from +100 to -100 armies). So tile placement will have both offensive and defensive considerations.
Comment 1,2,4 seem to resemble a minimax strategy where we minimize the maximum expected possible loss (modified by some probabilistic consideration of the value ß the opponent can get from 1..20 i.e. a structure which can only be flipped by a ß=20 tile is 'nearly impregnable'.)
I'm not clear what the implications of comments 3,5,6 are for optimal strategy.
Interested in comments from Go, Chess or Othello players.
(The sequel ProximityHD for XBox Live, allows 4-player -cooperative or -competitive local multiplayer increases the branching factor since you now have 5 tiles in your hand at any given time, of which you can only play one. Reinforcement of ally tiles is increased to +2 per ally.)
| 0
| 1
| 0
| 0
| 0
| 0
|
I spent quite a long time searching for a solution to this problem. I drew tons of cross-hatched triangles, counted the triangles in simple cases, and searched for some sort of pattern. Unfortunately, I hit the wall. I'm pretty sure my programming/math skills did not meet the prereq for this problem.
So I found a solution online in order to gain access to the forums. I didn't understand most of the methods at all, and some just seemed too complicated.
Can anyone give me an understanding of this problem? One of the methods, found here: http://www.math.uni-bielefeld.de/~sillke/SEQUENCES/grid-triangles (Problem C)
allowed for a single function to be used.
How did they come up with that solution? At this point, I'd really just like to understand some of the concepts behind this interesting problem. I know looking up the solution was not part of the Euler spirit, but I'm fairly sure I would not have solved this problem anyhow.
| 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.