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've stumbled on this algorithm recently and am having difficulty explaining it to myself. The algorithm solves the assignment problem in O(n4) (and apparently can be improved to O(n3)) but I can't see why.
Intuitively I can see that the algorithm would tend to find good to optimal solutions but I can't see a proof! All the proofs I have seen so far contain notation I am unfamiliar with. My question is: can anyone explain it rigorously but simply?
I understand already that the problem can be transferred to a matrix of values where exactly one value in each row and each column must be selected. The minimum value possible (from the selected elements) and the selection that produces that is what the algorithm computes. Obviously finding the selection also finds the minimum.
The part I'm struggling on, notation-wise, is here. The third paragraph down in the Settings section which begins "Let us call a function"...
| 0
| 0
| 0
| 0
| 1
| 0
|
One of my interests in AI focuses not so much on data but more on biologic computing. This includes neural networks, mapping the brain, cellular-automata, virtual life and environments.
Described below is an exciting project that includes develop a virtual environment for bots to evolve in.
"Polyworld is a cross-platform (Linux, Mac OS X) program written by Larry Yaeger to evolve Artificial Intelligence through natural selection and evolutionary algorithms."
http://en.wikipedia.org/wiki/Polyworld "
Polyworld is a promising project for studying virtual life but it still is far from creating an "intelligent autonomous" agent.
Here is my question, in theory, what parameters would you use create an AI environment? Possibly a brain environment? Possibly multiple self contained life organisms that have their own "brain" or life structures.
I would like a create a spin on the game of life simulation. What if you have a 64x64 game of life grid. But instead of one grid, you might have N number of grids. The N number of grids are your "life force" If all of the game of life entities die in a particular grid then that entire grid dies. A group of "grids" makes up a life form.
I don't have an immediate goal. First, I want to simulate an environment and visualize what is going on in the environment with OpenGL and see if there are any interesting properties to the environment. I then want to add "scarce resources" and see if the AI environment can manage resources adequately.
| 0
| 1
| 0
| 0
| 0
| 0
|
Does anybody know of an English verb inflector that I can use on a lexicon of verbs (in present-participle) that can give me other inflected forms of the verbs?
For example:
I give it I get
========= ======================================
run ran, running, runs
sing sang, singing, sings
play played, playing, plays
| 0
| 1
| 0
| 0
| 0
| 0
|
how do news outlets like google news automatically classify and rank documents about emerging topics, like "obama's 2011 budget"?
i've got a pile of articles tagged with baseball data like player names and relevance to the article (thanks, opencalais), and would love to create a google news-style interface that ranks and displays new posts as they come in, especially emerging topics. i suppose that a naive bayes classifier could be trained w/ some static categories, but this doesn't really allow for tracking trends like "this player was just traded to this team, these other players were also involved."
| 0
| 1
| 0
| 0
| 0
| 0
|
Say I have an algorithm which operates on an input of size n and I know that the time it takes for n is twice the time it takes for n-1. I can observe in this simple case (assuming it takes, say, 1 second for n = 0) that the algorithm takes 2n seconds.
Is there a general method for converting between recursively-defined definitions to the more familiar direct type of expression?
| 0
| 0
| 0
| 0
| 1
| 0
|
I'm looking at the standard definition of the assignment problem as defined here
My question is to do with the two constraints (latex notation follows):
\sum_{j=1}^n(x_{ij}) = 1 for all i = 1, ... , n
\sum_{i=1}^n(x_{ij}) = 1 for all j = 1, ... , n
Specifically, why the second constraint required? Doesn't the first already cover all pairs of x_{ij}?
| 0
| 0
| 0
| 0
| 1
| 0
|
Let me know if this is mathoverflow material, and I'll wend my way over there. I'm hoping someone will recognise this and point me in the right direction...
I'm trying to map out related nodes. I've figured out how to calculate the minimum distances between all the points, and now I need to know how to turn those into actual co-ordinates in 2D space.
So, given a point Pn (where n > 1), a set of points [P1..Pn-1], and a set of distances [d1..dn-1] where each d represents the minimum distance between Pn and d's respective point, how do I calculate the best valid co-ordinate set [x,y] for Pn?
When I say 'best' valid co-ordinate set, I mean the set that brings Pn closest to all the other points without violating any of the constraints.
My first thought was to stick P1 at [0,0], P2 at [0,d] (d1 for P2) and then for P3 I would put it at [0,y] where y is the minimum distance that P3 has to be at to satisfy its d1 and d2 and then move it in a circle around P2 at a radius of d2 for as long as it still satisfies d1.
That would have to be repeated for all points, which sounds like it would take ages.
Does this problem ring any bells with anyone? I'm not sure what formula or algorithms I'm looking for.
Update
I hadn't thought about what 'closest' means. I knew what I meant when I wrote it, but I hadn't thought about calculating it!
Minimum sum of squares sounds like it will do the job.
| 0
| 0
| 0
| 0
| 1
| 0
|
There are two views:
viewA and viewB. Both are rotated.
The coordinate system for rotation is weird: It goes from 0 to 179,999999 or -179,99999 degrees. So essentially 179,99999 and -179,99999 are very close together!
I want to calculate how much degrees or radians are between these rotations.
For example:
viewA is rotated at 20 degrees
viewB is rotated at 30 degrees
I could just do: rotationB - rotationA = 10.
But the problem with this formula:
viewA is rotated at 179 degrees
viewB is rotated at -179 degrees
that would go wrong: rotationB - rotationA = -179 - 179 = -358
358 is plain wrong, because they are very close together in reality. So one thing I could do maybe is to check if the absolute result value is bigger than 180, and if so, calculate it the other way around to get the short true delta. But I feel this is plain wrong and bad, because of possible floating point errors and unprecision. So if two views are rotated essentially equally at 179,99999999999 degrees I might get a weird 180 or a 0 if I am lucky.
Maybe there's a genius-style math formular with PI, sine or other useful stuff to get around this problem?
| 0
| 0
| 0
| 0
| 1
| 0
|
I have a function that will take a range of values, which need to be normalized to the range [-1, 1]. MathHelper.Clamp() just takes values that are outside the range and sets them to be whichever bound it exceeds. Does XNA or C# have anything that does what I'm looking for? (I'm looking through the documentation but can't find it.)
This is the get mouse movement. The values are the difference in mouse coordinates between one tick and the next. I'm not sure what the max value for that is.
This function will take values one at a time - so there is no iterating over all values to scale them all or see what the min and max is.
This is what I currently have:
// max - min cannot == 0
private float normalizeToRange(float value, float min, float max) {
return (2.0f * (value - min) / (max - min)) -1.0f;
}
| 0
| 0
| 0
| 0
| 1
| 0
|
Matrices and Euler angles can suffer from Gimbal lock but what are some other arguments for using one over the other?
What do you think DirectX favors?
What do you use in daily C++/C/DirectX programming?
| 0
| 0
| 0
| 0
| 1
| 0
|
I'm playing with writing a MUD/text adventure (please don't laugh) in Ruby. Can anyone give me any pointers towards an elegant, oop-based solution to parsing input text?
We're talking about nothing more complex than "put wand on table", here. But everything needs to be soft; I want to extend the command set painlessly, later.
My current thoughts, slightly simplified:
Each item class (box, table, room, player) knows how to recognise a command that 'belongs' to it.
The game class understands a sort of a domain-specific language involving actions such as "move object X inside object Y", "show description of object X", etc.
The game class asks each item in the room if it recognises the input command. First to say yes wins.
It then passes control to a method in the item class that handles the command. This method rephrases the command in the DSL, passes it back to the game object to make it happen.
There must be well-worn, elegant ways of doing this stuff. Can't seem to google anything, though.
| 0
| 1
| 0
| 0
| 0
| 0
|
How can I calculate a fixed payment amount for a loan term that has two different interest rates based on how long the loan has been open?
| 0
| 0
| 0
| 0
| 1
| 0
|
For large n (see below for how to determine what's large enough), it's safe to treat, by the central limit theorem, the distribution of the sample mean as normal (gaussian) but I'd like a procedure that gives a confidence interval for any n. The way to do that is to use a Student T distribution with n-1 degrees of freedom.
So the question is, given a stream of data points that you collect or encounter one at a time, how do you compute a c (eg, c=.95) confidence interval on the mean of the data points (without storing all of the previously encountered data)?
Another way to ask this is: How do you keep track of the first and second moments for a stream of data without storing the whole stream?
BONUS QUESTION: Can you keep track of higher moments without storing the whole stream?
| 0
| 0
| 0
| 0
| 1
| 0
|
I've been doing some research for a mathematical Android related project I'd like to embark upon and I stumbled across for the first time MathML.
Does anyone know of any Java libraries which can do any (preferably all) of the following things?
Parse MathML
Output MathML by parsing standard mathematical notation
Render MathML (particularly important)
Do any other cool maths-ey things (like re-arrange equations in terms of different things)
Number 3 is probably the most important, and number 4 the least.
Thanks in advance.
| 0
| 0
| 0
| 0
| 1
| 0
|
Possible Duplicate:
how to perform bitwise operation on floating point numbers
Hello, everyone!
Background:
I know that it is possible to apply bitwise operation on graphics (for example XOR). I also know, that in graphic programs, graphic data is often stored in floating point data types (to be able for example to "multiply" the data with 1.05). So it must be possible to perform bitwise operations on floating point data, right?
I need to be able to perform bitwise operations on floating point data. I do not want to cast the data to long, bitwise manipulate it, and cast back to float.
I assume, there exist a mathematical way to achieve this, which is more elegant (?) and/or faster (?).
I've seen some answers but they could not help, including this one.
EDIT:
That other question involves void-pointer casting, which would rely on deeper-level data representation. So it's not such an "exact duplicate".
| 0
| 0
| 0
| 0
| 1
| 0
|
I want to display in a HTML page some datas with errors, for example:
(value, error) -> string
(123, 12) -> (12 +- 1) x 10^1
(4234.3, 2) -> (4234 +- 2)
(0.02312, 0.003) -> (23 +- 3) x 10^-3
I've produced this:
from math import log10
def format_value_error(value,error):
E = int(log10(abs(error)))
val = float(value) / 10**E
err = float(error) / 10**E
return "(%f +- %f) x 10^%d" % (val, err, E)
but I've some difficulties with rounding. Are there some libraries with this functionality?
| 0
| 0
| 0
| 0
| 1
| 0
|
I know the coordinates of A, B and C.. I also know of a vector V originating from C..
I know that the vector intersects A and B, I just don't know how to find i.
Can anyone explain the steps involved in solving this problem?
Thanks alot.
http://img34.imageshack.us/img34/941/triangleprob.png
| 0
| 0
| 0
| 0
| 1
| 0
|
I was wondering if you creative minds out there could think of some situations or applications in the web environment where Neural Networks would be suitable or an interesting spin.
Edit: Some great ideas here. I was thinking more web centric. Maybe bot detectors or AI in games.
| 0
| 1
| 0
| 0
| 0
| 0
|
I'm looking for a pure Python module that implements a matrix class where the underlying matrix operations are computed in modulo 2 arithmetic as in
(x+y)%2
I need to do a lot of basic matrix manipulations ( transpose, multiplication, etc. ).
Any help appreciated.
Thanks in advance
| 0
| 0
| 0
| 0
| 1
| 0
|
In MATLAB I have calculated the Fundamental matrix (of two images) using the normalized Eight point algorithm. From that I need to triangulate the corresponding image points in 3D space. From what I understand, to do this I would need the rotation and translation of the image's cameras. The easiest way of course would be calibrate the cameras first then take the images, but this is too constricting for my application as it would require this extra step.
So that leaves me with auto (self) camera calibration. I see mention of bundle adjustment, however in An Invitation to 3D Vision it seems it requires an initial translation and rotation, which makes me think that a calibrated camera is needed or my understanding is falling short.
So my question is how can I automatically extract the rotation/translation so I can reprojected/triangulate the image points into 3D space. Any MATLAB code or pseudocode would be fantastic.
| 0
| 0
| 0
| 0
| 1
| 0
|
I have a variable that is...
$whatever = "5865/100";
This is a text variable.
I want it to calculate 5865/100 , so that I can add it to other numbers and do a calculation.
Number_format doesn't work, as it just returns "5,865". Whereas I want it to return 58.65
I could do...
$explode=explode("/",$whatever);
if(count($explode)=="2") {
$whatever = $explode[0]/$explode[1];
}
But it seems rather messy. Is there a simpler way?
| 0
| 0
| 0
| 0
| 1
| 0
|
I'm trying to build a calculator in Flex / actionscript 3 but have some weird results using the class Math :
trace(1.4 - .4); //should be 1 but it is 0.9999999999999999
trace(1.5 - .5); //should be 1 and it is 1
trace(1.444 - .444); //should be 1 and it is 1
trace(1.555 - .555); //should be 1 but it is 0.9999999999999999
I know there are some issues with floating point numbers, but as you can see, it should at least fail for all of my examples, am I right?
How the problem is solved in other calculators and how should I proceed in order to build a usable calculator in Actionscript 3 please?
Thank you in advance,
Adnan
| 0
| 0
| 0
| 0
| 1
| 0
|
I'd like to have a simple & lightweight library/application in PHP/Python/C/C++ library/application to match/correct/give suggestions to input. Example in/out:
Input: Webdevelopment ==> Output: Web Development
Input: Web developmen ==> Output: Web Development
Input: Web develop ==> Output: Web Development
Given there is database of correct words and phrases, I just need the library to match/guess phrases. Please suggest if you know any.
| 0
| 1
| 0
| 0
| 0
| 0
|
For an assignment I have to make a multi-agent system (very open ended, but a short project), something like predator/prey or traffic simulation? It will be written in Jason/Agent speak. I am at a loss for ideas as to what to actually implement (what is feasible?), as it can be anything, the more bizarre the better!
| 0
| 1
| 0
| 0
| 0
| 0
|
I can't find a good reference about color-modifying functions (such as contrast, brightness, gamma, ...).
(Is there a more exact term for what I mean?)
Would appreciate a tutorial with example pictures and implementation algorithms.
Thank you!
EDIT:
Platform and language is not so important. I'm interested in pure mathematic algorithms, so please don't point me to graphic APIs ;)
| 0
| 0
| 0
| 0
| 1
| 0
|
Why this class uses 48 bit seed in its linear congruence formula?
I would have expected 32 or 64...
I know it takes higher order bits when asked for 32 bit values. But why only 16 more additional bits? Was it a "random" choice?
| 0
| 0
| 0
| 0
| 1
| 0
|
Prob Statement:
'N' equal radii circles are plotted on a graph from (-)infinity to (+)infinity.Find the total area of intersection I.e all the area on the graph which is covered by two or more circles.
| 0
| 0
| 0
| 0
| 1
| 0
|
Alright, I've cooked up some code to reverse hex characters around as part of a fun exercise I made up.
Here is what I have at the moment:
#include <stdio.h>
int main() {
char a,b,c;
while (1) {
c = getchar();
if (!feof(stdin)) {
a = c % 16;
b = (c - a) / 16;
c = (a*16) + b;
putchar(c);
}else{break;}
}
return 0;
}
It works well for most values. For example, 0xA0 becomes 0x0A etc...
However, it's not playing well with values beginning with 'F'.
0xF1 becomes 0x10
0xFF becomes 0xF0
etc...
Can somebody point me into the right direction?
| 0
| 0
| 0
| 0
| 1
| 0
|
I was learning about using the command line version of latex today, and I was experimenting with outputting .tex to .dvi, and then .dvi to .png.
The problem is, I have a simple .tex document which contains some math. The goal is to eventually produce a png form of the equation. But when I run:
$ latex -output-format=dvi test.tex
$ dvipng test.dvi
I get test1.png that is shaped like a regular letter-sized page. I only want an image that is as big as the equation needs to be. I'm sure I'm missing something obvious, but I can't figure it out!
Is there a command line option for either latex or dvipng to specify that the output file should only be set on a page as large as needed to render the equation?
Here's my example test.tex:
\documentclass{article}
\begin{document}
The solution to $\sqrt{x} = 5$ is $x=25$.
\end{document}
Thanks!
| 0
| 0
| 0
| 0
| 1
| 0
|
I have a degree in computer science and I have taken the following math courses.
Calculus I
Calculus II
Discrete Mathematics and Number Theory
Linear Algebra
Probability
Logic
Automata Theory
What other courses should I take in order to prepare for studying wavelets, with a focus of implementing wavelet transforms?
EDIT:
Looks like this was closed for not being "programming related". That is wrong!
Wavelet transform is a very common image processing technique, it's used in H.264 and JPEG2000. Is image processing beyond the scope of StackOverflow?
| 0
| 1
| 0
| 0
| 1
| 0
|
I'm working on a game where on each update of the game loop, the AI is run. During this update, I have the chance to turn the AI-controlled entity and/or make it accelerate in the direction it is facing. I want it to reach a final location (within reasonable range) and at that location have a specific velocity and direction (again it doesn't need to be exact) That is, given a current:
P0(x, y) = Current position vector
V0(x, y) = Current velocity vector (units/second)
θ0 = Current direction (radians)
τmax = Max turn speed (radians/second)
αmax = Max acceleration (units/second^2)
|V|max = Absolute max speed (units/second)
Pf(x, y) = Target position vector
Vf(x, y) = Target velocity vector (units/second)
θf = Target rotation (radians)
Select an immediate:
τ = A turn speed within [-τmax, τmax]
α = An acceleration scalar within [0, αmax] (must accelerate in direction it's currently facing)
Such that these are minimized:
t = Total time to move to the destination
|Pt-Pf| = Distance from target position at end
|Vt-Vf| = Deviation from target velocity at end
|θt-θf| = Deviation from target rotation at end (wrapped to (-π,π))
The parameters can be re-computed during each iteration of the game loop. A picture says 1000 words so for example given the current state as the blue dude, reach approximately the state of the red dude within as short a time as possible (arrows are velocity):
Pic http://public.blu.livefilestore.com/y1p6zWlGWeATDQCM80G6gaDaX43BUik0DbFukbwE9I4rMk8axYpKwVS5-43rbwG9aZQmttJXd68NDAtYpYL6ugQXg/words.gif
Assuming a constant α and τ for Δt (Δt → 0 for an ideal solution) and splitting position/velocity into components, this gives (I think, my math is probably off):
Equations http://public.blu.livefilestore.com/y1p6zWlGWeATDTF9DZsTdHiio4dAKGrvSzg904W9cOeaeLpAE3MJzGZFokcZ-ZY21d0RGQ7VTxHIS88uC8-iDAV7g/equations.gif
(EDIT: that last one should be θ = θ0 + τΔt)
So, how do I select an immediate α and τ (remember these will be recomputed every iteration of the game loop, usually > 100 fps)? The simplest, most naieve way I can think of is:
Select a Δt equal to the average of the last few Δts between updates of the game loop (i.e. very small)
Compute the above 5 equations of the next step for all combinations of (α, τ) = {0, αmax} x {-τmax, 0, τmax} (only 6 combonations and 5 equations for each, so shouldn't take too long, and since they are run so often, the rather restrictive ranges will be amortized in the end)
Assign weights to position, velocity and rotation. Perhaps these weights could be dynamic (i.e. the further from position the entity is, the more position is weighted).
Greedily choose the one that minimizes these for the location Δt from now.
Its potentially fast & simple, however, there are a few glaring problems with this:
Arbitrary selection of weights
It's a greedy algorithm that (by its very nature) can't backtrack
It doesn't really take into account the problem space
If it frequently changes acceleration or turns, the animation could look "jerky".
Note that while the algorithm can (and probably should) save state between iterations, but Pf, Vf and θf can change every iteration (i.e. if the entity is trying to follow/position itself near another), so the algorithm needs to be able to adapt to changing conditions.
Any ideas? Is there a simple solution for this I'm missing?
Thanks,
Robert
| 0
| 1
| 0
| 0
| 1
| 0
|
Given 2N-points in a 2D-plane, you have to group them into N pairs such that the overall sum of distances between the points of all of the pairs is the minimum possible value.The desired output is only the sum.
In other words, if a1,a2,..an are the distances between points of first, second...and nth pair respectively, then (a1+a2+...an) should be minimum.
Let us consider this test-case, if the 2*5 points are :
{20,20},
{40, 20},
{10, 10},
{2, 2},
{240, 6},
{12, 12},
{100, 120},
{6, 48},
{12, 18},
{0, 0}
The desired output is 237.
This is not my homework,I am inquisitive about different approaches rather than brute-force.
| 0
| 0
| 0
| 0
| 1
| 0
|
Can somebody provide me with an easy to understand explanation of a guarded equation as it is used in Haskell and also its mathematical sense?
| 0
| 0
| 0
| 0
| 1
| 0
|
It is possible because PageRank was a form of eigenvalue and that is why MapReduce introduced. But there seems problems in actual implementation, such as every slave computer have to maintain a copy of the matrix?
| 0
| 0
| 0
| 0
| 1
| 0
|
Does every function has to be inside a type like in C#? Or does F# has free functions?
Also what about functions I have seen all over some F# code like, cos, sin, etc. Are they calls to Math.Cos, Math.Sin?
Also why did they provide cos, sin, etc like that instead of Math.Cos, Math.Sin?
| 0
| 0
| 0
| 0
| 1
| 0
|
Does F# have the same problem as C# where you can't directly use arithmetic operators with generic T types?
Can you write a generic Sum function that would return the sum of any value that supports the arithmetic addition?
| 0
| 0
| 0
| 0
| 1
| 0
|
I'm creating an MySQL call using PHP, I'm calculating distance using the haversine forumula:
SELECT name, id,
(6371 * acos(cos(radians(' . $lat . '))
* cos(radians(geoname.latitude))
* cos(radians(geoname.longitude) - radians(' . $lon . '))
+ sin(radians(' . $lat . '))
* sin(radians(geoname.latitude)))) AS distance
My question is; is it best to do all this calculation in SQL? This query searches a table with around 1000 records. Would it be more efficient to do some of the math in PHP rather than SQL? Is there a better way to optimise this query?
| 0
| 0
| 0
| 0
| 1
| 0
|
Hello I would like to know how to implement the solution to such a task:
There's a 500Mb file of plain English texts.
I'd like to collect the statistics about the frequency of words,
but additionally to be sure that each word is recognized correctly (or the majority of words).
In terms that 'cry' in the sentence "she gave a loud CRY" would
be classified as a noun and "Do not cry" would give a verb to the statistics.
Also, it would be good to filter proper names, so that they formed another dictionary.
The other task would be more difficult. I would like to find the occurences of words that
come together quite often and to build the list of such occurences.
Let's say, "green grass", "beautiful girl", "handle carefully", "you are right".
So that we could say exactly, what word sequences are often used together in the language.
HOW WOULD I START? Are there open Java tools & good books on the subject?
| 0
| 1
| 0
| 0
| 0
| 0
|
What's a good way to determine the following.
You have a table of game players, in an array of size N. Each round, each player takes a turn.
You know the index of the player that should go first, and each player will take a turn ascending the array, and looping back to 0 when it hits the last index. For example, if player at index 3 went first, then 4 would go second, and 2 would go last.
How do you calculate the index of the player that goes last in the round?
Here's one way:
var startPosition = 3;
var numberOfPlayers = 10;
for (var i=0;i<numberOfPlayers;i++) {
startPosition++;
if (startPosition == numberOfPlayers) startPosition = 0;
}
| 0
| 0
| 0
| 0
| 1
| 0
|
Given 2 java AffineTransform items, how can I interpolate between them. I need the image on screen to slowly move from the position/rotation/scale with one matrix applied, to the other.
Preferably this should be reasonably efficient since it's running every time a game draws.
My current (really hacky) solution is to getTranslate() from both matrices, lerp between them, and then create a new matrix (This doesn't work fully, since there is no equivalent for rotation)
| 0
| 0
| 0
| 0
| 1
| 0
|
Will adding 6 random unique numbers in the range 0-32 and doing a modulus on the result favour a high number?
Example: 9 +10 +11 +18 +25 +28 +32 = 133 % 20 = 13
| 0
| 0
| 0
| 0
| 1
| 0
|
I am using Python 3.1, but I can downgrade if needed.
I have an ASCII file containing a short story written in one of the languages the alphabet of which can be represented with upper and or lower ASCII. I wish to:
1) Detect an encoding to the best of my abilities, get some sort of confidence metric (would vary depending on the length of the file, right?)
2) Automatically translate the whole thing using some free online service or a library.
Additional question: What if the text is written in a language where it takes 2 or more bytes to represent one letter and the byte order mark is not there to help me?
Finally, how do I deal with punctuation and misc characters such as space? It will occur more frequently than some letters, right? How about the fact that punctuation and characters can be sometimes mixed - there might be two representations of a comma, two representations for what looks like an "a", etc.?
Yes, I have read the article by Joel Spolsky on Unicode. Please help me with at least some of these items.
Thank you!
P.S. This is not a homework, but it is for self-educational purposes. I prefer using a letter frequency library that is open-source and readable as opposed to the one that is closed, efficient, but gets the job done well.
| 0
| 1
| 0
| 0
| 0
| 0
|
What are books about how to build a natural language parsing program like this:
input: I got to TALL you
output: I got to TELL you
input: Big RAT box
output: Big RED box
in: hoo un thum zend three
out: one thousand three
It must have the language model that allows to predict what words are misspelled !
What are the best books on how to build such a tool??
p.s. Are there free webservices to spell-check? From Google maybe?..
| 0
| 1
| 0
| 0
| 0
| 0
|
I want to increase a decimal's smallest fractional part with one so that for example
decimal d = 0.01
d++
d == 0.02
or
decimal d = 0.000012349
d++
d == 0.000012350
How do i do this?
| 0
| 0
| 0
| 0
| 1
| 0
|
I have a series of timestamped on/off data in a table, representing on/off states, or the point at which a state "starts"
00:00:00 0
04:00:00 1
08:00:00 0
09:00:00 1
15:00:00 0
20:00:00 1
23:59:59 0
I need to calculate the total duration of (say) the ON state over a 24h period.
In this simplified example total duration = 1 is
(04:00:00->08:00:00, 09:00:00->15:00:00, 20:00:00->23:59:59
i.e. 13:59:59 approx 14h
I can't determine whether this can be done in SQL alone, or whether the underlying framework i am using (django) would need to do this based on returned data. I would obviously prefer to have the database do the heavy lifting if possible, because we may need to use the SQL in our separate stats package as well.
It's not clear to me if I can do operations on (say) previous or next element in the select, I am a confident SQL user but can't see where to start for this or the generalised approach, any ideas?
I'd really like this in a single query, or some other clever way of calculating this I am missing!
| 0
| 0
| 0
| 0
| 1
| 0
|
How would one go about implementing least squares regression for factor analysis in C/C++?
| 0
| 0
| 0
| 0
| 1
| 0
|
i've got a problem with the sampling theorem
Sampling theorem states that a signal can be reconstructed exactly from it's samples if the original signal has no frequencies above half the sampling frequency.
But what about frequencies exactly half the sampling frequency?? let's say i sample a sine (with an arbitrary phase and amplitude) with a frequency exactly double the sine frequency. I will be unable to reconstruct the phase and the amplitude of the sine because i don't know how the phase shifted the sine in relation to my samples (for example, if i happen to sample exactly on the zero-crossings of the sine, my samples will all be zero).
what's the solution to that problem?
| 0
| 0
| 0
| 0
| 1
| 0
|
I ask because a lot of game programming and graphic design seems to use the z-axis a lot. I didn't know what kind of math uses it so I could understand it and its relation to programming graphics applications. I don't remember seeing it - all the way up to calc 2.
| 0
| 0
| 0
| 0
| 1
| 0
|
I am currently dabbling in expert systems, emacs lisp, and reading up about artificial intelligence. Traditionally, artificial intelligence is associated with LISP and expert systems with CLIPS. However, I have noticed in computational sciences how much Python is being used. What about the area of artificial intelligence and machine learning? is it still been dominated by LISP? how much is python being used in AI? are any of the newer functional languages, clojure for example, being used in research?
in the area of expert systems, which shells are most used/popular today? are there any interesting developments language wise which you know of?
| 0
| 1
| 0
| 0
| 0
| 0
|
Assume I do this operation:
(X / const) * const
with double-precision arguments as defined by IEEE 754-2008, division first, then multiplication.
const is in the range 0 < ABS(const) < 1.
Assuming that the operation succeeds (no overflows occur), are distinct arguments of X to this operation guaranteed to return distinct results?
In other words, are there any X1, X2 and 0 < ABS(const) < 1 so that X1 <> X2, but (X1 / const) * const = (X2 / const) * const?
| 0
| 0
| 0
| 0
| 1
| 0
|
I'm creating an application in C# 3.5 that uses the AutoCAD API to read a 2D AutoCAD drawing, make changes to the drawing using defined business logic, then adjust it back in AutoCAD. Due to the nature of the logic, the shape of the drawing has to be re-constructed - e.g. a rectangle is made up of 4 connecting straight lines.
I'm creating these shapes using the start and end co-ordinates of each line from AutoCAD, but some of the co-ordinates don't exactly match up. For example, one point could at 0.69912839 (on one axis), but a line starting from the same point could be 0.69990821. These are in mm so the distance is minute (0.00078mm!)
I've created my own class (call it MyPoint, similar to PointF) because I've needed to add some additional logic to it. In that class I've created a method that takes two doubles and returns true or false depending on if the two points are within 0.001mm of each other. I've then overridden the Equals method, == and != operators so I can do (point1 == point2 or point1.Equals(point2)) which checks if all axis are within 0.001mm of each other - if they are, I class it as being the same point.
That's fine and working brilliantly. Now, I need to check a collection of these point classes to get rid of all duplicates, so I'm using LINQ's Distinct() method on my collection. However this method uses GetHashcode(), not Equals() to determine if the instances are equal. So, I've overriden GetHashcode() which uses the GetHashcode of the double class.
But, the above example fails because obviously they're different values and therefore generate different hashcodes. Is there any way that two numbers that are within 0.001 of each other can generate the same hashcode? (Note the numbers don't know about each other as GetHashcode is called separately on different class instances.) I've tried numerous ways which work for some examples but not for others.
One example is truncating the number to 3dp (multiply it by 10^3, then truncate it) and creating the hashcode on the result - which works for the above example (699 == 699.) But this doesn't work for 0.69990821 and 0.70000120 (699 != 700.) I've tried rounding, which works for the second set of numbers (0.700 == 0.700) but not for the first (0.699 != 0.700.) I've even tried truncating the number to 3dp then adjusting it up to the next even number, which works for both the previous examples, but not for 12.9809 and 12.9818 (12980 != 12982.)
Is there another way, or should I scrap the Equals, ==, != and GetHashcode overrides, and create my own MyPoint.IsEqualTo() and MyPointCollection.Distinct() methods?
| 0
| 0
| 0
| 0
| 1
| 0
|
I have a unit in a game which is pointing in a particular direction; when it turns to another direction it should take the shortest turn available. The scheme starts at a particular angle, and requires a given angle to lerp (linear interpolate) towards.
For example, lerping from 10 degrees to 350 degrees should calculate a target angle of -10. Conversely lerping from 350 to 10 should calculate an end end of 370 degrees.
What algorithm can calculate these required end values?
EDIT:: There seems to be some confusion over what I need
I'm using linear interpolation to calculate angles over time. So, if I want to get from 10 to 20 then the end value needs to be 20, then I shall interpolate from 10 to 20 and turn right. However, similarly if I want to go from 20 to 10, then interpolating from 20 to 10 will go anticlockwise, this is fine too. The problem is when the turn is more than 180 in the clockwise direction, to go from 270 to 80 (210 degrees) needs to turn clockwise, direct interpolation from 270 to 80 will go anticlockwise, I need to interpolate from 270 to 420 (360+80), which will go anticlockwise.
| 0
| 0
| 0
| 0
| 1
| 0
|
I'm trying to get my simulation to stop on a specific point. I have my starting position, an ending position, my current velocity and the time I'd like to take to get there. Since:
d = vt + (at^2)/2
I was figuring that
d = (end - start)
a = 2(d - vt) / t^2
but my end point is way off when I run it. I've tried using two simple updates, first:
v += a * dt
d += v * dt
and second:
d += v * dt + a * dt * dt / 2;
v += a * dt;
if that matters. Position in this case is 1d, so no need for crazy vector stuff. Any help would be greatly appreciated :) Thanks!
(Edit: formatting)
(Edit2: corrected update #2)
(Edit3: updates now show dt instead of t)
| 0
| 0
| 0
| 0
| 1
| 0
|
I would like to develop a poker odds application that can give the probability of various game situations. Since the application will be mostly statistical analysis, I figured I would see if someone else had already written a library that implements the required mathematics.
I would prefer cross-platform open-source in C++, but that's not a requirement.
| 0
| 0
| 0
| 0
| 1
| 0
|
Unmanaged languages notwithstanding, is F# really better than C# for implementing math? And if that's the case, why?
| 0
| 0
| 0
| 0
| 1
| 0
|
Is there a natural language web application framework? Maybe something like http://inform7.com ?
Maybe something like:
Make a website called My_homepage at my_homepage.com
The homepage for My_homepage is called mainpage
mainpage has a title of 'Home'
mainpage has text at the top saying 'My homepage'
| 0
| 1
| 0
| 0
| 0
| 0
|
How should I approach a situtation when I try to apply some ML algorithm (classification, to be more specific, SVM in particular) over some high dimensional input, and the results I get are not quite satisfactory?
1, 2 or 3 dimensional data can be visualized, along with the algorithm's results, so you can get the hang of what's going on, and have some idea how to aproach the problem. Once the data is over 3 dimensions, other than intuitively playing around with the parameters I am not really sure how to attack it?
| 0
| 0
| 0
| 1
| 0
| 0
|
What I am hoping to achieve is the ability to generate 'teams' of users. I will have x amount of men, weighted (decimal skill weight, like 75.23) and y amount of women (also with a skill weight value).
Given that list of users, I would then take for input the number of teams to make (let us say, 6 teams). Then, I go through the list of x's and y's and organize them so that the best average possible weighted teams are created. I would like to keep the teams balanced (women and men ratio)
I don't want 'stacked' teams, (best skilled in one team). I would like an even distribution of weight.
Curious how I could achieve this in PHP? I'd be using a MySQL database to fetch users with weight values. I would know ahead of time how many users I would have, also how many teams I would want to generate.
I would appreciate any suggestions, or links to a solution if anyone has found something similar like this. I'm just not a math wiz, so I don't know what formula would apply here.
Thanks. I appreciate any input!
EDIT
After reviewing the answers, maybe I was not clear enough, so hopefully this helps a little more.
I want the teams to be roughly equally-sized
I want the average (mean) skill score for each team to be roughly equal
I want the ratio of men to women in each team to be roughly equal (that is to say, if by division, we get a distribution, of 5 men and 3 women per team, I would like to keep that roughly the same). Not really an issue if I sort men first, and women second (or vise-versa).
I don't want a linear approach (team 1 gets highest, team 2, sec highest, team 3.. so on). Tim's method of taking (if 6 teams) 6 people and randomizing and then distributing via linear fashion seems to work out fine.
| 0
| 0
| 0
| 0
| 1
| 0
|
I tried to solve problem# 276 from Project Euler, but without success so far.
Consider the triangles with integer
sides a, b and c with a ≤ b ≤ c. An
integer sided triangle (a,b,c) is
called primitive if gcd(a,b,c)=1. How
many primitive integer sided triangles
exist with a perimeter not exceeding
10 000 000?
The bottleneck in my code is the GCD function. It almost takes 90% of execution time for my sample input. I would love to hear hints, comments on how to improve the solution... My solution is written in C, but it is quit simple:
#include <stdio.h>
#include <math.h>
#define sides 3
// This is where my program spends most of its time
size_t bi_gcd (size_t a, size_t b);
size_t tri_gcd (size_t a, size_t b, size_t c);
size_t count_primitive_triangles (size_t maximum_perimeter);
int main()
{
printf( "primitive_triangles = %lu
",
count_primitive_triangles(1000) );
}
size_t bi_gcd (size_t a, size_t b)
{
size_t t;
while(b != 0)
{
t = b;
b = a % b;
a = t;
}
return a;
}
size_t tri_gcd (size_t a, size_t b, size_t c)
{
return bi_gcd(a, bi_gcd(b, c));
}
size_t count_primitive_triangles (size_t max_perimeter)
{
size_t count = 0; // number of primitive triangles
size_t a, b, c; // sides of the triangle
// the following are the bounds of each side
size_t
// because b >= a && c >= b ==> max of a
// is when a+b+c > 10,000,000
// b == a (at least)
// c == b (at least)
// ==> a+b+c >= 10,000,000
// ==> 3*a >= 10,000,000
// ==> a= 10,000,000/3
a_limit = max_perimeter/sides,
b_limit,
c_limit;
for (a = 1; a <= a_limit; ++a)
{
// because c >= b && a+b+c <= 10,000,000
// ==> 2*b + a = 10,000,000
// ==> 2*b = 10,000,000 - a
// ==> b = (10,000,000 - a)/2
for (b = a, b_limit = (max_perimeter-a)/2; b <= b_limit; ++b)
{
// The triangle inequality:
// a+b > c (for a triangle to be valid!)
// ==> c < a+b
for (c = b, c_limit = a+b; c < c_limit; ++c)
{
if (tri_gcd(a, b, c) == 1)
++count;
}
}
}
return count;
}
| 0
| 0
| 0
| 0
| 1
| 0
|
Does anyone know how to minimize a function containing an integral in MATLAB? The function looks like this:
L = Int(t=0,t=T)[(AR-x)dt], A is a system parameter and R and x are related through:
dR/dt = axRY - bR, where a and b are constants.
dY/dt = -xRY
I read somewhere that I can use fminbnd and quad in combination but I am not able to make it work. Any suggestions?
| 0
| 0
| 0
| 0
| 1
| 0
|
Does anyone know of a project that uses some sort of interpreted runtime, to perhaps, as an example will take a before and after text file and generate and run a program in its-self to produce the after result. So it combines a bit of lexing, fuzzy logic, NN, backtracking, genetic programing, software FPGA.
I am interested in how the horsepower of modern quad socket, quad core machines can help programmers in unusual ways. I normally program in Prolog so never care about speed, memory usage etc as the problems I solve take humans a week while a machine might take six hours.
This is a hobby, not homework, not work. Something to keep my servers busy rather than warming the planet
| 0
| 1
| 0
| 0
| 0
| 0
|
I'm developing a Genetic Algorithm in python were chromosomes are composed of strings and integers. To apply the genetic operations, I want to convert these groups of integers and strings into bit strings.
For example, if one chromosome is:
["Hello", 4, "anotherString"]
I'd like it to become something like:
0100100100101001010011110011
(this is not actual translation). So... How can I do this? Chromosomes will contain the same amount of strings and integers, but this numbers can vary from one algorithm run to another.
To be clear, what I want to obtain is the bit representation of each element in the chromosome concatenated.
If you think this would not be the best way to apply genetic operators (such as mutation and simple crossover) just tell me! I'm open to new ideas.
Thanks a lot!
Manuel
| 0
| 1
| 0
| 0
| 0
| 0
|
I have a triangulated isometric grid, like this:
(source: mathforum.org)
In my code, triangles are grouped by columns.
As I hover the mouse, I want to calculate what triangle the mouse coordinates are in. Is there a simple algorithm to do that?
| 0
| 0
| 0
| 0
| 1
| 0
|
First of all,thanks for reading my question.
I used TF/IDF then on those values, I calculated cosine similarity to see how many documents are more similar. You can see the following matrix. Column names are like doc1, doc2, doc3 and rows names are same like doc1, doc2, doc3 etc. With the help of following matrix, I can see that doc1 and doc4 has 72% similarity (0.722711142). It is correct even if I see both documents they are similar. I have 1000 documents and I can see each document freq. in matrix to see how many of them are similar.
I used different clustering like k-means and agnes ( hierarchy) to combine them. It made clusters. For example Cluster1 has (doc4, doc5, doc3) becoz they have values (0.722711142, 0.602301766, 0.69912109) more close respectively. But when I see manually if these 3 documents are realy same so they are NOT. :( What am I doing or should I use something else other than clustering??????
1 0.067305859 -0.027552299 0.602301766 0.722711142
0.067305859 1 0.048492904 0.029151952 -0.034714695
-0.027552299 0.748492904 1 0.610617214 0.010912109
0.602301766 0.029151952 -0.061617214 1 0.034410392
0.722711142 -0.034714695 0.69912109 0.034410392 1
P.S: The values can be wrong, it is just to give you an idea.
If you have any question please do ask.
Thanks
| 0
| 0
| 0
| 0
| 1
| 0
|
In trying to solve a particular Project Euler question, I ran into difficulties with a particular mathematical formula. According to this web page (http://www.mathpages.com/home/kmath093.htm), the formula for determining the probability for rolling a sum, T, on a number of dice, n, each with number of sides, s, each numbered 1 to s, can be given as follows:
alt text http://www.freeimagehosting.net/uploads/8294d47194.gif
After I started getting nonsensical answers in my program, I started stepping through, and tried this for some specific values. In particular, I decided to try the formula for a sum T=20, for n=9 dice, each with s=4 sides. As the sum of 9 4-sided dice should give a bell-like curve of results, ranging from 4 to 36, a sum of 20 seems like it should be fairly (relatively speaking) likely. Dropping the values into the formula, I got:
alt text http://www.freeimagehosting.net/uploads/8e7b339e32.gif
Since j runs from 0 to 7, we must add over all j...but for most of these values, the result is 0, because at least one the choose formulae results are 0. The only values for j that seem to return non-0 results are 3 and 4. Dropping 3 and 4 into this formula, I got
alt text http://www.freeimagehosting.net/uploads/490f943fa5.gif
Which, when simplified, seemed to go to:
alt text http://www.freeimagehosting.net/uploads/603ca84541.gif
which eventually simplifies down to ~30.75. Now, as a probability, of course, 30.75 is way off...the probability must be between 0 and 1, so something has gone terribly wrong. But I'm not clear what it is.
Could I misunderstanding the formula? Very possible, though I'm not clear at all where the breakdown would be occuring. Could it be transcribed wrong on the web page? Also possible, but I've found it difficult to find another version of it online to check it against. Could I be just making a silly math error? Also possible...though my program comes up with a similar value, so I think it's more likely that I'm misunderstanding something.
Any hints?
(I would post this on MathOverflow.com, but I don't think it even comes close to being the kind of "postgraduate-level" mathematics that is required to survive there.)
Also: I definitely do not want the answer to the Project Euler question, and I suspect that other people that my stumble across this would feel the same way. I'm just trying to figure out where my math skills are breaking down.
| 0
| 0
| 0
| 0
| 1
| 0
|
I am writing a code in C++ and want to compute distance between two points.
Question 1:
I have two points P(x1, y1, z1) and Q(x2, y2, z2) , where x, y and z are floats/doubles.
I want to find the distance between these two points. One way to do it is :
square_root(x_diffx_diff + y_diffy_diff + z_diff*z_diff)
But this is probably not the most efficient way . (e.g. a better formula or a ready made utility in math.h etc )
Question 2:
Is there a better way if I just want to determine if P and Q are in fact the same points?
My inputs are x, y and z coordinates of both the points.
Thank you
| 0
| 0
| 0
| 0
| 1
| 0
|
What are the number of combinations in which 8 persons taking part in a single elimination tornament play? Total no of matches played would be 7 but I also need the number of combinations that can for this set
| 0
| 0
| 0
| 0
| 1
| 0
|
$value = '100.00';
echo $value * 100/100;
Or should I be rounding incase there's a value such as '100.70'? I'm displaying this for a table that displays daily rates, the total value contains the digits so I assume the user won't have to really worry about decimal values...
| 0
| 0
| 0
| 0
| 1
| 0
|
I've been studying algorithms about collective intelligence, for things such as recommendation engines, neural networks etc., and was looking for freely available datasets and/or APIs for practice projects. any suggestions?
EDIT: my original question was kind of vague, so here are some examples of the types of things I was looking for:
Delicious API: collection of links, tags, who liked them, etc.
Ebay API: resource of various items, prices, descriptions.
| 0
| 1
| 0
| 0
| 0
| 0
|
I want to be able to make image move realistically with the accelerometer controlling it, like any labyrinth game. Below shows what I have so far but it seems very jittery and isnt realistic at all. The ball images seems to never be able to stop and does lots of jittery movements around everywhere.
- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration {
deviceTilt.x = 0.01 * deviceTilt.x + (1.0 - 0.01) * acceleration.x;
deviceTilt.y = 0.01 * deviceTilt.y + (1.0 - 0.01) * acceleration.y;
}
-(void)onTimer {
ballImage.center = CGPointMake(ballImage.center.x + (deviceTilt.x * 50), ballImage.center.y + (deviceTilt.y * 50));
if (ballImage.center.x > 279) {
ballImage.center = CGPointMake(279, ballImage.center.y);
}
if (ballImage.center.x < 42) {
ballImage.center = CGPointMake(42, ballImage.center.y);
}
if (ballImage.center.y > 419) {
ballImage.center = CGPointMake(ballImage.center.x, 419);
}
if (ballImage.center.y < 181) {
ballImage.center = CGPointMake(ballImage.center.x, 181);
}
| 0
| 0
| 0
| 0
| 1
| 0
|
Consider the following scenario:
We have a number of sequential building blocks (e.g. 12 building blocks, ordered from 1 to 12), distributed randomly (but not necessarily equally) on a number of builders (e.g. 3 builders).
The builders are required to work in order and start building the wall from block number 4, both ways; down to block number 1 or up to block 12.
Each builder doesn't have any knowledge about what block numbers the other builders may have, though he knows how many.
Builders must try to finish first by preventing others from making their moves. They should not pass and have to place a block, if they can.
Any builder who finishes all his blocks first will be granted the highest reward, then the second, and so on...
Can we predict who will finish first, second and last? Is there any algorithm the builders should follow to get their work done first?
The following is a practical example of the problem:
Let us say:
builder 1 has: b2 b5 b8 b9
builder 2 has: b1 b11
builder 3 has: b3 b4 b6 b7 b10 b12
builder 1, and builder 2 will have to wait for builder 3 to place b4.
builder 3 will place b4, and gives his place back to builder 1.
wall: b4
builder 1 will have to put up b5, as there are no other options for him.
wall: b4 b5
builder 2 will follow, but he cant place his blocks, he will have to wait for b2 or b10.
builder 3 now have two options: b3 or b6, he must choose the one which help him finish first.
wall: b4 b5 b6
builder 1 has nothing to do, he'll pass his turn to builder 2.
builder 2 is still waiting for the installation of b2 or b10.
builder 3 will have to place b7.
wall: b4 b5 b6 b7
builder 1 now will place b8.
wall: b4 b5 b6 b7 b8
builder 2 is still waiting patiently...
builder 3 is forced to put down b3, as there are no other options, he was hoping that builder 2 may place b9... but his hope faded!
wall: b3 b4 b5 b6 b7 b8
builder 1 is totally in charge now, and feeling very happy! but he is confused! after thinking he decided that b2 may allow him to keep preventing a larger number of blocks, which in turn increases his chance.
wall: b2 b3 b4 b5 b6 b7 b8
builder 2 says: finally! some action! and places b1.
wall: b1 b2 b3 b4 b5 b6 b7 b8
builder 3 lost his hope on becoming first!
builder 1 now will install his final block and go home with the biggest reward!
wall: b1 b2 b3 b4 b5 b6 b7 b8 b9
builder 2 will wait...
builder 3 sadly places b10
builder 2 places b11 and goes home with the second reward...
Any known algorithm for solving such problems?
| 0
| 1
| 0
| 0
| 0
| 0
|
I'm starting neural networks, currently following mostly D. Kriesel's tutorial. Right off the beginning it introduces at least three (different?) learning rules (Hebbian, delta rule, backpropagation) concerning supervised learning.
I might be missing something, but if the goal is merely to minimize the error, why not just apply gradient descent over Error(entire_set_of_weights)?
Edit: I must admit the answers still confuse me. It would be helpful if one could point out the actual difference between those methods, and the difference between them and straight gradient descent.
To stress it, these learning rules seem to take the layered structure of the network into account. On the other hand, finding the minimum of Error(W) for the entire set of weights completely ignores it. How does that fit in?
| 0
| 0
| 0
| 1
| 0
| 0
|
F# allows to use checked arithmetics by opening Checked module, which redefines standard operators to be checked operators, for example:
open Checked
let x = 1 + System.Int32.MaxValue // overflow
will result arithmetic overflow exception.
But what if I want to use checked arithmetics in some small scope, like C# allows with keyword checked:
int x = 1 + int.MaxValue; // ok
int y = checked { 1 + int.MaxValue }; // overflow
How can I control the scope of operators redefinition by opening Checked module or make it smaller as possible?
| 0
| 0
| 0
| 0
| 1
| 0
|
I need an AI Bot for a chat service which can imitate a human. I have tried ALICE with AIMLBot(C#) as a front-end but it didn't work very well.
Are there any good bots you would recommend?
| 0
| 1
| 0
| 0
| 0
| 0
|
I am trying to play tic tac toe using iterative Alpha-Beta prunning,
I have one second limit for a move but for some reason it
doesnt work well.
I modified the regular alpha-beta code so instead of returning
alpha or beta, it returns a state (which is the board with the next move)
Each time I create children I update their depth.
But again for some reason I keep losing and I see that
my alpha beta doesnt see the best move to make.
Here is my code:
The outer loop:
while (watch.get_ElapsedMilliseconds() < 900 && d <= board.length * board[0].length - 1)
{
s = maxiMin(beginSt, d, watch);
if (s.getNextMove().getIsWin() == true)
{
break;
}
d++;
}
return new location(s.getNextMove().getRow(), s.getNextMove().getCol());
The alpha beta:
public State maxiMin(State s, int depth, Stopwatch timer)
{
if (s.getDepth() == 7)
{
Console.WriteLine();
}
if (timer.get_ElapsedMilliseconds() > 850 || s.getDepth() == depth || goalTest(s.getBoard()) != 0)
{
s.evaluationFunc(line_length, PlayerShape);
s.setAlpha(s.getEvaluation());
s.setBeta(s.getEvaluation());
return s;
}
LinkedList<State> children = createChildren(s, true);
// No winner, the board is full
if (children.get_Count() == 0)
{
s.evaluationFunc(line_length, PlayerShape);
s.setAlpha(s.getEvaluation());
s.setBeta(s.getEvaluation());
return s;
}
while (children.get_Count() > 0)
{
State firstChild = children.get_First().get_Value();
children.RemoveFirst();
State tmp = miniMax(firstChild, depth, timer);
int value = tmp.getBeta();
if (value > s.getAlpha())
{
s.setAlpha(value);
s.setNextMove(tmp);
}
if (s.getAlpha() >= s.getBeta())
{
return s;
}
}
return s;
}
public State miniMax(State s, int depth, Stopwatch timer)
{
if (s.getDepth() == 7)
{
Console.WriteLine();
}
if (timer.get_ElapsedMilliseconds() > 850 || s.getDepth() == depth || goalTest(s.getBoard()) != 0)
{
s.evaluationFunc(line_length, PlayerShape);
s.setAlpha(s.getEvaluation());
s.setBeta(s.getEvaluation());
return s;
}
LinkedList<State> children = createChildren(s, false);
// No winner, the board is full
if (children.get_Count() == 0)
{
s.evaluationFunc(line_length, PlayerShape);
s.setAlpha(s.getEvaluation());
s.setBeta(s.getEvaluation());
return s;
}
while (children.get_Count() > 0)
{
State firstChild = children.get_First().get_Value();
children.RemoveFirst();
State tmp = maxiMin(firstChild, depth, timer);
int value = tmp.getAlpha();
if (value < s.getBeta())
{
s.setBeta(value);
s.setNextMove(tmp);
}
if (s.getAlpha() >= s.getBeta())
{
return s;
}
}
return s;
}
Would appriciate much if anyone can tell me if something is wrong. I suspect maybe
it something to do with that I am returning "s" instead of the regular alpha beta
which returns the evaluation but I didnt manage to find the error.
Thanks in advance,
Lena
| 0
| 1
| 0
| 0
| 0
| 0
|
I don't know if I've chosen the appropriate title for this question (if not, please change it accordingly) but consider the following simplified table structure I'm working with:
----------------------------------------------
| date | i | j | k | x | y | z |
----------------------------------------------
| 100209 | 1 | 2 | 3 | 4 | 5 | 6 |
----------------------------------------------
| 100210 | 2 | 3 | 4 | 5 | 6 | 7 |
----------------------------------------------
| 100211 | 0 | 1 | 2 | 3 | 4 | 5 |
----------------------------------------------
| 100212 | 1 | 2 | 3 | 4 | 5 | 6 |
----------------------------------------------
| 100213 | 6 | 5 | 4 | 3 | 2 | 1 |
----------------------------------------------
i, j, k, x, y, z are all unrelated integers / floats, they all represent different factors and can have very different orders of magnitude (i can range from 1 - 10 while j can range from 100 - 1000).
I'm trying to select dates that share similar conditions; Given a set of i, j, k, x, y, z values I need to return all results ordered by closeness of all values as a whole for instance, if i = 1, j = 2, k = 3, x = 4, y = 5 and z = 6 the query should return the following dates in this order:
100209
100212
100210
100211
100213
I'm not sure if this is relevant or not to the question, but some values (i, j, k) mean more is better while other values (x, y, z) mean the opposite: less is better.
How I should build such a query? Is this possible with SQL alone?
@Pentium10:
I'll try to answer your comment the best way I can. Here is a sample of my data:
---------------------------------------------------------------------------------
date | temperature | humidity | pressure | windSpeed | moonDistance
---------------------------------------------------------------------------------
090206 | 7 | 87 | 998.8 | 3 | 363953
---------------------------------------------------------------------------------
...... | ... | ... | .... | ... | ......
---------------------------------------------------------------------------------
100206 | 10 | 86 | 1024 | 2 | 386342
---------------------------------------------------------------------------------
100207 | 9 | 90 | 1015 | 1 | 391750
---------------------------------------------------------------------------------
100208 | 13 | 90 | 1005 | 2 | 396392
---------------------------------------------------------------------------------
100209 | 12 | 89 | 1008 | 2 | 400157
---------------------------------------------------------------------------------
100210 | 11 | 92 | 1007 | 3 | 403012
---------------------------------------------------------------------------------
100211 | 6 | 86 | 1012 | 2 | 404984
---------------------------------------------------------------------------------
100212 | 6 | 61 | 1010 | 3 | 406135
---------------------------------------------------------------------------------
100213 | 7 | 57 | 1010 | 2 | 406542
---------------------------------------------------------------------------------
My table structure has more columns and thousands of rows but hopefully this will be enough to get my point clear. I'm not going to attempt to order these values like I did in my previous example because I would probably get it wrong, but I basically need to do two types of queries with this data:
show me all dates, ordered by the resemblance of the conditions provided by me
show me all dates, ordered by the resemblance of the conditions observed in date X
I understand that the second query can easily be archived by using the first one, but my problem lies in sorting by resemblance using several columns, that's what I meant by "ordered by closeness of all values as a whole". As in, if I was dealing with only one column it would be a lot easier to order by likeness but my head really starts spinning when dealing with several columns.
The goal is to to be able to produce results like this:
Today is really similar to d/m/yy,
very similar to d/m/yy, somewhat
similar to d/m/yy, ...
In my case I'm working with weather and atmospheric data but if it helps I guess you can think in this problem in terms of employees (having attendance, hoursPerWeek and monthlySalary columns) and order by employees that most closely resemble attendance = 100%, hoursPerWeek = 40 and monthlySalary = $5000, for instance.
PS: Now that I've given this employees example I'm not really sure anymore if it can be compared to the weather example I'm working with, since with the employees table you can compute (rating = monthlySalary / hoursPerWeek * attendance for instance) and kinda weight the columns, but I don't think the same can be done with the weather table - input is appreciated anyhow.
PS2: I'm not sure if I expressed myself well enough, if you still have doubts please let me know.
Bounty
Some good suggestions so far, however
none of them truly solve my problem.
I'm setting up a bounty to hopefully
gather even more possible solutions to
this problem. Thanks.
| 0
| 0
| 0
| 0
| 1
| 0
|
I am now using libsvm for support vector machine classifier with Gaussian kernal. In its website, it provides a python script grid.py to select the best C and gamma.
I just wonder how training time and overfitting/underfitting change with gamma and C?
Is it correct that:
suppose C changes from 0 to +infinity, the trained model will go from underfitting to overfitting, and the training time increases?
suppose gamma changes from almost 0 to +infinity, the trained model will go from underfitting to overfitting, and the training time increases?
In grid.py, the default searching order is for C from small to big BUT gamma from big to small. Is it for the purpose of training time from small to big and trained model from underfitting to overfitting? So we can perhaps save time in selecting the values of C and gamma?
Thanks and regards!
| 0
| 0
| 0
| 1
| 0
| 0
|
Is there already a python package allowing to graphically edit the graph of a function?
| 0
| 0
| 0
| 0
| 1
| 0
|
Which approach would you suggest for automatically classifying type found in images? The samples are likely large, with black text on a white background.
The categories are defined here, with some examples on each (Google Books link): http://bit.ly/9Mnu7P This is an extended version of the VOX-ATypI classification system.
My initial thoughts on this were to train the system with lots of single character samples from each category, but I'm wondering if there's a better way that would eliminate the need to do the comparison one letter at a time.
| 0
| 0
| 0
| 1
| 0
| 0
|
A friend of mine asked for a simple program.
Input: Coordinates of some points, spheres, planes etc. ( from an excel document (strictly) )
Output: A 3D view of the input which the user can move the camera.
The questions is, how can I do that easiest way. I have experience in C++, C#, Flash (AS), Java
| 0
| 0
| 0
| 0
| 1
| 0
|
I'm using rectangles defined in terms of their x y coordinates and their width and height. I figured out how to rotate them in terms of coordinates (x = cos(deg) * x - sin(deg) * y y = sin(deg) * x + cos(deg) * y) but I'm stuck on the height and width. I'm sure there's an obvious solution that I'm missing. If it matters, I'm using Python.
edit Sorry for the confusing description. My intention is to get the width and height either reversed or negated due to whatever the angle is. For example, in a 90 degree rotation the values would switch. In a 180 degree rotation the width would be negative. Also, I only intend to use multiples of 90 in my script. I could just use if statements, but I assumed there would be a more "elegant" method.
| 0
| 0
| 0
| 0
| 1
| 0
|
I want to decrease a value by one and if it reaches zero, set it to the maximum value. Is there a way to do this via math without resorting to if (n-1 == 0) { n = max; }
The opposite scenario of increasing a value by one and then setting it to zero when it is greater than max can easily be achieved using n = (n + 1) % (max + 1);. Furthermore, this is even better since you can increase by whatever amount (not just one) and it will still "wrap" correctly.
Thanks for the answers so far. To be clear, I meant without any boolean logic (if/else) or boolean operators (!, &&, etc) at all. I was just curious as to how to do this. Does the correct answer below really make it more unreadable as long as a comment is provided? It would be necessary to use that for the more general case for subtracting an arbitrary number and expecting the correct wrap around.
| 0
| 0
| 0
| 0
| 1
| 0
|
I have two NSArrays of Movie objects called DVD and VHS. I'd like to find the symmetric difference of these arrays. I want to know which Movies are in VHS buy not in DVD, and which Movies are in DVD but not VHS.
Can anyone tell me if there is a fast algorithm to solve it (preferably in C or Objective-C)? Is it faster/easier to solve if I use Dictionaries? What this kind of problem called (or is it just "Symmetric Difference")?
Thanks.
| 0
| 0
| 0
| 0
| 1
| 0
|
Possible Duplicate:
convert integer to a string in a given numeric base in python
I want to work with base 5 numbers, or any other non standard base for that matter.
I found out int('123', 5) works, but I need to go the other way around.
Should I write my own number class to accomplish this?
Maybe I'm just thinking in the wrong direction...
| 0
| 0
| 0
| 0
| 1
| 0
|
I have a hindi script file like this:
3. भारत का इतिहास काफी समृद्ध एवं विस्तृत है।
I have to write a program which adds a position to each and every word in each sentence.
Thus the numbering for every line for a particular word position should start off with 1 in parentheses. The output should be something like this.
3. भारत(1) का(2) इतिहास(3) काफी(4) समृद्ध(5) एवं(6) विस्तृत(7) है(8) ।(9)
The meaning of the above sentence is:
3. India has a long and rich history.
If you observe the '।'( which is a full stop in hindi equivalent to a '.' in English ) also has a word position and similarly other special symbols would also have as I am trying to go about English-Hindi Word alignment( a part of Natural Language Processing ( NLP ) ) so the full stop in english '.' should map to '।' in Hindi. Serial nos remain as it is untouched.
I thought reading character by character could be a solution. How can I do this?
The thing is I am able to get word positions for my English text using C++ as I was able to read character by character using ASCII values in C++ but I don't have a clue to how to go about the same for the hindi text.
The final aim of all this is to see which word position of the English text maps to which postion in Hindi. This way I can achieve bidirectional alignment.
Thank you for your time...:)
| 0
| 1
| 0
| 0
| 0
| 0
|
The following python code is to traverse a 2D grid of (c, g) in some special order, which is stored in "jobs" and "job_queue". But I am not sure which kind of order it is after trying to understand the code. Is someone able to tell about the order and give some explanation for the purpose of each function? Thanks and regards!
import Queue
c_begin, c_end, c_step = -5, 15, 2
g_begin, g_end, g_step = 3, -15, -2
def range_f(begin,end,step):
# like range, but works on non-integer too
seq = []
while True:
if step > 0 and begin > end: break
if step < 0 and begin < end: break
seq.append(begin)
begin = begin + step
return seq
def permute_sequence(seq):
n = len(seq)
if n <= 1: return seq
mid = int(n/2)
left = permute_sequence(seq[:mid])
right = permute_sequence(seq[mid+1:])
ret = [seq[mid]]
while left or right:
if left: ret.append(left.pop(0))
if right: ret.append(right.pop(0))
return ret
def calculate_jobs():
c_seq = permute_sequence(range_f(c_begin,c_end,c_step))
g_seq = permute_sequence(range_f(g_begin,g_end,g_step))
nr_c = float(len(c_seq))
nr_g = float(len(g_seq))
i = 0
j = 0
jobs = []
while i < nr_c or j < nr_g:
if i/nr_c < j/nr_g:
# increase C resolution
line = []
for k in range(0,j):
line.append((c_seq[i],g_seq[k]))
i = i + 1
jobs.append(line)
else:
# increase g resolution
line = []
for k in range(0,i):
line.append((c_seq[k],g_seq[j]))
j = j + 1
jobs.append(line)
return jobs
def main():
jobs = calculate_jobs()
job_queue = Queue.Queue(0)
for line in jobs:
for (c,g) in line:
job_queue.put((c,g))
main()
EDIT:
There is a value for each (c,g). The code actually is to search in the 2D grid of (c,g) to find a grid point where the value is the smallest. I guess the code is using some kind of heuristic search algorithm? The original code is here http://www.csie.ntu.edu.tw/~cjlin/libsvmtools/gridsvr/gridregression.py, which is a script to search for svm algorithm the best values for two parameters c and g with minimum validation error.
| 0
| 0
| 0
| 1
| 0
| 0
|
I'm trying to build an app to detect images which are advertisements from the webpages. Once I detect those I`ll not be allowing those to be displayed on the client side.
From the help that I got on this Stackoverflow question, I thought SVM is the best approach to my aim.
So, I have coded SVM and an SMO myself. The dataset which I have got from UCI data repository has 3280 instances ( Link to Dataset ) where around 400 of them are from class representing Advertisement images and rest of them representing non-advertisement images.
Right now I'm taking the first 2800 input sets and training the SVM. But after looking at the accuracy rate I realised that most of those 2800 input sets are from non-advertisement image class. So I`m getting very good accuracy for that class.
So what can I do here? About how many input set shall I give to SVM to train and how many of them for each class?
Thanks. Cheers. ( Basically made a new question because the context was different from my previous question. Optimization of Neural Network input data )
Thanks for the reply.
I want to check whether I`m deriving the C values for ad and non-ad class correctly or not.
Please give me feedback on this.
Or you u can see the doc version here.
You can see graph of y1 eqaul to y2 here
and y1 not equal to y2 here
| 0
| 0
| 0
| 1
| 0
| 0
|
i'm try for log10 calculation using mathml in xml as follow
<apply><log><cn>x</cn></log></apply>
for this i'm getting expected result, but now trying for antilog which is inverse of log, i'm not sure which tag have to be use, any i'm trying as follow
<apply><inverse><log><cn>x</cn></log></inverse></apply>
here i'm not getting the expected result, do anyone know the exact tag for the antilog
thanks
| 0
| 0
| 0
| 0
| 1
| 0
|
I asked a question earlier about how to deal with rounding issues with floating point numbers in PHP, and was pointed to the bc and gmp libraries.
I've looked at the functions in these libraries but nothing jumped out at me when I was looking for one to round off the number.
How do you accurately round using these libraries?
| 0
| 0
| 0
| 0
| 1
| 0
|
I have a file with a sequence of event timestamps corresponding to the times at which someone visits a website:
02.02.2010 09:00:00
02.02.2010 09:00:00
02.02.2010 09:00:00
02.02.2010 09:00:01
02.02.2010 09:00:03
02.02.2010 09:00:05
02.02.2010 09:00:06
02.02.2010 09:00:06
02.02.2010 09:00:09
02.02.2010 09:00:11
02.02.2010 09:00:11
02.02.2010 09:00:11
etc, for several thousand rows.
I'd like to get an idea how the web hits are distributed over time, over the week etc. I need to know how I should scale the (future) web servers in order to guarantee service availability with a given number of nines. In particuler I need to give upper bounds on the number of almost-concurrent visits.
Are there any resources out ther that explain how to do that? I'm fluent in mathematics and statistics, and I've looked at queuing theory but it seems that that theory assumes the rate of arrival to be independent of the time of the day, which is clearly wrong in my case. And NO, histograms are not the right answer since the result depends heavily on bin width and placement.
| 0
| 0
| 0
| 0
| 1
| 0
|
I've been trying to learn Text mining and other related things in Collective Intelligence field. I am interested to make an app which will scan thru the document and show related posts/articles on page.
What algorithm(s) would be helpful to retrieve required info?
Thanks
/A
| 0
| 1
| 0
| 0
| 0
| 0
|
I've made a lot of random math programs to help me with my homework (synthetic division being the most fun) and now I'm wanting to reverse a radical expression.
For instance, in my handy TI calculator I get
.2360679775
Well, I want to convert that number to it's equivalent irrational expression, which is
sqrt(5)-2
I realize I could brute force it... but that takes out the fun, and isn't nearly so easy when you consider the significant round-off error of floating point.
So how would you do it? Is there is a trivial algorithm?
| 0
| 0
| 0
| 0
| 1
| 0
|
I am trying to find information (and hopefully c# source code) about trying to create a basic AI tool that can understand english words, grammar and context.
The Idea is to train the AI by using as many written documents as possible and then based on these documents, for the AI to create its own creative writitng in proper english that makes sense to a human.
While the idea is simple, I do realise that the hurdles are huge, any starting points or good resoueces will be appriacted.
| 0
| 1
| 0
| 0
| 0
| 0
|
I have a a mesh, with certain types of elements (e.g. triangular, tetra). For each element I know all its vertices i.e. a triangular 2D element will have 3 vertices v1, v2 and v3 whose x,y,z coords are known.
Question 1
I am looking for an algorithm that will return all the edges... in this case:
edge(v1, v2), edge(v1, v3) , edge(v2, v3). Based on how many vertices each element has , the algorithm should efficiently determine the edges.
Question 2
I am using C++, so, what will be the most efficient way to store the information about the edges returned by the above algorithm? Example, all I am interested in is a tuple (v1, v2) that I want to use for some computation and then forget about it.
Thank you
| 0
| 0
| 0
| 0
| 1
| 0
|
I have information on paths I would like to draw. The information consists of a sequence of straight sections and curves. For straight sections, I have only the length. For curves, I have the radius, direction and angle. Basically, I have a turtle that can move straight or move in a circular arc from the current position (after which moving straight will be in a different direction).
I would like some way to draw these paths with the following conditions:
Minimal (preferably no) trigonometry.
Ability to center on a canvas and scale to fit any arbitrary size.
From what I can tell, GDI+ gives me number 2, Cairo gives me number 1, but neither one makes it particularly easy to get both. I'm open to suggestions of how to make GDI+ or Cairo (preferably pycairo) work, and I'm also open to any other library (preferably C# or Python).
I'm even open to abstract mathematical explanations of how this would be done that I can convert into code.
| 0
| 0
| 0
| 0
| 1
| 0
|
Hi:) I am not able to figure out what the error in the program is could you please help me out with it. Thank you..:)
The input file contains the following:
3. भारत का इतिहास काफी समृद्ध एवं विस्तृत है।
57. जैसे आज के झारखंड प्रदेश से, उन दिनों, बहुत से लोग चाय बागानों में मजदूरी करने के उद्देश्य से असम आए।
( its basically sample sentences for which i need to get word positions in the output appended to each word in hindi)
for e.g the output for the first sentence would look like this:
3. भारत(1) का(2) इतिहास(3) काफी(4) समृद्ध(5) एवं(6) विस्तृत(7) है(8) ।(9)
I should get a similar op for the following sentence(s)
The code looks like this:
#!/usr/bin/python
# -*- coding: UTF-8 -*-
# encoding: utf-8
separators = [u'।', ',', '.']
text = open("hinstest1.txt").read()
#This converts the encoded text to an internal unicode object, where
# all characters are properly recognized as an entity:
text = text.decode("UTF-8")
#this breaks the text on the white spaces, yielding a list of words:
words = text.split()
counter = 1
output = ""
#if the last char is a separator, and is joined to the word:
for word in words:
if word[-1] in separators and len(word) > 1:
#word up to the second to last char:
output += word[:-1] + u'(%d) ' % counter
counter += 1
#last char
output += word[-1] + u'(%d) ' % counter
else:
output += word + u'(%d) ' % counter
counter += 1
print output
The error I am getting is:
File "pyth_hinwp.py", line 22
output += word[-1] + u'(%d) ' % counter
^
SyntaxError: invalid syntax
I know this question is something similar to what I have asked earlier, but since I am not able to successfully execute some of the answers given to me earlier hence I am kinda restructuring the question to the place where I am currently getting stuck.
| 0
| 1
| 0
| 0
| 0
| 0
|
I have a code which appends word positions to the words from the source file
but the output is not coming as desired:
The input file contains the following:
3. भारत का इतिहास काफी समृद्ध एवं विस्तृत है।
57. जैसे आज के झारखंड प्रदेश से, उन दिनों, बहुत से लोग चाय बागानों में मजदूरी करने के उद्देश्य से असम आए।
The original source code is like this:
#!/usr/bin/python
# -*- coding: UTF-8 -*-
# encoding: utf-8
separators = [u'।', ',', '.']
text = open("hinstest1.txt").read()
#This converts the encoded text to an internal unicode object, where
# all characters are properly recognized as an entity:
text = text.decode("UTF-8")
#this breaks the text on the white spaces, yielding a list of words:
words = text.split()
counter = 1
output = ""
#if the last char is a separator, and is joined to the word:
for word in words:
if word[-1] in separators and len(word) > 1:
#word up to the second to last char:
output += word[:-1] + u'(%d) ' % counter
counter += 1
#last char
output += word[-1] +u'(%d) ' % counter
else:
output += word + u'(%d) ' % counter
counter += 1
#for ch in word:
# if ch is '
':
print output
#counter = 1
The output for this code is like this:
3(1) .(2)
3(1) .(2) भारत(2)
3(1) .(2) भारत(2) का(3)
3(1) .(2) भारत(2) का(3) इतिहास(4)
3(1) .(2) भारत(2) का(3) इतिहास(4) काफी(5)
3(1) .(2) भारत(2) का(3) इतिहास(4) काफी(5) समृद्ध(6)
3(1) .(2) भारत(2) का(3) इतिहास(4) काफी(5) समृद्ध(6) एवं(7)
3(1) .(2) भारत(2) का(3) इतिहास(4) काफी(5) समृद्ध(6) एवं(7) विस्तृत(8)
3(1) .(2) भारत(2) का(3) इतिहास(4) काफी(5) समृद्ध(6) एवं(7) विस्तृत(8) है(9) ।(10)
3(1) .(2) भारत(2) का(3) इतिहास(4) काफी(5) समृद्ध(6) एवं(7) विस्तृत(8) है(9) ।(10) 57(10) .(11)
3(1) .(2) भारत(2) का(3) इतिहास(4) काफी(5) समृद्ध(6) एवं(7) विस्तृत(8) है(9) ।(10) 57(10) .(11) जैसे(11)
3(1) .(2) भारत(2) का(3) इतिहास(4) काफी(5) समृद्ध(6) एवं(7) विस्तृत(8) है(9) ।(10) 57(10) .(11) जैसे(11) आज(12)
3(1) .(2) भारत(2) का(3) इतिहास(4) काफी(5) समृद्ध(6) एवं(7) विस्तृत(8) है(9) ।(10) 57(10) .(11) जैसे(11) आज(12) के(13)
3(1) .(2) भारत(2) का(3) इतिहास(4) काफी(5) समृद्ध(6) एवं(7) विस्तृत(8) है(9) ।(10) 57(10) .(11) जैसे(11) आज(12) के(13) झारखंड(14)
3(1) .(2) भारत(2) का(3) इतिहास(4) काफी(5) समृद्ध(6) एवं(7) विस्तृत(8) है(9) ।(10) 57(10) .(11) जैसे(11) आज(12) के(13) झारखंड(14) प्रदेश(15)
3(1) .(2) भारत(2) का(3) इतिहास(4) काफी(5) समृद्ध(6) एवं(7) विस्तृत(8) है(9) ।(10) 57(10) .(11) जैसे(11) आज(12) के(13) झारखंड(14) प्रदेश(15) से(16) ,(17)
3(1) .(2) भारत(2) का(3) इतिहास(4) काफी(5) समृद्ध(6) एवं(7) विस्तृत(8) है(9) ।(10) 57(10) .(11) जैसे(11) आज(12) के(13) झारखंड(14) प्रदेश(15) से(16) ,(17) उन(17)
3(1) .(2) भारत(2) का(3) इतिहास(4) काफी(5) समृद्ध(6) एवं(7) विस्तृत(8) है(9) ।(10) 57(10) .(11) जैसे(11) आज(12) के(13) झारखंड(14) प्रदेश(15) से(16) ,(17) उन(17) दिनों(18) ,(19)
3(1) .(2) भारत(2) का(3) इतिहास(4) काफी(5) समृद्ध(6) एवं(7) विस्तृत(8) है(9) ।(10) 57(10) .(11) जैसे(11) आज(12) के(13) झारखंड(14) प्रदेश(15) से(16) ,(17) उन(17) दिनों(18) ,(19) बहुत(19)
3(1) .(2) भारत(2) का(3) इतिहास(4) काफी(5) समृद्ध(6) एवं(7) विस्तृत(8) है(9) ।(10) 57(10) .(11) जैसे(11) आज(12) के(13) झारखंड(14) प्रदेश(15) से(16) ,(17) उन(17) दिनों(18) ,(19) बहुत(19) से(20)
3(1) .(2) भारत(2) का(3) इतिहास(4) काफी(5) समृद्ध(6) एवं(7) विस्तृत(8) है(9) ।(10) 57(10) .(11) जैसे(11) आज(12) के(13) झारखंड(14) प्रदेश(15) से(16) ,(17) उन(17) दिनों(18) ,(19) बहुत(19) से(20) लोग(21)
3(1) .(2) भारत(2) का(3) इतिहास(4) काफी(5) समृद्ध(6) एवं(7) विस्तृत(8) है(9) ।(10) 57(10) .(11) जैसे(11) आज(12) के(13) झारखंड(14) प्रदेश(15) से(16) ,(17) उन(17) दिनों(18) ,(19) बहुत(19) से(20) लोग(21) चाय(22)
3(1) .(2) भारत(2) का(3) इतिहास(4) काफी(5) समृद्ध(6) एवं(7) विस्तृत(8) है(9) ।(10) 57(10) .(11) जैसे(11) आज(12) के(13) झारखंड(14) प्रदेश(15) से(16) ,(17) उन(17) दिनों(18) ,(19) बहुत(19) से(20) लोग(21) चाय(22) बागानों(23)
3(1) .(2) भारत(2) का(3) इतिहास(4) काफी(5) समृद्ध(6) एवं(7) विस्तृत(8) है(9) ।(10) 57(10) .(11) जैसे(11) आज(12) के(13) झारखंड(14) प्रदेश(15) से(16) ,(17) उन(17) दिनों(18) ,(19) बहुत(19) से(20) लोग(21) चाय(22) बागानों(23) में(24)
3(1) .(2) भारत(2) का(3) इतिहास(4) काफी(5) समृद्ध(6) एवं(7) विस्तृत(8) है(9) ।(10) 57(10) .(11) जैसे(11) आज(12) के(13) झारखंड(14) प्रदेश(15) से(16) ,(17) उन(17) दिनों(18) ,(19) बहुत(19) से(20) लोग(21) चाय(22) बागानों(23) में(24) मजदूरी(25)
3(1) .(2) भारत(2) का(3) इतिहास(4) काफी(5) समृद्ध(6) एवं(7) विस्तृत(8) है(9) ।(10) 57(10) .(11) जैसे(11) आज(12) के(13) झारखंड(14) प्रदेश(15) से(16) ,(17) उन(17) दिनों(18) ,(19) बहुत(19) से(20) लोग(21) चाय(22) बागानों(23) में(24) मजदूरी(25) करने(26)
3(1) .(2) भारत(2) का(3) इतिहास(4) काफी(5) समृद्ध(6) एवं(7) विस्तृत(8) है(9) ।(10) 57(10) .(11) जैसे(11) आज(12) के(13) झारखंड(14) प्रदेश(15) से(16) ,(17) उन(17) दिनों(18) ,(19) बहुत(19) से(20) लोग(21) चाय(22) बागानों(23) में(24) मजदूरी(25) करने(26) के(27)
3(1) .(2) भारत(2) का(3) इतिहास(4) काफी(5) समृद्ध(6) एवं(7) विस्तृत(8) है(9) ।(10) 57(10) .(11) जैसे(11) आज(12) के(13) झारखंड(14) प्रदेश(15) से(16) ,(17) उन(17) दिनों(18) ,(19) बहुत(19) से(20) लोग(21) चाय(22) बागानों(23) में(24) मजदूरी(25) करने(26) के(27) उद्देश्य(28)
3(1) .(2) भारत(2) का(3) इतिहास(4) काफी(5) समृद्ध(6) एवं(7) विस्तृत(8) है(9) ।(10) 57(10) .(11) जैसे(11) आज(12) के(13) झारखंड(14) प्रदेश(15) से(16) ,(17) उन(17) दिनों(18) ,(19) बहुत(19) से(20) लोग(21) चाय(22) बागानों(23) में(24) मजदूरी(25) करने(26) के(27) उद्देश्य(28) से(29)
3(1) .(2) भारत(2) का(3) इतिहास(4) काफी(5) समृद्ध(6) एवं(7) विस्तृत(8) है(9) ।(10) 57(10) .(11) जैसे(11) आज(12) के(13) झारखंड(14) प्रदेश(15) से(16) ,(17) उन(17) दिनों(18) ,(19) बहुत(19) से(20) लोग(21) चाय(22) बागानों(23) में(24) मजदूरी(25) करने(26) के(27) उद्देश्य(28) से(29) असम(30)
3(1) .(2) भारत(2) का(3) इतिहास(4) काफी(5) समृद्ध(6) एवं(7) विस्तृत(8) है(9) ।(10) 57(10) .(11) जैसे(11) आज(12) के(13) झारखंड(14) प्रदेश(15) से(16) ,(17) उन(17) दिनों(18) ,(19) बहुत(19) से(20) लोग(21) चाय(22) बागानों(23) में(24) मजदूरी(25) करने(26) के(27) उद्देश्य(28) से(29) असम(30) आए(31) ।(32)
I have tried to modify the above code so that the counter detects a new line and reinitializes the word positions to start from 1 for every new line, I also need to make sure that no word positions is displayed for the serial nos.
My modified code is not 100% correct could you please help me correct it to get the desired output:
Modified code looks like this:
#!/usr/bin/python
# -*- coding: UTF-8 -*-
# encoding: utf-8
import fileinput
list1 = []
separators = [u'।', ',', '.']
chknwlin = ['
']
text = open("hinstest1.txt").read()
output_file = ("ophwp1.txt")
#This converts the encoded text to an internal unicode object, where
# all characters are properly recognized as an entity:
text = text.decode("UTF-8")
#this breaks the text on the white spaces, yielding a list of words:
words = text.split()
counter = 1
output = ""
#if the last char is a separator, and is joined to the word:
for line in words:
for word in line:
for ch in line:
if word[-1] in separators and len(word) > 1:
#word up to the second to last char:
output += word[:-1] + u'(%d) ' % counter
counter += 1
#last char
output += word[-1] +u'(%d) ' % counter
else :
output += word + u'(%d) ' % counter
counter += 1
# if ch is '
':
if ch in chknwlin:
#for ch in words:
print output
counter = 1
list1.append(output)
#words.close()
f1=open(output_file,'w')
f1.write(' '.join(list1))
f1.close()
I finally want the output to look like this:
3. भारत(1) का(2) इतिहास(3) काफी(4) समृद्ध(5) एवं(6) विस्तृत(7) है(8) ।(9)
57. जैसे(1) आज(2) के(3) झारखंड(4) प्रदेश(5) से(6) ,(7) उन(8) दिनों(9) ,(10) बहुत(11) से(12) लोग(13) चाय(14) बागानों(15) में(16) मजदूरी(17) करने(18) के(19) उद्देश्य(20) से(21) असम(22) आए(23) ।(24)
The modified code is not giving me any output on the console and is also copying nothing to the output file.
| 0
| 1
| 0
| 0
| 0
| 0
|
I'm implementing the scrolling behaviour of a touch screen UI but I'm too tired in the moment to wrap my mind around some supposedly trivial piece of math:
y (distance/velocity)
|********
| ******
| ****
| ***
| ***
| **
| **
| *
| *
-------------------------------- x (time)
f(x)->?
The UI is supposed to allow the user to drag and "throw" a view in any direction and to keep it scrolling for a while even after he releases the finger from the screen. It's sort of having a momentum that depends on how fast the user was dragging before he took off the finger.
So I have a starting velocity (v0) and every 20ms I scroll by a amount relative to the current velocity. With every scrolling iteration I lower the velocity a bit until it falls below a threshold when I stop it. It just doesn't look right when I decrement it by a fixed amount (linear), so I need to model a negative acceleration but fail to come up with a decent simple formula how to calculate the amount by which I have to lower the velocity in every iteration.
Update:
Thank you for your responses so far but I still didn't manage to derive a satisfying function from the feedback yet. I probably didn't describe the desired solution good enough, so I'll try to give a real world example that should illustrate what kind of calculation I would like to do:
Assume there is a certain car driving on a certain street and the driver hits the brakes to a max until the car comes to a halt. The driver does this with the same car on the same street multiple times but begins to brake at varying velocities. While the car is slowing down I want to be able to calculate the velocity it will have exactly one second later solely based on it's current velocity. For this calculation it should not matter at which speed the car was driving when the driver began to break since all environmential factors remain the same. Of course there will be some constants in the formula but when the car is down to i.e. 30 m/s it will go the same distance in the next second, regardless whether it was driving 100 or 50 m/s when the driver began to break. So the time since hitting the breaks would also not be a parameter of the function. The deceleration at a certain velocity would always be the same.
How do you calculate the velocity one second later in such a situation assuming some arbitrary constants for deceleration, mass, friction or whatever and ignoring complicating influences like air resistance? I'm only after the kinetic energy and the it's dissipation due to the friction from breaking the car.
Update 2
I see now that the acceleration of the car would be liniear and this is actually not what I was looking for. I'll clean this up and try out the new suggestions tomorrow. Thank you for your input so far.
| 0
| 0
| 0
| 0
| 1
| 0
|
I'm looking for a good open source POS Tagger in Java. Here's what I have come up with so far.
LingPipe
Stanford
LBJ
FastTag
Anybody got any recommendations?
| 0
| 1
| 0
| 0
| 0
| 0
|
I have a little problem. I've recently created an algorithm to allow thick lines to be drawed onscreen (as a quad structure), the problem is that when the line is very long and diagonal the aliasing is very high, making the line look very bad.
What are my chance to reduce the aliasing while trying to have high performance?
I'm using (as the tags says) DirectX as graphics API.
| 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.