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
|
|---|---|---|---|---|---|---|
How can I set Neural Networks so they accept and output a continuous range of values instead of a discrete ones?
From what I recall from doing a Neural Network class a couple of years ago, the activation function would be a sigmoid, which yields a value between 0 and 1. If I want my neural network to yield a real valued scalar, what should I do? I thought maybe if I wanted a value between 0 and 10 I could just multiply the value by 10? What if I have negative values? Is this what people usually do or is there any other way? What about the input?
Thanks
| 0
| 1
| 0
| 0
| 0
| 0
|
As much as I like using GUIDs as the unique identifiers in my system, it is not very user-friendly for fields like an order number where a customer may have to repeat that to a customer service representative.
What's a good algorithm to use to generate order number so that it is:
Unique
Not sequential (purely for optics)
Numeric values only (so it can be easily read to a CSR over phone or keyed in)
< 10 digits
Can be generated in the middle tier without doing a round trip to the database.
UPDATE (12/05/2009)
After carefully reviewing each of the answers posted, we decided to randomize a 9-digit number in the middle tier to be saved in the DB. In the case of a collision, we'll regenerate a new number.
| 0
| 0
| 0
| 0
| 1
| 0
|
I'm writing an AI-testing Framework for a competition. Participants submit a Bot class which matches a given Interface. Then all the bots play a turn-based game. On every turn, I want to do the following:
For every bot B:
start a thread that runs at most N cycles and does B.getNextMove()
wait for all threads to complete
Make all moves (from each bot).
My difficulty comes in saying "at most N cycles". I can limit all the bots by time (say half a second per turn) but this means that some can get more processor cycles than others and doesn't permit a strict "your bot should be able to make its decision re: a turn in X time" requirement in the competition.
As stated, this is in Java. Any ideas? I've been looking at concurrency and locking but this doesn't feel like the right direction. Also, it's possible to not run the bots in Parralel and then use time for the restriction (given that the computer isn't running anything else at the time), but this would be undesirable as it would significantly slow down the speed at which we could have results from the games.
| 0
| 1
| 0
| 0
| 0
| 0
|
For my university project I am creating a neural network that can classify the likelihood that a credit card transaction is fraudulent or not. I am training with backpropagation. I am writing this in Java. I would like to apply multithreading, because my computer is a quad-core i7. It bugs me to spend hours training and see most of my cores idle.
But how would I apply multithreading to backpropagation? Backprop works by adjusting the errors backwards through the network. One layer must be done before the other can continue. Is there any way that I can modify my program to do multicore backdrop?
| 0
| 1
| 0
| 0
| 0
| 0
|
I'm trying to find out when a quadratic selection algorithm is faster than a linear selection algorithm. Running some experiments I generated two 3D plots that show the algorithm run times as a function of the input array size and the desired order statistic. Using gnuplot to draw the plot I confirmed that there are cases when the quadratic algorithm is faster. I then used gnuplot's fitting algorithms to find two functions that model my observed runtimes (a,b,c,d,e,f are constants I've already found but leave out):
lin_alg_runtime(x,y) = ax + by +c
quad_alg_runtime(x,y) = (d*x * e*y) + f
where x is the size of the input array and y is the order statistic.
Now I'm kind of lost on how to use these models to calculate when to switch between the quadratic implementation and the linear implementation. I suspect I have to find where these two functions intersect but I'm not quite sure how to do that. How does one find where these two functions intersect?
| 0
| 0
| 0
| 0
| 1
| 0
|
I need to calculate a net mask and subnet addr using broadcast addr and host address from this subnet.
I must use only bitwise operations and not comparing of string representation, sysadmin tools and so on.
I have some formulas for calculating addresses. But I don't know how to use it with my source data.
^ -- is bitwise xor
~ -- negation
& and | conjunction and disjunction respectively
Formulas:
ip | (~m) = b
ip & m = n
n | (~m) = b
n ^ b = ~m
where n -- is subnet address, b -- broadcast address, ip -- host address from subnet and m -- is net mask.
(For example, I have 192.168.1.160 -- subnet addr, 192.168.1.191 -- broadcast, and /27 net mask (255.255.255.224))
| 0
| 0
| 0
| 0
| 1
| 0
|
I am making a simple AI and I am really new to this realm. What I need is an algorithm to make some sort of decisions based on some parameters; but with a little bit of randomness. What I have been doing so far is to generate a random number and based on the different values I get; take different execution paths. I somehow think there's a much better way to do this sort of thing. Can you give me some pointers?
| 0
| 1
| 0
| 0
| 0
| 0
|
For a homework assignment in linear algebra, I have solved the following equation using MATLAB's \ operator (which is the recommended way of doing it):
A = [0.2 0.25; 0.4 0.5; 0.4 0.25];
y = [0.9 1.7 1.2]';
x = A \ y
which produces the following answer:
x =
1.7000
2.0800
For the next part of assignment, I'm supposed to solve the same equation using the least squares approximation (and then compare it against the prior value to see how accurate the approximation is).
How can I find a way of doing that in MATLAB?
Prior work: I have found the function lsqlin, which seems to be able to solve equations of the above type, but I don't understand which arguments to supply it nor in what order.
| 0
| 0
| 0
| 0
| 1
| 0
|
Can the Dancing Links implementation of Knuth's Algorithm X be used to solve this CSP? In this game the first and last number are always already in the board and I belive there's only one solution to each well formulated problem.
| 0
| 1
| 0
| 0
| 0
| 0
|
Let's imagine we have an (x,y) plane where a robot can move. Now we define the middle of our world as the goal state, which means that we are going to give a reward of 100 to our robot once it reaches that state.
Now, let's say that there are 4 states(which I will call A,B,C,D) that can lead to the goal state.
The first time we are in A and go to the goal state, we will update our QValues table as following:
Q(state = A, action = going to goal state) = 100 + 0
One of 2 things can happen. I can end the episode here, and start a different one where the robot has to find again the goal state, or I can continue exploring the world even after I found the goal state. If I try to do this, I see a problem though. If I am in the goal state and go back to state A, it's Qvalue will be the following:
Q(state = goalState, action = going to A) = 0 + gamma * 100
Now, if I try to go again to the goal state from A:
Q(state = A, action = going to goal state) = 100 + gamma * (gamma * 100)
Which means that if I keep doing this, as 0 <= gamma <= 0, both qValues are going to rise forever.
Is this the expected behavior of QLearning? Am I doing something wrong? If this is the expected behavior, can't this lead to problems? I know that probabilistically, all the 4 states(A,B,C and D), will grow at the same rate, but even so it kinda bugs me having them growing forever.
The ideia of allowing the agent to continue exploring even after finding the goal has to do with that the nearer he is from the goal state, the more likely it is to being in states that can be updated at the moment.
| 0
| 1
| 0
| 0
| 0
| 0
|
I've made a program for my OOP class that does the following:
Defines a class to represent complex numbers.
Uses a constructor to initialize a Complex Number object.
Passes and returns complex number objects from a function.
Tests the complex number class in a driver.
Optionally adds and subtracts complex numbers.
My Program works as follows:
Prompts the user to Enter in the values for the real and imaginary parts of a complex number.
Creates a ComplexNumber object using the user provided values as parameters to the ComplexNumber constructor.
Prints the value of the complex number object, using the stand-alone print function.
I'm a little confused at this requirement though:
static void printComplexNumber(ComplexNumber n)
The function will print the Complex Number object passed as a parameter in the form realPart + imaginaryPart i
The realPart should be signed only if it is negative. The sign between the realPart and the imaginaryPart should be positive if the imaginaryPart is positive, and negative if the imaginaryPart is negative. If the real part is zero, only print the imaginary part, with the corrrect sign. If the imaginary part is zero, only print the real part. If the imaginary part is equal to one, just print the symbol i for the imaginary part.
Here's my question: What's the best(most efficient, clear, concise) way to determine when to print what?
My Code for my Print method:
static void PrintComplexNumber(ComplexNumber n)
{
// what's the best thing to do here to determine what to print?
// if-else?
// to get my real value and complex value, I have methods of the
// ComplexNumber class entitled: GetRealPart(), and GetComplexPart().
}
| 0
| 0
| 0
| 0
| 1
| 0
|
I have a vector consisting of a point, speed and direction. We will call this vector R. And another vector that only consists of a point and a speed. No direction. We will call this one T.
Now, what I am trying to do is to find the shortest intersection point of these two vectors. Since T has no direction, this is proving to be difficult. I was able to create a formula that works in CaRMetal but I can not get it working in python.
Can someone suggest a more efficient way to solve this problem? Or solve my existing formula for X?
Formula:
(source: bja888.com)
Key:
(source: bja888.com)
Where o or k is the speed difference between vectors. R.speed / T.speed
| 0
| 0
| 0
| 0
| 1
| 0
|
I'm in the middle of porting some c++ code to java, and I keep running across instances where whoever wrote it kept doing the following:
double c = (1.0/(a+1.0)*pow(b, a+1.0));
double d = (1./(integral(gamma, dmax)-integral(gamma, dmin)))*(integral(gamma+1, dmax)-integral(gamma+1, dmin));
Instead of:
double c = pow(b, a+1.0)/(a+1.0);
double d = (integral(gamma+1, dmax)-integral(gamma+1, dmin))/(integral(gamma, dmax)-integral(gamma, dmin));
The second seems much clearer, and unless I'm wrong about the order of operations in C++ they should do the same thing. Is there some reason to do the first and not the second? The only thing I could think of would be some weird case with precision.
| 0
| 0
| 0
| 0
| 1
| 0
|
I'm interested in creating poster-sized images that contain repeating patterns, similar to the two (public domain) images below, the Flower of Life and a Penrose tiling:
My questions:
How do people usually create images like these on a computer? I'm hoping the answer isn't, "Open Adobe Illustrator and guess at intersection points," since such points can be defined mathematically. But I also imagine that not everyone with an interest in geometric patterns is also familiar with programming.
What is the best environment for creating such images? In particular, what's the best way to get high-resolution images out of Java, Python, Processing, etc? Or, is Mathematica the best tool?
Actually calculating the points and doing the math isn't the hard part, in my mind (at least, it's not the focus of this question). I'm interested in the best way to get a high-quality visual product out of a program.
| 0
| 0
| 0
| 0
| 1
| 0
|
I'm looking to try and write a chess AI. Is there something i can use on the .NET framework (or maybe even a chess program scripted in Lua) that will let me write and test a chess AI without worrying about actually makign a chess game?
| 0
| 1
| 0
| 0
| 0
| 0
|
I've been trying to find an answer to this for months (to be used in a machine learning application), it doesn't seem like it should be a terribly hard problem, but I'm a software engineer, and math was never one of my strengths.
Here is the scenario:
I have a (possibly) unevenly weighted coin and I want to figure out the probability of it coming up heads. I know that coins from the same box that this one came from have an average probability of p, and I also know the standard deviation of these probabilities (call it s).
(If other summary properties of the probabilities of other coins aside from their mean and stddev would be useful, I can probably get them too.)
I toss the coin n times, and it comes up heads h times.
The naive approach is that the probability is just h/n - but if n is small this is unlikely to be accurate.
Is there a computationally efficient way (ie. doesn't involve very very large or very very small numbers) to take p and s into consideration to come up with a more accurate probability estimate, even when n is small?
I'd appreciate it if any answers could use pseudocode rather than mathematical notation since I find most mathematical notation to be impenetrable ;-)
Other answers:
There are some other answers on SO that are similar, but the answers provided are unsatisfactory. For example this is not computationally efficient because it quickly involves numbers way smaller than can be represented even in double-precision floats. And this one turned out to be incorrect.
| 0
| 0
| 0
| 1
| 0
| 0
|
The problem is to derive a formula for determining number of digits a given decimal number could have in a given base.
For example: The decimal number 100006 can be represented by 17,11,9,8,7,6,8 digits in bases 2,3,4,5,6,7,8 respectively.
Well the formula I derived so far is like this : (log10(num) /log10(base)) + 1.
in C/C++ I used this formula to compute the above given results.
long long int size = ((double)log10(num) / (double)log10(base)) + 1.0;
But sadly the formula is not giving correct answer is some cases,like these :
Number 8 in base 2 : 1,0,0,0
Number of digits: 4
Formula returned: 3
Number 64 in base 2 : 1,0,0,0,0,0,0
Number of digits: 7
Formula returned: 6
Number 64 in base 4 : 1,0,0,0
Number of digits: 4
Formula returned: 3
Number 125 in base 5 : 1,0,0,0
Number of digits: 4
Formula returned: 3
Number 128 in base 2 : 1,0,0,0,0,0,0,0
Number of digits: 8
Formula returned: 7
Number 216 in base 6 : 1,0,0,0
Number of digits: 4
Formula returned: 3
Number 243 in base 3 : 1,0,0,0,0,0
Number of digits: 6
Formula returned: 5
Number 343 in base 7 : 1,0,0,0
Number of digits: 4
Formula returned: 3
So the error is by 1 digit.I just want somebody to help me to correct the formula so that it work for every possible cases.
Edit : As per the input specification I have to deal with cases like 10000000000, i.e 10^10,I don't think log10() in either C/C++ can handle such cases ? So any other procedure/formula for this problem will be highly appreciated.
| 0
| 0
| 0
| 0
| 1
| 0
|
This is to extend the question: Tools to help reverse engineer binary file formats
Are there any tools that are publicly available that uses clustering and/or data mining techniques to reverse engineer file formats?
For example, with the tool you would have a collection of files that have the same format and the output of the tool would be the generic structure?
| 0
| 1
| 0
| 0
| 0
| 0
|
Ok. So I guess thing would to be envision new york city and beijing highlighted on google earth...
I'm trying to figure out how to map points onto a 3d primitive object (a sphere), get their distance via any direction by the circumference, and their distance by diameter. The points are going to be latitude and longitude coordinates.
Right now, this is what i'm trying to use to map the coordinates (a code agnostic version):
x1 = radius * cos(long1) * cos(lat1);
y1 = radius * sin(long1) * cos(lat1);
z1 = radius * sin(lat1);
but i'm almost sure its wrong. How could I get each points position and calculate their distances straight across the sphere's diameter and also their distance going around the circumference of the sphere?
Thanks.
| 0
| 0
| 0
| 0
| 1
| 0
|
How can I z-order the faces of a 3d object just using the 4 vertices of each of its faces? I've tried using a z-buffer where I store the average z value of each face; this works great most of the times, but fails when an object have large and small faces.
I'm building a small 3d-engine in flash, just for the fun of learning, so the only data i have is those 4 vertices and the normal of the face.
Thanks!
| 0
| 0
| 0
| 0
| 1
| 0
|
If I have a matrix which is a combination of WorldViewProjection and I multiply it by the inverse of the projection does it yield the WorldView matrix or something else? If not then how can I extract the WorldView matrix from a WorldViewProjection matrix?
Thanks for any help :)
| 0
| 0
| 0
| 0
| 1
| 0
|
I have gone through earlier discussions on floating point numbers in SO but that didn't clarified my problem,I knew this floating point issues may be common in every forum but my question in not concerned about Floating point arithmetic or Comparison.I am rather inquisitive about its representation and output with %f.
The question is straight forward :"How to determine the exact output of :
float = <Some_Value>f;
printf("%f
",<Float_Variable>);
Lets us consider this code snippet:
float f = 43.2f,
f1 = 23.7f,
f2 = 58.89f,
f3 = 0.7f;
printf("f1 = %f
",f);
printf("f2 = %f
",f1);
printf("f3 = %f
",f2);
printf("f4 = %f
",f3);
Output:
f1 = 43.200001
f2 = 23.700001
f3 = 58.889999
f4 = 0.700000
I am aware that %f (is meant to be for double) has a default precision of 6, also I am aware that the problem (in this case) can be fixed by using double but I am inquisitive about the output f2 = 23.700001 and f3 = 58.889999 in float.
EDIT: I am aware that floating point number cannot be represented precisely, but what is the rule of for obtaining the closest representable value ?
Thanks,
| 0
| 0
| 0
| 0
| 1
| 0
|
Im trying to implement a bezier curve and line segment intersection test. The closest thing my searching has turned up is to take the bezier curve (lets limit it to three control points for simplicity) find the mathematical function generating that curve and place it on origo. Then, using the function for the line segment as another function and let them be equal and solve the equation.
Many sources state the above solution (unless Ive misunderstood them), my problem is I cant find the way to calculate the mathematical function that generates the bezier curve.
Oh, and please point out if Im completely off track with finding the intersection point(s).
| 0
| 0
| 0
| 0
| 1
| 0
|
I have a simple, but perplexing problem, with Math.
The following code will take a number from a string (usually contained in a span or div) and subtract the value of 1 from it.
.replace(/(\d+)/g, function(a,n){ return (+n-1); });
This works really well, except when we get below zero. Once we get to -1 we're obviously dealing with negative subtraction.
-1 - 1 = -0
-0 - 1 = --1
how can I avoid this? It's likely I've got a general problem with the math here.
| 0
| 0
| 0
| 0
| 1
| 0
|
I wish to implement a audio visualizer widget (similar to what Winamp has) in WPF. How would I approach this problem?
| 0
| 0
| 0
| 0
| 1
| 0
|
I need an exponential equation with the following parameters:
When x = 0, y = 153.
When x = 500, y = 53.
Y should increase exponentially as X approaches 0 and should decrease exponentially when X approaches 500.
For some reason I can't remember how to do this.
I'm sure once I see the equation (or one similar) I can figure out the rest.
Context in Programming: This is for a Javascript function that changes the color of a div when a textarea's max-length is about to be reached. Other alternatives or code snippets are very welcome.
UPDATE:
I don't know why but -1500/(x+15)+153 gives me something close to what I am looking for. So It looks like what I was asking for is not what I really wanted.
I guess what I am looking for is:
When x = 0, y = 53.
When x = 500, y = 153.
| 0
| 0
| 0
| 0
| 1
| 0
|
Okay I'm working on a Space sim and as most space sims I need to work out where the opponents ship will be (the 3d position) when my bullet reaches it. How do I calculate this from the velocity that bullets travel at and the velocity of the opponents ship?
| 0
| 0
| 0
| 0
| 1
| 0
|
I have a map of the US, and I've got a lot of pixel coordinates on that map which correspond to places of interest. These are dynamically drawn on the map at runtime according to various settings and statistics.
I now need to switch over to a different map of the US which is differently sized, and the top left corner of the map is in a slightly place in the ocean.
So I've manually collected a small set of coordinates for each map that correspond to one another. For example, the point (244,312) on the first map corresponds to the point (598,624) on the second map, and (1323,374) on the first map corresponds to (2793,545) on the second map, etc.
So I'm trying to decide the translation for the X and Y dimensions. So given a set of points for the old and new maps, how do I find the x' = A*x + C and y' = B*x + D equations to automatically translate any point from the old map to the new one?
| 0
| 0
| 0
| 0
| 1
| 0
|
I am using the Stanford Natural Language processing toolkit. I've been trying to find spelling errors with Lexicon's isKnown method, but it produces quite a few false positives. So I thought I'd load a second lexicon, and check that too. However, that causes a problem.
private static LexicalizedParser lp = new LexicalizedParser(Constants.stdLexFile);
private static LexicalizedParser wsjLexParse = new LexicalizedParser(Constants.wsjLexFile);
static {
lp.setOptionFlags(Constants.lexOptionFlags);
wsjLexParse.setOptionFlags(Constants.lexOptionFlags);
}
public ParseTree(String input) throws IllegalArgumentException, IllegalAccessException, InvocationTargetException {
initialInput = input;
DocumentPreprocessor process = new DocumentPreprocessor();
sentences = process.getSentencesFromText(new StringReader(input));
for (List<? extends HasWord> sent : sentences) {
if(lp.parse(sent)) { // line 65
forest.add(lp.getBestParse()); //non determinism?
}
}
partsOfSpeech = pos();
runAnalysis();
}
The following fail trace is produced:
java.lang.ArrayIndexOutOfBoundsException: 45547
at edu.stanford.nlp.parser.lexparser.BaseLexicon.initRulesWithWord(BaseLexicon.java:300)
at edu.stanford.nlp.parser.lexparser.BaseLexicon.isKnown(BaseLexicon.java:160)
at edu.stanford.nlp.parser.lexparser.BaseLexicon.ruleIteratorByWord(BaseLexicon.java:212)
at edu.stanford.nlp.parser.lexparser.ExhaustivePCFGParser.initializeChart(ExhaustivePCFGParser.java:1299)
at edu.stanford.nlp.parser.lexparser.ExhaustivePCFGParser.parse(ExhaustivePCFGParser.java:388)
at edu.stanford.nlp.parser.lexparser.LexicalizedParser.parse(LexicalizedParser.java:234)
at nth.compling.ParseTree.<init>(ParseTree.java:65)
at nth.compling.ParseTreeTest.constructor(ParseTreeTest.java:33)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.internal.runners.BeforeAndAfterRunner.invokeMethod(BeforeAndAfterRunner.java:74)
at org.junit.internal.runners.BeforeAndAfterRunner.runBefores(BeforeAndAfterRunner.java:50)
at org.junit.internal.runners.BeforeAndAfterRunner.runProtected(BeforeAndAfterRunner.java:33)
at org.junit.internal.runners.TestClassRunner.run(TestClassRunner.java:52)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:45)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
If I comment out this line: (and other references to wsjLexParse)
private static LexicalizedParser wsjLexParse = new LexicalizedParser(Constants.wsjLexFile);
then everything works fine. What am I doing wrong here?
| 0
| 1
| 0
| 0
| 0
| 0
|
I'm making a software rasterizer for school, and I'm using an unusual rendering method instead of traditional matrix calculations. It's based on a pinhole camera. I have a few points in 3D space, and I convert them to 2D screen coordinates by taking the distance between it and the camera and normalizing it
Vec3 ray_to_camera = (a_Point - plane_pos).Normalize();
This gives me a directional vector towards the camera. I then turn that direction into a ray by placing the ray's origin on the camera and performing a ray-plane intersection with a plane slightly behind the camera.
Vec3 plane_pos = m_Position + (m_Direction * m_ScreenDistance);
float dot = ray_to_camera.GetDotProduct(m_Direction);
if (dot < 0)
{
float time = (-m_ScreenDistance - plane_pos.GetDotProduct(m_Direction)) / dot;
// if time is smaller than 0 the ray is either parallel to the plane or misses it
if (time >= 0)
{
// retrieving the actual intersection point
a_Point -= (m_Direction * ((a_Point - plane_pos).GetDotProduct(m_Direction)));
// subtracting the plane origin from the intersection point
// puts the point at world origin (0, 0, 0)
Vec3 sub = a_Point - plane_pos;
// the axes are calculated by saying the directional vector of the camera
// is the new z axis
projected.x = sub.GetDotProduct(m_Axis[0]);
projected.y = sub.GetDotProduct(m_Axis[1]);
}
}
This works wonderful, but I'm wondering: can the algorithm be made any faster? Right now, for every triangle in the scene, I have to calculate three normals.
float length = 1 / sqrtf(GetSquaredLength());
x *= length;
y *= length;
z *= length;
Even with a fast reciprocal square root approximation (1 / sqrt(x)) that's going to be very demanding.
My questions are thus:
Is there a good way to approximate the three normals?
What is this rendering technique called?
Can the three vertex points be approximated using the normal of the centroid? ((v0 + v1 + v2) / 3)
Thanks in advance.
P.S. "You will build a fully functional software rasterizer in the next seven weeks with the help of an expert in this field. Begin." I ADORE my education. :)
EDIT:
Vec2 projected;
// the plane is behind the camera
Vec3 plane_pos = m_Position + (m_Direction * m_ScreenDistance);
float scale = m_ScreenDistance / (m_Position - plane_pos).GetSquaredLength();
// times -100 because of the squared length instead of the length
// (which would involve a squared root)
projected.x = a_Point.GetDotProduct(m_Axis[0]).x * scale * -100;
projected.y = a_Point.GetDotProduct(m_Axis[1]).y * scale * -100;
return projected;
This returns the correct results, however the model is now independent of the camera position. :(
It's a lot shorter and faster though!
| 0
| 0
| 0
| 0
| 1
| 0
|
Given data values of some real-time physical process (e.g. network traffic) it is to find a name of the function which "at best" matches with the data.
I have a set of functions of type y=f(t) where y and t are real:
funcs = set([cos, tan, exp, log])
and a list of data values:
vals = [59874.141, 192754.791, 342413.392, 1102604.284, 3299017.372]
What is the simplest possible method to find a function from given set which will generate the very similar values?
PS: t is increasing starting from some positive value by almost-equal intervals
| 0
| 0
| 0
| 0
| 1
| 0
|
How do you draw the curve representing the shortest distance between 2 points on a flat map of the Earth?
Of course, the line would not be a straight line because the Earth is curved. (For example, the shortest distance between 2 airports is curved.)
EDIT: THanks for all the answers guys - sorry I was slow to choose solution :/
| 0
| 0
| 0
| 0
| 1
| 0
|
A little background: as a way to learn multinode trees in C++, I decided to generate all possible TicTacToe boards and store them in a tree such that the branch beginning at a node are all boards that can follow from that node, and the children of a node are boards that follow in one move. After that, I thought it would be fun to write an AI to play TicTacToe using that tree as a decision tree.
TTT is a solvable problem where a perfect player will never lose, so it seemed an easy AI to code for my first time trying an AI.
Now when I first implemented the AI, I went back and added two fields to each node upon generation: the # of times X will win & the # of times O will win in all children below that node. I figured the best solution was to simply have my AI on each move choose and go down the subtree where it wins the most times. Then I discovered that while it plays perfect most of the time, I found ways where I could beat it. It wasn't a problem with my code, simply a problem with the way I had the AI choose it's path.
Then I decided to have it choose the tree with either the maximum wins for the computer or the maximum losses for the human, whichever was more. This made it perform BETTER, but still not perfect. I could still beat it.
So I have two ideas and I'm hoping for input on which is better:
1) Instead of maximizing the wins or losses, instead I could assign values of 1 for a win, 0 for a draw, and -1 for a loss. Then choosing the tree with the highest value will be the best move because that next node can't be a move that results in a loss. It's an easy change in the board generation, but it retains the same search space and memory usage. Or...
2) During board generation, if there is a board such that either X or O will win in their next move, only the child that prevents that win will be generated. No other child nodes will be considered, and then generation will proceed as normal after that. It shrinks the size of the tree, but then I have to implement an algorithm to determine if there is a one move win and I think that can only be done in linear time (making board generation a lot slower I think?)
Which is better, or is there an even better solution?
| 0
| 1
| 0
| 0
| 0
| 0
|
How to generate a code from two numbers, that when you know this code and one of the numbers you can descramble the second number?
For example you have two numbers: 983 and 2303 and you "mix" it into hex-string like this:4b17a190bce4ea32236b98dd. When you know first number and this hex-string you can descramble second number. But when you know the second number and hex-string you cannot descramble first number. How to do this?
| 0
| 0
| 0
| 0
| 1
| 0
|
I'm currently reading "Artificial Intelligence: A Modern Approach" (Russell+Norvig) and "Machine Learning" (Mitchell) - and trying to learn basics of AINN.
In order to understand few basic things I have two 'greenhorn' questions:
Q1: In a genetic algorithm given the two parents A and B with the chromosomes 001110 and 101101, respectively, which of the following offspring could have resulted from a one-point crossover?
a: 001101
b: 001110
Q2: Which of the above offspring could have resulted from a two-point crossover? and why?
Please advise.
| 0
| 1
| 0
| 1
| 0
| 0
|
I am writing a program in C. I want to find a solution by minimizing expression
D1+D2+......+Dn
where Di's are distances calculated by distance formula between 2 points. The above expression is in x & y variables
Now I will differentiate this expression and find the solution. My doubt is:
since in the above expression, all Di's will occur as square roots which will be difficult to solve. So instead we can solve for this expression:
D1^2 + D2^2 + ......+ Dn^2
Will the answer produced by the above expression will be same as that would have been produced by solving the original one?
I have checked for simple test cases such as n=2. It produces the correct answer. Is it true in general?
If not, how this problem can be solved?
| 0
| 0
| 0
| 0
| 1
| 0
|
Is there an OSS which can compress a text to a synopsis?
My goal is to build an editor for SciFi novels which can either automatically create a synopsizes for chapters or at least make a suggestion for one.
| 0
| 1
| 0
| 0
| 0
| 0
|
When the user visits the site, I can get their country code. I want to use this to set the default language (which they can later modify if necessary, just a general guess as to what language they might speak based on what country they are in).
Is there a definitive mapping from country codes to language codes that exists somewhere? I could not find it. I know that not everyone in a particular country speaks the same language, but I just need a general mapping, the user can select their language manually later.
| 0
| 1
| 0
| 0
| 0
| 0
|
I have a set of columns of varying widths and I need an algorithm to re-size them for some value y which is greater than the sum of all their widths.
I would like the algorithm to prioritize equalizing the widths. So if I have a value that's absolutely huge the columns will end up with more or less the same width. If there isn't enough room for that I want the smaller cells to be given preference.
Any whiz bang ideas? I'd prefer something as simple as:
getNewWidths(NewWidth, ColumnWidths[]) returns NewColumnWidths[]
| 0
| 0
| 0
| 0
| 1
| 0
|
In the same thread as this question, I am giving this another shot and ask SO to help address how I should take care of this problem. I'm writing a bash script which needs to perform the following:
I have a circle in x and y with radius r.
I specify resolution which is the distance between points I'm checking.
I need to loop over x and y (from -r to r) and check if the current (x,y) is in the circle, but I loop over discrete i and j instead.
Then i and j need to go from -r/resolution to +r/resolution.
In the loop, what will need to happen is echo "some_text i*resolution j*resolution 15.95 cm" (note lack of $'s because I'm clueless). This output is what I'm really looking for.
My best shot so far:
r=40.5
resolution=2.5
end=$(echo "scale=0;$r/$resolution") | bc
for (( i=-end; i<=end; i++ ));do
for (( j=-end; j<=end; j++ ));do
x=$(echo "scale=5;$i*$resolution") | bc
y=$(echo "scale=5;$j*$resolution") | bc
if (( x*x + y*y <= r*r ));then <-- No, r*r will not work
echo "some_text i*resolution j*resolution 15.95 cm"
fi
done
done
I've had just about enough with bash and may look into ksh like was suggested by someone in my last question, but if anyone knows a proper way to execute this, please let me know! What ever the solution to this, it will set my future temperament towards bash scripting for sure.
| 0
| 0
| 0
| 0
| 1
| 0
|
I'm trying to determine for the articial neuron shown below the values (0 or 1)
for the inputs i1, i2, and i3 for which it will fire (i0 is the input for the
bias weight and will always be -1).
The weights are
W0 = 1.5
W1 = -1
W2 = 1, and W3 = 2.
Assume the activation function depicted in image below.
Please clarify your answer as I have done few examples and still I'm not able to fully understand the theory :(
Many thanks,
Mary J.
PS. Image below:
| 0
| 1
| 0
| 0
| 0
| 0
|
Can someone give me some pointers on how I should implement the artificial intelligence (human vs. computer gameplay) for a Puyo Puyo game? Is this project even worth pursuing?
The point of the game is to form chains of 4 or more beans of the same color that trigger other chains. The longer your chain is, the more points you get. My description isn't that great so here's a simple video of a game in progress: http://www.youtube.com/watch?v=K1JQQbDKTd8&feature=related
Thanks!
| 0
| 1
| 0
| 0
| 0
| 0
|
Say I got a set of 10 random numbers between 0 and 100.
An operator gives me also a random number between 0 and 100.
Then I got to find the number in the set that is the closest from the number the operator gave me.
example
set = {1,10,34,39,69,89,94,96,98,100}
operator number = 45
return = 39
And how do translate this into code? (javascript or something)
| 0
| 0
| 0
| 0
| 1
| 0
|
I am developing a game that calls so many math functions for physics and rendering. "Fast inverse sqrt" used in Quake3 is known to be faster than sqrt() and its background is beautiful.
Do you know any other algorithm that is faster than usual one with acceptable accuracy loss?
| 0
| 0
| 0
| 0
| 1
| 0
|
I am trying to implement a "Look At" behavior for planes moving around a sphere so they always face the camera.
What I figured out so far, I know the normal that the plane should have and I know that its rotation around its local Z axis should always be 0. I thought it was a pretty trivial operation to figure out the missing rotation values (X, Y) but so far, I found nothing.
So in short : How can I extract orientation information of a plane using its normal and one rotation value?
Or, if anyone has a better solution than using the normal, it would be welcome.
Thanks.
| 0
| 0
| 0
| 0
| 1
| 0
|
Pretty common situation, I'd wager. You have a blog or news site and you have plenty of articles or blags or whatever you call them, and you want to, at the bottom of each, suggest others that seem to be related.
Let's assume very little metadata about each item. That is, no tags, categories. Treat as one big blob of text, including the title and author name.
How do you go about finding the possibly related documents?
I'm rather interested in the actual algorithm, not ready solutions, although I'd be ok with taking a look at something implemented in ruby or python, or relying on mysql or pgsql.
edit: the current answer is pretty good but I'd like to see more. Maybe some really bare example code for a thing or two.
| 0
| 0
| 0
| 1
| 0
| 0
|
mysql_query("insert into mytable (flow,holderid,amount,operator,ip,product,taskid,comment)values('-1','$memberid','$sum+5','$memberid','$ip','Expertise','$taskid','Publish a problem or task') ")or die(mysql_error());
I get an error about
'$sum+5'
MySQL doesn't treat it as an and operation, how to resolve this problem?
| 0
| 0
| 0
| 0
| 1
| 0
|
L->|
A -> B ^ |
|__> C -> D-> G->X--| |
K |_> T | |_>Z
|___________|
I hope this small drawing helps convey what I'm trying to do.
I have a list of 7,000 locations, each with an undefined, but small number of doors. Each door is a bridge between both locations.
Referencing the diagram above, how would I go about finding the quickest route through the doors to get from A to Z?
I don't need full on source, just psuedo code would be fine.
Obviously you can take A -> B ->C -> D -> G -> X -> L -> Z,
but the shortest route is A -> B -> C -> K -> X -> Z.
| 0
| 0
| 0
| 0
| 1
| 0
|
I am trying to figure out a calculation I can perform in C# to determine the rows per column. Let's say I know I am going to have 3 columns and my record count is 46. I know that I can mod the results to get a remainder, but I would like something more efficient than what I have tried. So I know I will have 16 rows per column with a remainder of 14 for the last column, but what is the best way to loop through the resutls and keep counts.
| 0
| 0
| 0
| 0
| 1
| 0
|
I have this operation:
t = (x - (y * (z + w)) - w) / 2;
where:
x = 268;
y = 4;
z = 20;
w = 30;
As far as I know the result will be 49, but I getting 19.
Where is my error? (In using this code on a .Net Compact Framework 2.0 SP2 WinForm app).
Thank you.
| 0
| 0
| 0
| 0
| 1
| 0
|
For example, math logic, graph theory.
Everyone around tells me that math is necessary for programmer. I saw a lot of threads where people say that they used linear algebra and some other math, but no one described concrete cases when they used it.
I know that there are similar threads, but I couldn't see any description of such a case.
| 0
| 0
| 0
| 0
| 1
| 0
|
What would be the solution to the following two equations ?
A1uv + B1u + C1v + D1 = 0
A2uv + B2u + C2v + D2 = 0
u, v in [0, 1]
The solution needs to be blazing fast because it needs to be solved for each pixel, hopefully a direct rather than iterative solution.
This is basically trying to find the inverse of a coons patch where the boundaries are straight lines.
| 0
| 0
| 0
| 0
| 1
| 0
|
Just been looking at a code golf question about generating a sorted list of 100 random integers. What popped into my head, however, was the idea that you could generate instead a list of positive deltas, and just keep adding them to a running total, thus:
deltas: 1 3 2 7 2
ints: 1 4 6 13 15
In fact, you would use floats, then normalise to fit some upper limit, and round, but the effect is the same.
Although it wouldn't make for shorter code, it would certainly be faster without the sort step. But the thing I have no real handle on is this: Would the resulting distribution of integers be the same as generating 100 random integers from a uniformly distributed probability density function?
Edit: A sample script:
import random,sys
running = 0
max = 1000
deltas = [random.random() for i in range(0,11)]
floats = []
for d in deltas:
running += d
floats.append(running)
upper = floats.pop()
ints = [int(round(f/upper*max)) for f in floats]
print(ints)
Whose output (fair dice roll) was:
[24, 71, 133, 261, 308, 347, 499, 543, 722, 852]
UPDATE: Alok's answer and Dan Dyer's comment point out that using an exponential distribution for the deltas would give a uniform distribution of integers.
| 0
| 0
| 0
| 0
| 1
| 0
|
please help to print series as well sum of series like 1*3-3*5+5*7 up to n terms i have used code like this in php
class series {
function ser(){
$i = 0;
$k = 3;
$m = 0;
for($j = 1; $j < 3; $j++) {
if($j % 2 == 0 ) {
$m = $i + ($i * $k);
} else {
$m=$m-($i*$k);
}
}
//$m = $m + $i;
echo "$m";
}
}
$se = new series();
$se->ser();
Just i have tested for 2 times
| 0
| 0
| 0
| 0
| 1
| 0
|
I´ve got a question concerning two sets of points in a 3d space.
I defined a volume by 40 coordinates in one cartesian coordinate system,
in another coordinate system with different (0,0,0) i have s slightly different volume also defined by 40 coordinates. I know the matching pairs of the point sets and I want to measure the difference of each point pair (euclidian distance).
Now 1) how can i reference both coordinate systems (same scale) to each other and 2) how would i best calculate the transformation to register both volumes?
Thank you for your help.
| 0
| 0
| 0
| 0
| 1
| 0
|
I have a couple of questions about how to code the backpropagation algorithm of neural networks:
The topology of my networks is an input layer, hidden layer and output layer. Both the hidden layer and output layer have sigmoid functions.
First of all, should I use the bias?
To where should I connect the bias
in my network? Should I put one bias
unit per layer in both the hidden
layer and output layer? What about
the input layer?
In this link, they define the last delta as the input - output and they backpropagate the deltas as can be seen in the figure. They hold a table to put
all the deltas before actually
propagating the errors in a
feedforward fashion. Is this a
departure from the standard
backpropagation algorithm?
Should I decrease the learning
factor over time?
In case anyone knows, is Resilient
Propagation an online or batch
learning technique?
Thanks
edit: One more thing. In the following picture, d f1(e) / de, assuming I'm using the sigmoid function, is f1(e) * [1- f1(e)], right?
| 0
| 1
| 0
| 0
| 0
| 0
|
This question can probably be broken up into multiple questions, but here goes...
In essence, I'd like to allow users to type in what they would like to do and provide a wizard-like interface to ask for information which is missing to complete a requested query. For example, let's say a user types: "What is the weather like in Springfield?"
We recognize the user is interested in weather, but it could be Springfield, Il or Springfield in another state. A follow-up question would be:
What Springfield did you want weather for?
1 - Springfield, Il
2 - Springfield, Wi
You can probably think of a million examples where a request is missing key data or its ambiguous. Make the assumption the gist of what the user wants can be understood, but there are missing pieces of data required to complete the request.
Perhaps you can take it as far back as asking what the user wants to do and "leading" them to a query.
This is not AI in the sense of taking any input and truly understanding it. I'm not referring to having some way to hold a conversation with a user. It's about inferring what a user wants, checking to see if there is an applicable service to be provided, identifying the inputs needed and overlaying that on top of what's missing from the request, then asking the user for the remaining information. That's it! :-)
How would you want to store the information about services? How would you go about determining what was missing from the input data?
My thoughts:
Use regex expressions to identify clear pieces of information. These will be matched to the parameters of a service. Figure out which parameters do not have matching data and look up the associated question for those parameters. Ask those questions and capture answers. Re-run the service passing in the newly captured data. These would be more free-form questions.
For multiple choice, identify the ambiguity and search for potential matches ranked in order of likelihood (add in user history/preferences to help decide). Provide the top 3 as choices.
Thoughts appreciated.
Cheers,
Henry
| 0
| 1
| 0
| 0
| 0
| 0
|
Has anyone dealt with re-distributing an application that uses the Numerical Algorithms Group (NAG) Libraries?
It seems like when I build an executable, it won't run unless I have an environment variable set for the license file- i.e. if I gave someone the code they would need a license and associated daemon as well.
Is there no way around that? I was hoping I only need the license to link with it.
| 0
| 0
| 0
| 0
| 1
| 0
|
How can I tell NLTK to treat the text in a particular language?
Once in a while I write a specialized NLP routine to do POS tagging, tokenizing and etc. on a non-english (but still hindo-European) text domain.
This question seem to address only different corpora, not the change in code/settings:
POS tagging in German
Alternatively,are there any specialized Hebrew/Spanish/Polish NLP modules for python?
| 0
| 1
| 0
| 0
| 0
| 0
|
I'm tweening a movieclip from startX to finishX. The value of startX varies but finishX is a constant. But as the startX increases in value the animation appears to be quicker. How do I adjust the speed of the tween to ensure a consistant speed regardless of the value of startX?
Thanks
| 0
| 0
| 0
| 0
| 1
| 0
|
We've all poked fun at the 'X minutes remaining' dialog which seems to be too simplistic, but how can we improve it?
Effectively, the input is the set of download speeds up to the current time, and we need to use this to estimate the completion time, perhaps with an indication of certainty, like '20-25 mins remaining' using some Y% confidence interval.
Code that did this could be put in a little library and used in projects all over, so is it really that difficult? How would you do it? What weighting would you give to previous download speeds?
Or is there some open source code already out there?
Edit: Summarising:
Improve estimated completion time via better algo/filter etc.
Provide interval instead of single time ('1h45-2h30 mins'), or just limit the precision ('about 2 hours').
Indicate when progress has stalled - although if progress consistently stalls and then continues, we should be able to deal with that. Perhaps 'about 2 hours, currently stalled'
| 0
| 0
| 0
| 0
| 1
| 0
|
When I began this project, I thought it would be easy to get libraries for common stuff like matrix math, so I chose to work in Python 3.1- it being the most recent, updated version of the language. Unfortunately, NumPy is only compatible with 2.5 and 2.6 and seems to be the only game in town! Even other stuff that I turned up like gameobjects seemed to be based on NumPy and therefore incompatible with 3.x as well.
Does anyone out there know of a matrix library that is compatible with 3? I need to be able to do the following: matrix add, subtract, multiply, scalar multiply, inverse, transpose, and determinant. I've been looking all day and all roads seem to lead back to NumPy. I even tried this module: http://www.nightmare.com/squirl/python-ext/misc/matrix.py but it too is for 2.x. Even after converting it using the 2to3 tool, I can't get the yarn module that it refers to (and is probably itself 2.x).
Any help is hugely appreciated.
| 0
| 0
| 0
| 0
| 1
| 0
|
When doing:
load training.mat
training = G
load testing.mat
test = G
and then:
>> knnclassify(test.Inp, training.Inp, training.Ltr)
??? Error using ==> knnclassify at 91
The length of GROUP must equal the number of rows in TRAINING.
Since:
>> size(training.Inp)
ans =
40 40 2016
And:
>> length(training.Ltr)
ans =
2016
How can I give the second parameter of knnclassify (TRAINING) the training.inp 3-D matrix so that the number of rows will be 2016 (the third dimension)?
| 0
| 0
| 0
| 1
| 0
| 0
|
I have a weird problem in asp.NET when calculating how many hours we need to invoice.
In the below example, we have a total of 75,9 hours that need to be invoiced.
These hours are spread over several database rows (TimeIDs).
Basically, I always deduct the "amount_invoiced" from the "to invoice" hourly count:
TimeID:25433 - to invoice=75,9 - amount_invoiced=1
TimeID:25774 - to invoice=74,9 - amount_invoiced=1
TimeID:24688 - to invoice=73,9 - amount_invoiced=1,5
TimeID:24646 - to invoice=72,4 - amount_invoiced=2
TimeID:24890 - to invoice=70,4 - amount_invoiced=2
TimeID:25773 - to invoice=68,4 - amount_invoiced=2,25
TimeID:24455 - to invoice=66,15 - amount_invoiced=2,5
TimeID:25431 - to invoice=63,65 - amount_invoiced=2,5
TimeID:24552 - to invoice=61,15 - amount_invoiced=3
TimeID:24644 - to invoice=58,15 - amount_invoiced=3
TimeID:24727 - to invoice=55,15 - amount_invoiced=3
TimeID:25000 - to invoice=52,15 - amount_invoiced=4
TimeID:25195 - to invoice=48,15 - amount_invoiced=4,15
TimeID:24510 - to invoice=44 - amount_invoiced=4,5
TimeID:24419 - to invoice=39,5 - amount_invoiced=5
TimeID:25126 - to invoice=34,5 - amount_invoiced=5,5
TimeID:25064 - to invoice=29 - amount_invoiced=6,5
TimeID:24420 - to invoice=22,5 - amount_invoiced=7
TimeID:25251 - to invoice=15,5 - amount_invoiced=7,5
TimeID:24897 - to invoice=8,00000000000001 - amount_invoiced=8
Everything works ok, except for TimeID 24897.
Somehow the calculation of 15,5 - 7,5 = 8,00000000000001
I'm baffled as to why this would happen. Has anyone experienced a similar issue?
| 0
| 0
| 0
| 0
| 1
| 0
|
This is a math problem, but I'm sure this must come up in some programming scenarios, at least I hope so, and I was wondering if there was a name for this type of situation:
Suppose I have 7 items in a series. For the sake of this example, let's use days of the week. I would like a user to submit which days of the week they plan to come in the following week. They are presented with a standard series of checkboxes, one for each day of the week.
I would like to store which days they choose in one database field as a single integer.
Obviously, I could assign each day a number, 1 - 7 (leaving 0 out in case the user leaves all choices unchecked). But then I run into problems if one user chooses Monday and Tuesday ( 1 + 2) and another chooses Wednesday (3).
I could also give each day of the week some bizarre unique such that it was impossible for any combination of digits to be identical to any other combination.
My hope is that rather than make up such a series for the second scenario, some numerical property already exists (perhaps the square of each number in the series, etc) that is already well-used and respected. Ideally, this would be so familiar to programming, that deriving the individual digits would take very little overhead of a common programming language (in my case PHP).
Did I just dream this up, or does something like this exist?
| 0
| 0
| 0
| 0
| 1
| 0
|
I am adding "layer" objects to the stage with a depth value.
I have then created my own camera class. When I tell the camera to move to the right what Im actually doing is telling each layer object to move to the left.
The distance that the layer moved to the left is based on the value of its depth variable...
var fCameraDepth = 1;
var fTan:Number = Math.tan( fCameraMovement / fCameraDepth );
oLayer.x += fTan * fLayerDepth
This works well and gives me a really nice parallax effect. The problem I'm having is that I want to be able to tell the camera to look at a movie clip on any layer but I'm having trouble figuring out how to convert the movie clips coordinates to the cameras depth.
Im trying something like this...
var fCameraDepth = 1;
var fCameraPosition:Number = oCamera.x;
// the layer will have a + or - x val compared to the camera so we
// need to take that into account when getting the targets position
var fTargetPosition:Number = oActor.x + oActor.getLayer().x;
var fTargetDepth:Number = oActor.getLayer().getDepth();
var fTan:Number = Math.tan( fTargetPosition / fTargetDepth );
var fTargetPositionAdjusted:Number = fTan * fCameraDepth;
oCamera.x = fTargetPositionAdjusted;
But the camera just wanders off somewhere (no where near the movie clip)
Can anyone get their head around this?
| 0
| 0
| 0
| 0
| 1
| 0
|
I'm planning to develop program in Java which will provide diagnosis. The data set is divided into two parts one for training and the other for testing. My program should learn to classify from the training data (BTW which contain answer for 30 questions each in new column, each record in new line the last column will be diagnosis 0 or 1, in the testing part of data diagnosis column will be empty - data set contain about 1000 records) and then make predictions in testing part of data :/
I've never done anything similar so I'll appreciate any advice or information about solution to similar problem.
I was thinking about Java Machine Learning Library or Java Data Mining Package but I'm not sure if it's right direction... ? and I'm still not sure how to tackle this challenge...
Please advise.
All the best!
| 0
| 1
| 0
| 1
| 0
| 0
|
I needed an application for solving linear systems of equations (N up to 10), so I got different codes, and compile them, and they seem to work, but I get lots of problems with precision. I mean, the solvers are really very sensitive to small changes of the system.
So, could somebody recommend to me a reliable commandl ine application for this purpose? Or some useful open source code (and easy to compile)
Thanks
| 0
| 0
| 0
| 0
| 1
| 0
|
Suppose I want to match address records (or person names or whatever) against each other to merge records that are most likely referring to the same address. Basically, I guess I would like to calculate some kind of correlation between the text values and merge the records if this value is over a certain threshold.
Example:
"West Lawnmower Drive 54 A" is probably the same as "W. Lawn Mower Dr. 54A" but different from "East Lawnmower Drive 54 A".
How would you approach this problem? Would it be necessary to have some kind of context-based dictionary that knows, in the address case, that "W", "W." and "West" are the same? What about misspellings ("mover" instead of "mower" etc)?
I think this is a tricky one - perhaps there are some well-known algorithms out there?
| 0
| 1
| 0
| 0
| 0
| 0
|
Given a scenario where we have multiple lists of pairs of items, for example:
{12,13,14,23,24}
{14,15,25}
{16,17,25,26,36}
where 12 is a pair of items '1' and '2' (and thus 21 is equivalent to 12), we want to count the number of ways that we can choose pairs of items from each of the lists such that no single item is repeated. You must select one, and only one pair, from each list. The number of items in each list and the number of lists is arbitrary, but you can assume there are at least two lists with at least one pair of items per list. And the pairs are made from symbols from a finite alphabet, assume digits [1-9]. Also, a list can neither contain duplicate pairs {12,12} or {12,21} nor can it contain symmetric pairs {11}.
More specifically, in the example above, if we choose the pair of items 14 from the first list, then the only choice we have for the second list is 25 because 14 and 15 contain a '1'. And consequently, the only choice from the third list is 36 because 16 and 17 contain a '1', and 25 and 26 contain a '2'.
Does anyone know of an efficient way to count the total combinations of pairs of items without going through every permutation of choices and asking "is this a valid selection?", as the lists can each contain hundreds of pairs of items?
UPDATE
After spending some time with this, I realized that it is trivial to count the number of combinations when none of the lists share a distinct pair. However, as soon as a distinct pair is shared between two or more lists, the combinatorial formula does not apply.
As of now, I've been trying to figure out if there is a way (using combinatorial math and not brute force) to count the number of combinations in which every list has the same pairs of items. For example:
{12,23,34,45,67}
{12,23,34,45,67}
{12,23,34,45,67}
| 0
| 0
| 0
| 0
| 1
| 0
|
I need to work out if a massive integer (I mean 20 digits...) is prime.
I'm trying to use the brute-force method, but (of course) I need to use doubles to contain the original number. However, the modulo operator (%) is an integer operator - thus it is useless to me!
| 0
| 0
| 0
| 0
| 1
| 0
|
Thanks for looking at this. I apologize for this rather lengthy build-up but I thought it is needed to clarify things.
I have a chain of connected atoms, say a polymer which has rigid bonds and bond angles. With rigid bonds we get the condition that the distance between two immediate neighbours [eg. 2-3,3-4,etc.] is always fixed and the bond angles [defined using 3 atoms, eg. 1-2-3] are always maintained. We do have freedom to rotate around the torsion angles. The atoms are defined with respect to each previous atom by this length, angle and the torsion angle and that basically allows us to find the Cartesian coordinates by setting up a coordinate system. Now, if we want to align a pair of atoms which are not directly connected to the base atoms with respect to which the new orientations are supplied can we find a rotation matrix that can do the job?
For example, imagine that we have 10 atoms and we want to define a new set of internal coordinates between atoms 1,2 and 9,10. The locations in space of atoms 9 and 10 have been found using the internal coordinates specified by atoms 6, 7 and 8. [Distance 8-9, angle 7-8-9 and the torsion angle 6-7-8-9 and similarly for atom 10]
Now if we decide to reorient atoms 9 and 10 by defining a distance as 2-9 and the angle 1-2-9 and the dihedral angle 1-2-9-10, is there a way to find a rotation/transformation matrix that will perform this realignment without disturbing the geometry of the rest of the atoms [that is it will preserve the angle 7-8-9, distance 8-9 and dihedral 6-7-8-9].
Thanks a lot in advance for any advice.
| 0
| 0
| 0
| 0
| 1
| 0
|
What is the original source for the thesaurus data in Aiksaurus?
Is it possible to get data about antonyms for a word from Aiksaurus?
| 0
| 1
| 0
| 0
| 0
| 0
|
Is it standard across all languages for the following to yield the value 3?
Print(6 - 2 - 1)
In other words, are there any languages that will evaluate " 2 - 1 " before " 6 - 2 "?
I'd like to make this assumption so that I can quit instinctively inserting parentheses ((6 - 2) - 1). It leave me at risk of LISP nightmares.
Thanks
| 0
| 0
| 0
| 0
| 1
| 0
|
I have two waveforms which are linked by a numerical factor. I need to use optimal scaling (least squares) between the two waveforms to calculate this factor in Matlab. Unfortunately I have no idea how to do this. The two wave forms are seismic signals related by the velocity of the seismic waves, which I'm trying to calculate. Any ideas? need more info?
| 0
| 0
| 0
| 0
| 1
| 0
|
Does anyone know what math methods are implemnted by the hardware of the processor for .net? For example, I have an algorithm that makes a lot of use of atan. I can easily write a lookup table for this, but if math.net implements this using an fpu or other hardware extensions, it's not going to be worth it.
| 0
| 0
| 0
| 0
| 1
| 0
|
I'm having a problem trying to understand how does AIML pattern matching works.
What's the difference between _ and *? And how I should use them to get the best match?
I have this document only, but it lacks some good examples.
| 0
| 1
| 0
| 0
| 0
| 0
|
How to find the maximum of two explicit values in MySQL? Something like MAXIMUM(1, @foo).
There are group functions like MAX, MIN, AVG, etc that take column name as an argument and work with result sets. Is it possible to convert two explicit values to a result set and use those functions? Some other ways?
P.S.: I need a max function for one of my stored procedures.
| 0
| 0
| 0
| 0
| 1
| 0
|
I recently read this question regarding information gain and entropy. I think I have a semi-decent grasp on the main idea, but I'm curious as what to do with situations such as follows:
If we have a bag of 7 coins, 1 of which is heavier than the others, and 1 of which is lighter than the others, and we know the heavier coin + the lighter coin is the same as 2 normal coins, what is the information gain associated with picking two random coins and weighing them against each other?
Our goal here is to identify the two odd coins. I've been thinking this problem over for a while, and can't frame it correctly in a decision tree, or any other way for that matter. Any help?
EDIT: I understand the formula for entropy and the formula for information gain. What I don't understand is how to frame this problem in a decision tree format.
EDIT 2: Here is where I'm at so far:
Assuming we pick two coins and they both end up weighing the same, we can assume our new chances of picking H+L come out to 1/5 * 1/4 = 1/20 , easy enough.
Assuming we pick two coins and the left side is heavier. There are three different cases where this can occur:
HM: Which gives us 1/2 chance of picking H and a 1/4 chance of picking L: 1/8
HL: 1/2 chance of picking high, 1/1 chance of picking low: 1/1
ML: 1/2 chance of picking low, 1/4 chance of picking high: 1/8
However, the odds of us picking HM are 1/7 * 5/6 which is 5/42
The odds of us picking HL are 1/7 * 1/6 which is 1/42
And the odds of us picking ML are 1/7 * 5/6 which is 5/42
If we weight the overall probabilities with these odds, we are given:
(1/8) * (5/42) + (1/1) * (1/42) + (1/8) * (5/42) = 3/56.
The same holds true for option B.
option A = 3/56
option B = 3/56
option C = 1/20
However, option C should be weighted heavier because there is a 5/7 * 4/6 chance to pick two mediums. So I'm assuming from here I weight THOSE odds.
I am pretty sure I've messed up somewhere along the way, but I think I'm on the right path!
EDIT 3: More stuff.
Assuming the scale is unbalanced, the odds are (10/11) that only one of the coins is the H or L coin, and (1/11) that both coins are H/L
Therefore we can conclude:
(10 / 11) * (1/2 * 1/5) and
(1 / 11) * (1/2)
EDIT 4: Going to go ahead and say that it is a total 4/42 increase.
| 0
| 1
| 0
| 0
| 0
| 0
|
I am plotting flight paths between Airports that I have Latitude and Longitude values for onto a Google Map (v3 of the API).
However unlike v2, v3 does not seem to have an option to put a Polyline on the map between two points and have it display as the great-circle flightpath.
So what I was thinking, was that it might be possible to calculate a number of points along a great-circle path between two Latitude/Longitude points.
I'm terrible with maths and I can hardly understand or comprehend how the great-circle calculations work.
Does anyone know of a C# library or code snippit that can take two latitude and longitude points and calculate a number of points along the great-circle path between them ?
| 0
| 0
| 0
| 0
| 1
| 0
|
I know the end points of a line segment and the distance/size of the perpendicular end caps I'd like to create but I need to calcuate the end points of the perpendicular line. I've been banging my head against the wall using either 45-45-90 triangles and dot products but I just can't seem to make it come together.
I know the points in blue and the distance to the points in red, I need to find the points in red.
Before marking as duplicate, I tried the answer posted in this question but it resulted in end caps which were always vertical.
http://rauros.net/files/caps.png http://rauros.net/files/caps.png
| 0
| 0
| 0
| 0
| 1
| 0
|
For a linguistics course we implemented Part of Speech (POS) tagging using a hidden markov model, where the hidden variables were the parts of speech. We trained the system on some tagged data, and then tested it and compared our results with the gold data.
Would it have been possible to train the HMM without the tagged training set?
| 0
| 1
| 0
| 1
| 0
| 0
|
I'm using a shopping cart script from a tutorial I came across a while ago, and I need to modify it to calculate sales tax for my state (Pennsylvania). I want it to extract the state, compare it to either Pennsylvania or PA incase someone writes the state shorthand and then multiply the subtotal (for the items.. before shipping is added) by the sales tax for this state and add that to the subtotal. How should I go about doing this? Here is the script that does the calculation for grand total.
<?php
require_once 'config.php';
/*********************************************************
* CHECKOUT FUNCTIONS
*********************************************************/
function saveOrder()
{
$orderId = 0;
$shippingCost = 5;
$requiredField = array('hidShippingFirstName', 'hidShippingLastName', 'hidShippingAddress1', 'hidShippingCity', 'hidShippingPostalCode',
'hidPaymentFirstName', 'hidPaymentLastName', 'hidPaymentAddress1', 'hidPaymentCity', 'hidPaymentPostalCode');
if (checkRequiredPost($requiredField)) {
extract($_POST);
// make sure the first character in the
// customer and city name are properly upper cased
$hidShippingFirstName = ucwords($hidShippingFirstName);
$hidShippingLastName = ucwords($hidShippingLastName);
$hidPaymentFirstName = ucwords($hidPaymentFirstName);
$hidPaymentLastName = ucwords($hidPaymentLastName);
$hidShippingCity = ucwords($hidShippingCity);
$hidPaymentCity = ucwords($hidPaymentCity);
$cartContent = getCartContent();
$numItem = count($cartContent);
// save order & get order id
$sql = "INSERT INTO tbl_order(od_date, od_last_update, od_shipping_first_name, od_shipping_last_name, od_shipping_address1,
od_shipping_address2, od_shipping_phone, od_shipping_state, od_shipping_city, od_shipping_postal_code, od_shipping_cost,
od_payment_first_name, od_payment_last_name, od_payment_address1, od_payment_address2,
od_payment_phone, od_payment_state, od_payment_city, od_payment_postal_code)
VALUES (NOW(), NOW(), '$hidShippingFirstName', '$hidShippingLastName', '$hidShippingAddress1',
'$hidShippingAddress2', '$hidShippingPhone', '$hidShippingState', '$hidShippingCity', '$hidShippingPostalCode', '$shippingCost',
'$hidPaymentFirstName', '$hidPaymentLastName', '$hidPaymentAddress1',
'$hidPaymentAddress2', '$hidPaymentPhone', '$hidPaymentState', '$hidPaymentCity', '$hidPaymentPostalCode')";
$result = dbQuery($sql);
// get the order id
$orderId = dbInsertId();
if ($orderId) {
// save order items
for ($i = 0; $i < $numItem; $i++) {
$sql = "INSERT INTO tbl_order_item(od_id, pd_id, od_qty)
VALUES ($orderId, {$cartContent[$i]['pd_id']}, {$cartContent[$i]['ct_qty']})";
$result = dbQuery($sql);
}
// update product stock
for ($i = 0; $i < $numItem; $i++) {
$sql = "UPDATE tbl_product
SET pd_qty = pd_qty - {$cartContent[$i]['ct_qty']}
WHERE pd_id = {$cartContent[$i]['pd_id']}";
$result = dbQuery($sql);
}
// then remove the ordered items from cart
for ($i = 0; $i < $numItem; $i++) {
$sql = "DELETE FROM tbl_cart
WHERE ct_id = {$cartContent[$i]['ct_id']}";
$result = dbQuery($sql);
}
}
}
return $orderId;
}
/*
Get order total amount ( total purchase + shipping cost )
*/
function getOrderAmount($orderId)
{
$orderAmount = 0;
$sql = "SELECT SUM(pd_price * od_qty)
FROM tbl_order_item oi, tbl_product p
WHERE oi.pd_id = p.pd_id and oi.od_id = $orderId
UNION
SELECT od_shipping_cost
FROM tbl_order
WHERE od_id = $orderId";
$result = dbQuery($sql);
if (dbNumRows($result) == 2) {
$row = dbFetchRow($result);
$totalPurchase = $row[0];
$row = dbFetchRow($result);
$shippingCost = $row[0];
$orderAmount = $totalPurchase + $shippingCost;
}
return $orderAmount;
}
?>
| 0
| 0
| 0
| 0
| 1
| 0
|
I'm trying to write some code that will do "fuzzy hashing". That is: I want several inputs to hash to the same output so that I can do searches etc quickly and easily. If A hashes to 1 and C hashes to 1, it will be trivial for me to find out that A is equivalent to C.
Designing such a hash function seems hard, so I was wondering if anyone had experience with CMPH or GPERF and could walk me through creating a function that would result in this hash function.
Thanks in advance!
Stefan
@Ben
In this case, matrixes of booleans, but I can easily pack them into 64 bit integers. Rotations, translations, etc in the input are irrelevant and need to be weeded out. Thus:
000
111
000
Is equivalent to
111
000
000
and
001
001
001
(simplification)
@Kinopiko
My best bet thus far would be to determine some sort of "canonical" representation and design code that terminates when the transformations reach such a representation (say...packing all the bits at the bottom). Yet this is slow and I'm looking for a better way. My data set is large.
@Jason
These two would not hash to the same value.
000
010
000
000
011
000
| 0
| 0
| 0
| 0
| 1
| 0
|
What is the best mechanism for handling large scale structures and scenes?
Examples being a continent with scale cities and geography, or infinity universe style planetary transitions.
| 0
| 0
| 0
| 0
| 1
| 0
|
Edit: Since it appears nobody is reading the original question this links to, let me bring in a synopsis of it here.
The original problem, as asked by someone else, was that, given a large number of values, where the sum would exceed what a data type of Double would hold, how can one calculate the average of those values.
There was several answers that said to calculate in sets, like taking 50 and 50 numbers, and calculating the average inside those sets, and then finally take the average of all those sets and combine those to get the final average value.
My position was that unless you can guarantee that all those values can be split into a number of equally sized sets, you cannot use this approach. Someone dared me to ask the question here, in order to provide the answer, so here it is.
Basically, given an arbitrary number of values, where:
I know the number of values beforehand (but again, how would your answer change if you didn't?`)
I cannot gather up all the numbers, nor can I sum them (the sum will be too big for a normal data type in your programming language)
how can I calculate the average?
The rest of the question here outlines how, and the problems with, the approach to split into equally sized sets, but I'd really just like to know how you can do it.
Note that I know perfectly well enough math to know that in math theory terms, calculating the sum of A[1..N]/N will give me the average, let's assume that there are reasons that it isn't just as simple, and I need to split up the workload, and that the number of values isn't necessarily going to be divisable by 3, 7, 50, 1000 or whatever.
In other words, the solution I'm after will have to be general.
From this question:
What is a good solution for calculating an average where the sum of all values exceeds a double’s limits?
my position was that splitting the workload up into sets is no good, unless you can ensure that the size of those sets are equal.
Edit: The original question was about the upper limit that a particular data type could hold, and since he was summing up a lot of numbers (count that was given as example was 10^9), the data type could not hold the sum. Since this was a problem in the original solution, I'm assuming (and this is a prerequisite for my question, sorry for missing that) that the numbers are too big to give any meaningful answers.
So, dividing by the total number of values directly is out. The original reason for why a normal SUM/COUNT solution was out was that SUM would overflow, but let's assume, for this question that SET-SET/SET-SIZE will underflow, or whatever.
The important part is that I cannot simply sum, I cannot simply divide by the number of total values. If I cannot do that, will my approach work, or not, and what can I do to fix it?
Let me outline the problem.
Let's assume you're going to calculate the average of the numbers 1 through 6, but you cannot (for whatever reason) do so by summing the numbers, counting the numbers, and then dividing the sum by the count. In other words, you cannot simply do (1+2+3+4+5+6)/6.
In other words, SUM(1..6)/COUNT(1..6) is out. We're not considering NULL's (as in database NULL's) here.
Several of the answers to that question alluded to being able to split the numbers being averaged into sets, say 3 or 50 or 1000 numbers, then calculating some number for that, and then finally combining those values to get the final average.
My position is that this is not possible in the general case, since this will make some numbers, the ones appearing in the final set, more or less valuable than all the ones in the previous sets, unless you can split all the numbers into equally sized sets.
For instance, to calculate the average of 1-6, you can split it up into sets of 3 numbers like this:
/ 1 2 3 \ / 4 5 6 \
| - + - + - | + | - + - + - |
\ 3 3 3 / \ 3 3 3 / <-- 3 because 3 numbers in the set
---------- -----------
2 2 <-- 2 because 2 equally sized groups
Which gives you this:
2 5
- + - = 3.5
2 2
(note: (1+2+3+4+5+6)/6 = 3.5, so this is correct here)
However, my point is that once the number of values cannot be split into a number of equally sized sets, this method falls apart. For instance, what about the sequence 1-7, which contains a prime number of values.
Can a similar approach, that won't sum all the values, and count all the values, in one go, work?
So, is there such an approach? How do I calculate the average of an arbitrary number of values in which the following holds true:
I cannot do a normal sum/count approach, for whatever reason
I know the number of values beforehand (what if I don't, will that change the answer?)
| 0
| 0
| 0
| 0
| 1
| 0
|
I'm going to program a fancy (animated) about-box for an app I'm working on. Since this is where programmers are often allowed to shine and play with code, I'm eager to find out what kind of cool algorithms the community has implemented.
The algorithms can be animated fractals, sine blobs, flames, smoke, particle systems etc.
However, a few natural constraints come to mind: It should be possible to implement the algorithm in virtually any language. Thus advanced directx code or XNA code that utilizes libraries that aren't accessible in most languages should not be posted. 3D is most welcome, but it shouldn't rely on lots of extra installs.
If you could post an image along with your code effect, it would be awesome.
Here's an example of a cool about box with an animated 3D figure and some animated sine blobs on the titlebar:
And here's an image of the about box used in Winamp, complete with 3D animations:
| 0
| 0
| 0
| 0
| 1
| 0
|
I'm reading about an algorithm (it's a path-finding algorithm based on A*), and it contains a mathematical symbol I'm unfamiliar with: ∀
Here is the context:
v(s) ≥ g(s) = mins'∈pred(s)(v(s') + c(s', s)) ∀s ≠ sstart
Can someone explain the meaning of ∀?
| 0
| 0
| 0
| 0
| 1
| 0
|
I know the start and end points on a line segment. For this example say that the line segment has a distance of 5. Now I want to know the point that has a distance of three away from the end point. Any idea how to do this with math?
Start Point (0,0)
End Point (0,5)
Point I want to find (0,2)
| 0
| 0
| 0
| 0
| 1
| 0
|
I'm trying to calculate the monthly payment for the following scenario:
$5,000 is borrowed for 3 years at 8.00% compounded monthly with $1,000 due at the end of the term.
/*
From Math.pas
function Payment(Rate: Extended;
NPeriods: Integer;
const PresentValue: Extended;
const FutureValue: Extended;
PaymentTime: TPaymentTime): Extended;
*/
var
Pmt : Extended;
begin
Pmt := Payment(0.08/12,36,5000,1000,ptEndOfPeriod);
Edit1.Text := FloatToStr(Pmt);
end
Result = -181.351526101918
The result is correct except it is negative.
Why does the result of the Payment function return a negative number?
| 0
| 0
| 0
| 0
| 1
| 0
|
why does model.diff return 18446744073709551615 in template, when model is like this and model.pos is 0 and model.neg is 1?:
class Kaart(models.Model):
neg = models.PositiveIntegerField(default=0)
pos = models.PositiveIntegerField(default=0)
def diff(self):
return self.pos - self.neg
| 0
| 0
| 0
| 0
| 1
| 0
|
I have a method that draws a line between two points. This works pretty well, but now I want to make this line into a rectangle.
How can I get the points on the left and right side of each of the line points to make it into a rectangle that I can draw?
It is almost as though I need to somehow figure out how to get perpendicular lines programatically....
| 0
| 0
| 0
| 0
| 1
| 0
|
I want to be able to let users enter dates (including recurring dates) using natural language (eg "next friday", "every weekday"). Much like the examples at http://todoist.com/Help/timeInsert
I found this post, but it's a bit old and offered only one solution that I'm not entirely content with. I thought I'd resurrect this question and see: are there any other .NET libraries out there that do this kind of date parsing?
| 0
| 1
| 0
| 0
| 0
| 0
|
If tan(x) = y and atan(y) = x why Math.Atan(Math.Tan(x)) != x?
I´m trying to calculate x in something like:
tan(2/x +3) = 5
so
atan(tan(2/x + 3) = atan(5)
and so on... but I´ve tried this:
double d = Math.Atan(Math.Tan(10));
and d != 10. Why?
| 0
| 0
| 0
| 0
| 1
| 0
|
How would I go about generating a unique receipt number in the following range:
GA00000-GZ99999? I am not allowed to use the 'I' and 'O' letters so GI00000-GI99999 & GO00000-GO99999 would be excluded.
Ideally, I'd like to create this in T-SQL but can also do it in VB.Net. This number will be stored in SQL and I can access it prior to generating the next one. They do not have to be sequential.
Thanks.
| 0
| 0
| 0
| 0
| 1
| 0
|
I have downloaded AraMorph 1.2.1 Perl version from SourceForge, but I do not know how to use it. Could someone explain to me how can I get it to work?
| 0
| 1
| 0
| 0
| 0
| 0
|
I'm trying to check spelling accuracy of text samples using the Stanford NLP. It's just a metric of the text, not a filter or anything, so if it's off by a bit it's fine, as long as the error is uniform.
My first idea was to check if the word is known by the lexicon:
private static LexicalizedParser lp = new LexicalizedParser("englishPCFG.ser.gz");
@Analyze(weight=25, name="Spelling")
public double spelling() {
int result = 0;
for (List<? extends HasWord> list : sentences) {
for (HasWord w : list) {
if (! lp.getLexicon().isKnown(w.word())) {
System.out.format("misspelled: %s
", w.word());
result++;
}
}
}
return result / sentences.size();
}
However, this produces quite a lot of false positives:
misspelled: Sincerity
misspelled: Sisyphus
misspelled: Sisyphus
misspelled: fidelity
misspelled: negates
misspelled: gods
misspelled: henceforth
misspelled: atom
misspelled: flake
misspelled: Sisyphus
misspelled: Camus
misspelled: foandf
misspelled: foandf
misspelled: babby
misspelled: formd
misspelled: gurl
misspelled: pregnent
misspelled: babby
misspelled: formd
misspelled: gurl
misspelled: pregnent
misspelled: Camus
misspelled: Sincerity
misspelled: Sisyphus
misspelled: Sisyphus
misspelled: fidelity
misspelled: negates
misspelled: gods
misspelled: henceforth
misspelled: atom
misspelled: flake
misspelled: Sisyphus
Any ideas on how to do this better?
| 0
| 1
| 0
| 0
| 0
| 0
|
I am working on a math expression parser using regular expressions and I am trying to add support for parentheses.
My parser works like this:
function parse_expression(expression){
Find parenthetical expressions
Loop through parenthetical expressions, call parse_expression() on all of them
Replace parenthetical expression with value of expression
Find value of expression
Return value
}
Because it it recursive, I need to find only the outmost parenthetical expressions. For example if I was parsing the string "(5 + (4 + (3 / 4) + (3 * 2) + 2)) + (1 + 2)", I want to find the expressions "5 + (4 + (3 / 4) + (3 * 2) + 2)" and "1 + 2". How do you do this with Regular Expressions?
The regular expression I have now ( "\(([^\)]+)\)" ) would return just "5 + ( 4 + ( 3 * 2", it doesn't get the full first expression and it gets none of the second.
Any ideas?
Thanks,
Kyle
| 0
| 0
| 0
| 0
| 1
| 0
|
I am currently studying Fiege-Fiat Shamir and am stuck on quadratic residues. I understand the concept i think but im not sure how to calculate them for example how would i calculate
v | x^2 = v mod 21 | x =?
___________________________________
1 x^2 = 1 mod 21 1, 8, 13, 20
4 x^2 = 4 mod 21 2, 5, 16
7 x^2 = 7 mod 21 7, 14
9 x^2 = 9 mod 21 3, 18
15 x^2 = 15 mod 21 6, 15
16 x^2 = 16 mod 21 4, 10, 11, 17
18 x^2 = 18 mod 21 9, 12
I do not understand how the column x=? is calculated. Can anyone help me maybe explain the method?
| 0
| 0
| 0
| 0
| 1
| 0
|
as a homework assignment, we're writing a software rasterizer. I've noticed my z buffering is not working as well as it should, so I'm trying to debug it by outputting it to the screen. (Black is near, white is far away).
However, I'm getting peculiar values for the z per vertex. This is what I use to transform the points:
float Camera::GetZToPoint(Vec3 a_Point)
{
Vec3 camera_new = (m_MatRotation * a_Point) - m_Position;
return (HALFSCREEN / tanf(_RadToDeg(60.f * 0.5f)) / camera_new.z);
}
m_MatRotation is a 3x3 matrix. Multiplying it by a vector returns a transformed vector.
I get maximum and minimum values between 0 and x, where x is a seemingly random number.
Am I doing this transformation right? If so, how can I normalize my Z values so it lies between two set points?
Thanks in advance.
| 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.