text
stringlengths 0
27.6k
| python
int64 0
1
| DeepLearning or NLP
int64 0
1
| Other
int64 0
1
| Machine Learning
int64 0
1
| Mathematics
int64 0
1
| Trash
int64 0
1
|
|---|---|---|---|---|---|---|
I have a image with horizontal and vertical lines. In fact, this image is the BBC website converted to horizontal and vertical lines.
My problem is that I want to be able to find all the rectangles in the image. I want to write a computer program to find all the rectangles.
Does anyone know how to do this or suggest ideas on how to get started? This task is easy for me as a person to find the visual rectangles, but I am not sure how to describe it as a program.
Image is the BBC website here http://www.bbc.co.uk/
Update to this, I wrote the code which converts the BBC website image to the horizontal and vertical line, the problem is these lines do not completely meet at the corners and sometimes they do not completely form a rectangle. Thanks!
| 0
| 1
| 0
| 1
| 0
| 0
|
clock http://img710.imageshack.us/img710/2623/circlock.jpg
I do not know how to determine the top of the needle of the clock. If you determine the coordinates of them, I can think of the time of the clock.
Please help me solve this problem. Thank you very much!
| 0
| 0
| 0
| 0
| 1
| 0
|
Can anyone point me to a library or module with a decent integer relation implementation (most likely PSLQ)?
My target platform is .NET (C#), but if there's source code in C/C++, Java, whatever, even a semi-comprehensible algorithm, that would help me a lot. All I was able to find on Google was some unreadable Mathematica code.
I was able to find an algorithm here, and I suppose given several weeks I might be able to muddle through it, but there's got to be somebody out there who's already tackled this problem, given that the algorithm's been the de facto standard for almost 20 years.
Alternatively, if anyone knows of any simpler algorithms I could use, that might help too. The precision does not have to be ridiculously high and speed is a more important concern than accuracy; I'm half-considering the crudest approach of multiplying by some factor of 10 and looking for an integral GCD, but I don't want to go there until I'm sure I've exhausted any better options.
Thanks in advance.
| 0
| 0
| 0
| 0
| 1
| 0
|
ok, I'm writing a little code snippet to get the ISO date-format value for yesterday.
code:
var dateString = new Date();
var yesterday = dateString.getFullYear();
yesterday += "-"+dateString.getMonth()+1;
yesterday += "-"+dateString.getDate()-1;
The above code outputs 2009-111-23. It is clearly not treating dateString.getMonth() as an intiger and tacking 1 on to the end of it.
Does putting the "-"+ in front of dateString.getDate() cast getDate() into a string?
this works gets the desired result.
var dateString = new Date();
var yesterday = dateString.getFullYear() + "-";
yesterday += dateString.getMonth()+1+ "-";
yesterday += dateString.getDate()-1;
//yesterday = 2009-12-22
Although I don't really like the way it looks... whatever no big deal.
Can anyone explain to me why javascript acts like this? is there any explanation for why this happens?
| 0
| 0
| 0
| 0
| 1
| 0
|
Im facing a scenario where in ill have to compute some huge math expressions. The expressions in themselves are simple, ie have just the conventional BODMAS fundamental but the numbers that occur as operands are very large, to the tune of 1000 digit numbers. I do know of the BigInteger class of the java.math module but am looking for a different way so that the computation can occur also in a speedy manner. Im a guy still finding his feet in Java, so any pointers or advice in gthis regard would be of great help.
Regards
p1nG
| 0
| 0
| 0
| 0
| 1
| 0
|
There is a Table of pairs , which defines pieces bounds.
And we are using straightforward algorithm:
y = f(x)
Calculate index n in Table using x
Get Yn and Yn+1, compute linear interpolation Y
Y is the answer.
So i think, there must be more efficient method, could you please point me?
| 0
| 0
| 0
| 0
| 1
| 0
|
I have this class:
public class Fibonacci
{
public static int Calculate( int x )
{
if (x <= 0)
{
return 0;
}
else
{
return Calculate(x - 1) + Calculate(x - 2);
}
}
}
Per a tutorial I'm doing if one inputs 6 one should get 8 as an expected result, but when I run it, it always returns 0. It's recursive so it makes sense to me, but how do they get 8 as an expected result?
| 0
| 0
| 0
| 0
| 1
| 0
|
Is there an easy markup language for math equations?
I am developing an application for undergrads and I was looking for something less complex than LaTex and easier to write than MathML.
| 0
| 0
| 0
| 0
| 1
| 0
|
Reading a book on algorithms. Can someone explain the meaning of the mathematical symbol ∃?
| 0
| 0
| 0
| 0
| 1
| 0
|
I have a calculation which isn't working and I cannot work out why!
int numHoursInWeek;
int numDays;
int averageSalary;
int total_seconds_in_year = ((numHoursInWeek * 60 * 60) * numDays);
NSLog(@"average sal in pence=%i", (averageSalary * 100));
NSLog(@"num seconds in year=%i", total_seconds_in_year);
NSLog(@"cost per second=%i", ((averageSalary * 100) / total_seconds_in_year));
int cost_per_person_per_second = ((averageSalary*100) / total_seconds_in_year);
costPerSecond = (cost_per_person_per_second * numPeople);
lblCostPerPerson.text = [NSString stringWithFormat:@"%.2f",cost_per_person_per_second];
the above returns the following in NSLog
average sal in pence=3400000
num seconds in year=31968000
cost per second=-1.991753
I know everything else is being set correctly (numDays, averageSalary for example).
When I do the calc manually, I get 0.1063. So that should show on my label?? (cost per person per second).
any ideas? should I be using floats instead of ints for the variables?
| 0
| 0
| 0
| 0
| 1
| 0
|
HI,
I want to customize the WMD editor (or wmd-new) to convert TeX equations like $\frac{2}{3}$ to Google Charts API images ()
Is it possible to customize how the HTML is generated?
| 0
| 0
| 0
| 0
| 1
| 0
|
I saw the help in Matlab, but they have provided an example without explaining how to use the parameters in the 'classregtree' function. Any help to explain the use of 'classregtree' with its parameters will be appreciated.
| 0
| 0
| 0
| 1
| 0
| 0
|
How to find solution to overdetermined systems in Macsyma, Scilab, Octave?
| 0
| 0
| 0
| 0
| 1
| 0
|
I have a gray-scale image and I want to make a function that
closely follows the image
is always grater than it the image
smooth at some given scale.
In other words I want a smooth function that approximates the maximum of another function in the local region while over estimating the that function at all points.
Any ideas?
My first pass at this amounted to picking the "high spots" (by comparing the image to a least-squares fit of a high order 2-D polynomial) and matching a 2-D polynomial to them and their slopes. As the first fit required more working space than I had address space, I think it's not going to work and I'm going to have to come up with something else...
What I did
My end target was to do a smooth adjustment on an image so that each local region uses the full range of values. The key realization was that an "almost perfect" function would do just fine for me.
The following procedure (that never has the max function explicitly) is what I ended up with:
Find the local mean and standard deviation at each point using a "blur" like function.
offset the image to get a zero mean. (image -= mean;)
divide each pixel by its stdev. (image /= stdev;)
the most image should now be in [-1,1] (oddly enough most of my test images have better than 99% in that range rather than the 67% that would be expected)
find the standard deviation of the whole image.
map some span +/- n*sigma to your output range.
With a little manipulation, that can be converted to find the Max function I was asking about.
| 0
| 0
| 0
| 0
| 1
| 0
|
I am trying to find references about different designs of metamorphic generators can someone point me to the right direction. I have gone through some papers in ACM but couldn't find what I am looking for.
| 0
| 1
| 0
| 0
| 0
| 0
|
Given three 3D points (A,B, & C) how do I calculate the normal vector? The three points define a plane and I want the vector perpendicular to this plane.
Can I get sample C# code that demonstrates this?
| 0
| 0
| 0
| 0
| 1
| 0
|
I have been working for two years in software industry. Some things that have puzzled me are as follows:
There is lack of application of mathematics in current software industry.
e.g.: When a mechanical engineer designs an electricity pole , he computes the stress on the foundation by using stress analysis techniques(read mathematical equations) to determine exactly what kind and what grade of steel should be used, but when a software developer deploys a web server application he just guesses on the estimated load on his server and leaves the rest on luck and god, there is nothing that he can use to simulate mathematically to answer his problem (my observation).
Great softwares (wind tunnel simulators etc) and computing programs(like matlab etc) are there to simulate real world problems (because they have their mathematical equations) but we in software industry still are clueless about how much actual resources in terms of memory , computing resources, clock speed , RAM etc would be needed when our server side application would actually be deployed. we just keep on guessing about the solution and solve such problem's by more or less 'hit and trial' (my observation).
Programming is done on API's, whether in c, C#, java etc. We are never able to exactly check the complexity of our code and hence efficiency because somewhere we are using an abstraction written by someone else whose source code we either don't have or we didn't have the time to check it.
e.g. If I write a simple client server app in C# or java, I am never able to calculate beforehand how much the efficiency and complexity of this code is going to be or what would be the minimum this whole client server app will require (my observation).
Load balancing and scalability analysis are just too vague and are merely solved by adding more nodes if requests on the server are increasing (my observation).
Please post answers to any of my above puzzling observations.
Please post relevant references also.
I would be happy if someone proves me wrong and shows the right way.
Thanks in advance
Ashish
| 0
| 0
| 0
| 0
| 1
| 0
|
I am trying to solve a problem which I have reduced down to counting the number of integer solutions to a number of linear inequalities. I need to be able to count the number of solutions for any number of variables c_1, ..., c_n, but for n=3 the equations could be written as:
The equations. http://silicon.appspot.com/readdoc?id=155604
Now, I know the values of n and r in advance and wish to find the number of (c_1, ..., c_n) solutions that exist.
Can this be done efficiently (faster than enumerating the solutions)? (If so: how?; if not: why?)
| 0
| 0
| 0
| 0
| 1
| 0
|
Consider you have a set of objects X (e.g., A, B, C, D) that you wish to divide into non-empty subsets that cover all of X. Mathematically, a partition of the set.
So, at first you might treat them as all different, {{A}, {B}, {C}, {D}}. Alternatively, you could separate them into vowels and consonants, i.e. {{A}, {B,C,D}}. Or, arbitrarily, {{A,D}, {B,C}}.
Is there a standard user interface widget/concept/paradigm/pattern that supports this? Having two list boxes with Add ->, Add All ->, <- Remove, and <-- Remove All to switch between them (i.e. a list builder) works for only 2 subsets, but doesn't work for an arbitrary k number of subsets.
| 0
| 0
| 0
| 0
| 1
| 0
|
I need to implement a bit of AI to figure out how to hit a target with projectile motion.
I found this over at wikipedia:
Angle required to hit coordinate
Which looks like just the thing I need, especially since I have the added problem launching the projectile from above zero height. However, my maths skills aren't great so it all looks like complete nonsense to me and I have no idea how to translate any of it into code.
If anyone can break this down into something I can understand with basic operators (+ - * %) and functions (sin, cos, sqrt etc.), I'd really appreciate it.
| 0
| 1
| 0
| 0
| 0
| 0
|
I have a 3D surface ( such as a cone). It is projected to a 2D plan in the form of contour, meaning that different Z will have different lines on 2D plan. The problem is from the contour, how to recover the 3D surface by using interpolation? We only know about the z difference between different contor lines.
| 0
| 0
| 0
| 0
| 1
| 0
|
I have a set of 5 values from experiment, E1, ..., E5 and results from 10000 different simulations, sim_A_B_C.out . From each simulation I get S1, ..., S5 .
I want to study the correlation between experimental and simulated values. So I would like to perform linear regression for each set in a script that loops for the whole set of 10000 result files.
What is the best way of performing linear regression in bash or python? I used to do it with sigmaplot but it is not so good for so big set of data
| 0
| 0
| 0
| 0
| 1
| 0
|
I am writing a program to try to solve a math problem. I need to generate a unique list of all of the numbers that add up to another number. For example, all of the unqiue combinations of 4 numbers that add up to 5 are:
5 0 0 0
4 1 0 0
3 2 0 0
3 1 1 0
2 2 1 0
2 1 1 1
This is easy to brute force in perl but I am working in C and would like to find a more elegant solution.
In perl I would generate every possible combination of numbers 0-N in each column, discard the ones that don't add up to the target number, then sort the numbers in each row and remove the duplicate rows.
I've been trying all morning to write this in C but can't seem to come up with a satisfactory solution. I need it to work up to a maximum N of about 25. Do you guys have any ideas?
Here is an example of the kind of thing I have been trying (this produces duplicate combinations):
// target is the number each row should sum to.
// Don't worry about overflows, I am only using small values for target
void example(int target)
{
int row[4];
for (int a=target; a>=0; a--) {
row[0] = a;
for (int b=target-a; b>=0; b--) {
row[1] = b;
for (int c=target-(a+b); c>=0; c--) {
row[2] = c;
row[3] = target-(a+b+c);
printf ("%2d %2d %2d %2d sum: %d
", row[0],row[1],row[2],row[3],
row[0]+row[1]+row[2]+row[3]);
}
}
}
}
| 0
| 0
| 0
| 0
| 1
| 0
|
I have a string that looks like this:
"0.4794255386042030002732879352156"
which is approximately the sin(0.5). I would like to format the string to look a much nicer
"4.794255386042e-1"
How can I achieve this? Remember I am dealing with strings and not numbers (float, double). Also I need to round to keep the number as accurate as possible, I can't just truncate. If I need to convert to a different data type I would prefer a long double because a regular double doesn't have enough precision. I'd like at least 12 decimal digits before rounding. Perhaps there is a simple sprintf() conversion I could do.
| 0
| 0
| 0
| 0
| 1
| 0
|
I have a function,
P(x0, x1, ..., xn)
that takes 100 integers as input and gives as output an integer. P is a slow function to evaluate(it can range from 30 seconds to a couple of minutes).
I need to know which values of points will maximize the yielded value from P.
What techniques can I use to accomplish this? I know generally people use genetic algorithms for this, but I'm afraid it will take ages to compute it with them, as even with a small population and few generations (let's say, population = 50, generations = 50), P is so slow it will take more than 40 hours to compute it.
Is there any cheaper method of doing it? Maybe an iterative process? I don't need it to be really optimal, but I don't have any ideia of how it behaves (I've tried linear / quadratic / exponential but it doesn't seem to yield any good values. I know P can return values at least 5-10 times better than what I'm getting).
It should be something that's easier to implement (i.e., I must implement it myself).
Thanks
edit: P is a stochastic process.
| 0
| 0
| 0
| 0
| 1
| 0
|
In the XKCD comic 195 a design for a map of the Internet address space is suggested using a Hilbert curve so that items from a similar IP adresses will be clustered together.
Given an IP address, how would I calculate its 2D coordinates (in the range zero to one) on such a map?
| 0
| 0
| 0
| 0
| 1
| 0
|
A small (3x3, 4x4) tic-tac-toe can be easily solved by considering all the cases. But for example, you have a 30x30 tic-tac-toe. What algorithm would you use to decide the next best move in that case?
Minimax + alpha-beta pruning is one way that I know.
Is there some other way that is more efficient/not more efficient but cooler?
I know it would not be a very interesting game to play. I said 30x30 just to ask what I wanted to i.e. which algorithms work best at these sort of games where the number of cases to consider for a perfect solution is very very high and thus not feasible.
| 0
| 1
| 0
| 0
| 0
| 0
|
I don't have much experience in machine learning, pattern recognition, data mining, etc. and in their underlying theory and systems.
I would like to develop an artificial model of the time it takes a human to make a move in a given Sudoku puzzle.
So what I'm looking for as an output from the machine learning process is a model that can give predictions on how long does it take for a target human to make a move in a given Sudoku situation.
Same input doesn't always map to same outcome. It takes different times for the human to make a move with the same situation, but my hypothesis is that there's a tendency in the resulting probability distribution. (My educated guess is that it is ~normal.)
I have ideas about the factors that influence the distribution (like #empty slots) but would preferably leave it to the system to figure these patterns out. Please notice, that I'm not interested in the patterns, just the model.
I can generate sample and test data easily by running sudoku puzzles and measuring the times it takes to make the moves.
What kind of learning algorithm would you suggest to use for this?
I was thinking NNs, but I'm not sure if they can have the desired property of giving weighted random outcomes for the same input.
| 0
| 0
| 0
| 1
| 0
| 0
|
After extensive research and fun learning about Google's mapping api, I am building a digital antenna map application. At this point, the next step in the project plan is to build a memory-map replication of the google map that is locating digital tv stations based upon input from the user's address. So, I am using this math code to formulate the bearing of the center of the google map and a lat/lng point from the database result set.
My question is: How can I complete the math to show the bearing in degrees?
this code is the math that returns the following array result set:
1.21
1.10
1.10
1.10
1.10
2.62
-0.29
-1.17
0.12
3.04
var y = Math.sin(longitude-center.lng()) * Math.cos(latitude);
var x = Math.cos(center.lat())*Math.sin(latitude) - Math.sin(center.lat())*Math.cos(latitude)*Math.cos(longitude-center.lng());
var bearing = (Math.atan2(y, x)).toFixed(2);
There seems to something missing in my calculations. The db table is holding the longitude values as a negative number to represent the upper western quadrant of the globe.
Any suggestions to complete my math would save a million nuerons, I've already burned a trillion.
Taking the degrees to radian suggestion, I've modified the javascript code:
var radLat1 = center.lat() * Math.PI / 180;
var radLat2 = latitude * Math.PI / 180;
var radLng1 = center.lng() * Math.PI / 180;
var radLng2 = longitude * Math.PI / 180;
var y = Math.sin(radLng2- radLng1) * Math.cos(radLng2);
var x = Math.cos(radLat1)*Math.sin(radLat2) - Math.sin(radLat1)*Math.cos(radLat2)*Math.cos(radLng2-radLng1);
var bearing = (Math.atan2(y, x)).toFixed(2);
url to testing project site: click here
the div at the bottom of the page is a result set returned from 2 arrays, the first holding the distance and second holding the bearing measurement.
| 0
| 0
| 0
| 0
| 1
| 0
|
I'm using long double in a C program to compute 2D images of the Mandelbrot Set but wish to have further precision to zoom deeper.
Are there any performance gains to be had from an arbitrary precision maths library that can restrict the amount of precision as required, rather than leaping from long double precision straight into arbitrary precision?
Which is the fastest of the arbitrary precision maths libraries?
| 0
| 0
| 0
| 0
| 1
| 0
|
If I apply Binet Formula and Recursive formula for finding the fibonaci series, there is a discrepancy in result. Why?
Basically I am a student and it's our assignment to implement the fibonacci series. So while making the experiment I came across this situation.
Thanks in advance
| 0
| 0
| 0
| 0
| 1
| 0
|
What would be an intelligent way to store text, so that it can be intelligently parsed and translated later on.
For example, The employee is outstanding as he can identify his own strengths and weaknesses and is comfortable with himself.
The above could be the generic text which is shown to the user prior to evaluation. If the user is a Male (say Shaun) or female (say Mary), the above text should be translated as follows.
Mary is outstanding as she can identify her own strengths and weaknesses and is comfortable with herself.
Shaun is outstanding as he can identify his own strengths and weaknesses and is comfortable with himself.
How do we store the evaluation criteria in the first place with appropriate place or token holders. (In the above case employee should be translated to employee name and based on his gender the words he or she, himself or herself needs to be translated)
Is there a mechanism to automatically translate the text with the above information.
| 0
| 1
| 0
| 0
| 0
| 0
|
I am trying to understand the method transition that falls in the Matrix Class. I am using it to copy pieces of a bitMapData. But I need to better understand what transitions do.
I have a tilesheet that has 3 images on it. all 30x30 pixels. the width of the total bitmap is 90pxs.
The first tile is green, the second is brown, and the third is yellow. If I move over 30pxs using the matrix that transitions, instead of getting brown, I get yellow, if I move over 60px, I get brown.
If I move -30 pixels, then the order is correct. I am confused on what is going on.
tileNum -= (tileNumber * tWidth);
theMatrix = new Matrix();
theMatrix.translate(tileNum,0);
this.graphics.beginBitmapFill(tileImage,theMatrix);
this.graphics.drawRect(0, 0,tWidth ,tHeight );
this.graphics.endFill();
Can someone tell me how transitions work, or some resources that show how they work. I ultimately want to know a good way to switch back and forth between each tile.
| 0
| 0
| 0
| 0
| 1
| 0
|
How can I find the distance between 2 System.Drawing.Point?
I googled and didn't find it...
Dim p1 As New Point(0, 10)
Dim p2 As New Point(10, 10)
Dim distance = ??
In this case, it should be 10, but what about here?
Dim p1 As New Point(124, 942)
Dim p2 As New Point(34, 772)
Dim distance = ??
Thanks!
| 0
| 0
| 0
| 0
| 1
| 0
|
i want to do arithmetic operation on jsp . I am using struts tag lib tag
following is the code :
<s:set name="value1" value ="%{0.0}" />
<s:set name="value2" value ="%{0.0}" />
<s:set name="percent" value ="%{0.0}" />
<s:iterator>
<s:set name="value1" value ="%{#value1+ someIntegerValue1}" />
<s:set name="value2" value ="%{#value2+ someIntegerValue2}" />
</s:iterator>
<s:set name="percent" value ="%{(#value1*100.0)/#value2}" />
<fmt:formatNumber type="number" maxFractionDigits="2" minFractionDigits="2" value="${percent}" />
now the last line always rounds to integer value
like if value1 = 3 , value2 = 31 . then percent should be equal to (3*100)/31 = 9.68
BUT the damn thing outputs to 9.00
<s:set name="percent" value ="%{(3*100.0)/31.0}" />
<fmt:formatNumber type="number" maxFractionDigits="2" minFractionDigits="2" value="${percent}" />
then it outputs correctly 9.68 :S
can anyone please help ??
Now when i hardcode this expression
I have been banging my head on this for a long time, googling for more than 2-3 hours didnt get me anything .
| 0
| 0
| 0
| 0
| 1
| 0
|
differencePercentage = Math.round(((Pay.init / Pay.current) * 100) - 100);
and that gives me the difference in percent between initial and current pay, but it's reversed. When it's positive i.e. pay is above the initial value it says -X%, and when it's below it says X%.
Is there any obvious way I'm not seeing to polarize this?
Thanks for any insight. :)
| 0
| 0
| 0
| 0
| 1
| 0
|
If I have 5 Vertices in 3D coordinate space how can I determined the ordering of those Vertices. i.e clockwise or anticlockwise.
If I elaborate more on this,
I have a 3D model which consists of set of polygons. Each polygon is collection of vertices and I want to calculate the norm of the polygon surface. To calculate the norm I have to consider the vertices in counter clockwise order . My question is given set of vertices how can I determine whether it is ordered in clockwise or counter clockwise?
This is for navigation mesh generation where I want to remove the polygons which cannot be walked by the agent. To do so my approach is to calculate the surface norm(perpendicular vector of the polygon) and remove the polygon based on the angle with 2D plane. To calculate the norm I should know in which order points are arranged. So for given set of points in polygon how can I determine the order of the arrangement of points.
Ex.
polygon1 consist of Vertex1 = [-21.847065 -2.492895 19.569759], Vertex2 [-22.279873 1.588395 16.017160], Vertex3 [-17.234818 7.132950 7.453146] these 3 points and how can I determine the order of them
| 0
| 0
| 0
| 0
| 1
| 0
|
Does anyone know how to calculate the error of quantizing from 16bit to 8bit?
I have looked at the Wikipedia article about Quantization, but it doesn't explain this.
Can anyone explain how it is done?
Lots of love,
Louise
Update: My function looks like this.
unsigned char quantize(double d, double max) {
return (unsigned char)((d / max) * 255.0);
}
| 0
| 0
| 0
| 0
| 1
| 0
|
I need to write an essay or a research for the subject Artificial Intelligence. There are many possible topics I can choose from plus we are also allowed to write about any other topic of interest.
One of the topics is Semantic Web. I would like to write about use of AI algorithms in relation with Semantic Web.
Could you please suggest me some good topics from this area?
Is PageRank a good topic? Is it related enough to both Semantic Web and AI?
| 0
| 1
| 0
| 0
| 0
| 0
|
I was recently diagnosed with a cascading dissociative disorder that causes retrograde amnesia in addition to an existing case of possible anterograde amnesia. Many people have tried to remind me of how great a programmer I was before -- Right now I get the concepts and the idioms, but I want to teach myself whether I know or not. I think I can overcome the amnesia problems in part with it.
My question for you, stackoverflow, is this: I recently found Clojure and it... it feels good to use, even in just copying down the examples from whatever webpage I can find. My goals in learning a functional programming language are to create a simple webserver, an irc AI bot of some variety, and a couchdb-like database system, all of which lightweight and specifically for education. What flaws does Clojure have? Is there a better functional programming language to use right now for education /and/ application?
| 0
| 1
| 0
| 0
| 0
| 0
|
I need guidance in how I should compute the GoogleShare of several terms.
For example, take the following base terms:
"Tom Cruise" = 12,000,000 pages
"John Travolta" = 4,900,000 pages
Now if we add a second term:
"Tom Cruise" + "Scientology" = 784,000 pages
"John Travolta" + "Scientology" = 331,000 pages
So the GoogleShare for Tom Cruise and Scientology is (784000 * 100 / 12000000) = 6.53%, while the GoogleShare for John Travolta and Scientology is (331000 * 100 / 4900000) = 6.76%.
Now if we add a third term to our query:
"Tom Cruise" + "Scientology" + "StackOverflow" = 100 pages
"John Travolta" + "Scientology" + "StackOverflow" = 181 pages
How should I compute the GoogleShare percentage now?
// Tom Cruise
100 * 100 / 784000 = 0.01% // StackOverflow / Scientology
// or...
100 * 100 / 12000000 = 0.00083% // StackOverflow / Tom Cruise
// John Travolta
181 * 100 / 331000 = 0.05% // StackOverflow / Scientology
// or...
181 * 100 / 4900000 = 0.00369% // StackOverflow / John Travolta
John Travolta seems to be 5 times more Scientologist than Tom Cruise inside the SO community.
What is the correct way to compute the GoogleShare of N terms?
| 0
| 0
| 0
| 0
| 1
| 0
|
I searched, can't find anything: How do I do this?
I enter $x = 'tlagre';
I want it to return every single letter combination, down to four.
i.e. - "tlagr" "gratl" "lat" "rat"
I've found some that can do this but none will do every number of letters (they all just do the exact same # of letters as given in $x
| 0
| 0
| 0
| 0
| 1
| 0
|
I am still a beginner but I want to write a character-recognition-program. This program isn't ready yet. And I edited a lot, therefor the comments may not match exactly. I will use the 8-connectivity for the connected component labeling.
from PIL import Image
import numpy as np
im = Image.open("D:\\Python26\\PYTHON-PROGRAMME\\bild_schrift.jpg")
w,h = im.size
w = int(w)
h = int(h)
#2D-Array for area
area = []
for x in range(w):
area.append([])
for y in range(h):
area[x].append(2) #number 0 is white, number 1 is black
#2D-Array for letter
letter = []
for x in range(50):
letter.append([])
for y in range(50):
letter[x].append(0)
#2D-Array for label
label = []
for x in range(50):
label.append([])
for y in range(50):
label[x].append(0)
#image to number conversion
pix = im.load()
threshold = 200
for x in range(w):
for y in range(h):
aaa = pix[x, y]
bbb = aaa[0] + aaa[1] + aaa[2] #total value
if bbb<=threshold:
area[x][y] = 1
if bbb>threshold:
area[x][y] = 0
np.set_printoptions(threshold='nan', linewidth=10)
#matrix transponation
ccc = np.array(area)
area = ccc.T #better solution?
#find all black pixel and set temporary label numbers
i=1
for x in range(40): # width (later)
for y in range(40): # heigth (later)
if area[x][y]==1:
letter[x][y]=1
label[x][y]=i
i += 1
#connected components labeling
for x in range(40): # width (later)
for y in range(40): # heigth (later)
if area[x][y]==1:
label[x][y]=i
#if pixel has neighbour:
if area[x][y+1]==1:
#pixel and neighbour get the lowest label
pass # tomorrows work
if area[x+1][y]==1:
#pixel and neighbour get the lowest label
pass # tomorrows work
#should i also compare pixel and left neighbour?
#find width of the letter
#find height of the letter
#find the middle of the letter
#middle = [width/2][height/2] #?
#divide letter into 30 parts --> 5 x 6 array
#model letter
#letter A-Z, a-z, 0-9 (maybe more)
#compare each of the 30 parts of the letter with all model letters
#make a weighting
#print(letter)
im.save("D:\\Python26\\PYTHON-PROGRAMME\\bild2.jpg")
print('done')
| 0
| 1
| 0
| 0
| 0
| 0
|
When I was in high school and learning about matrices, we were shown a technique that would help in a situation like this:
There are a number of chess players in a league, and they need to determine a ranking for all of them, but don't have enough time for every player to play every other person. If it ends up that Player A beats Player B, and Player B beats Player C, you can say with some level of certainty that Player A is better than Player C and therefore award some points to player A in lieu of them actually playing each other.
As I said, this was a little while ago and I can't remember how to actually perform the algorithm, but I think it was called something like a "domination matrix". Searching the web for that has been fruitless and scary at times, so I don't think that's right.
Can anyone give me some help? Ideally an algorithm I can use for this program I'm working on, but even just a pointer to some more information about the procedure.
| 0
| 0
| 0
| 0
| 1
| 0
|
I would like to plot the "greasy" test signal in Matlab, and then plot a Gauss function in the same plot. The script below does that.
But I would like to be able to place the Gauss function at a certain position, so I see that others often use CIRCSHIFT to move plots.
When I use it I can move the Gauss function to the left or right, but not up and down.
PGAUSS used in the script comes from the LTFAT DSP third party toolbox, but it could for debugging be any function. E.g. -x^2.
Can someone figure out, what I am doing wrong?
Here is how it looks with [0 0]
alt text http://img268.imageshack.us/img268/1130/66837635.png
Here is how it looks with [0 111]
alt text http://img684.imageshack.us/img684/2386/0111q.png
Here is how it looks with [111 0]
alt text http://img194.imageshack.us/img194/8760/1110d.png
Lots of love,
Louise
g = greasy;
fs = 16000;
Lg = length(g);
% -2441 so just get the first 500 points
L2 = floor(Lg/2)+1 - 2441;
gf = greasy;
gf = gf(1:L2);
hold on
plot (1:L2,gf);
xlabel('Time / samples');
ylabel('Amplitude');
% Contructing values to make the plot look as desired
L = 500;
tfr = 1;
cent = 300;
%gw = pgauss(L,tfr,cent)
% Here I would have expected the Gauss function to be
% moved down, but nothing happens.
gw = circshift(pgauss(L,tfr,cent), [0 -1]);
plot(gw,'Color','red');
% Multiply the signal with the Gauss window
figure(2);
plot(gf.*gw);
| 0
| 0
| 0
| 0
| 1
| 0
|
$onethird = 1.0/3;
$fivethirds = 1.0/3+1.0/3+1.0/3+1.0/3+1.0/3;
$half = 1.0/2;
$threehalf = 1.0/2+1.0/2+1.0/2;
var_dump($onethird + $fivethirds == $half + $threehalf);
which outputs false,but as we all know:5/3+1/3=2=3/2+1/2
How to fix this problem?
| 0
| 0
| 0
| 0
| 1
| 0
|
I saw this question, which focuses on the "Brittney Spears" problem. But I have a bit of a different question. How does the algorithm determine which words or phrases need to be ranked? For instance, if I send out a tweet that says "Michael Jackson died", how does it know to pull out "Michael Jackson" but not "died"?
Or suppose that Alec Baldwin and Steven Baldwin were in the news that day and thus were both mentioned in a lot of tweets. How would it know to treat both names differently instead of just pulling out "Baldwin"?
Done naively, I could see this problem as being NP-complete (you'd have to compare all potential phrases in the tweet with all potential phrases in everyone else's tweets).
| 0
| 1
| 0
| 0
| 0
| 0
|
I have this code:
package math;
import java.io.IOException;
import java.util.Scanner;
public class Main
{
public static void main(String[] args) throws IOException
{
System.out.println("Hi, I will beat Java's Math.sqrt(double) method");
System.out.println("Both ways of calculation will be done");
System.out.println("I will time how long they took to calculate");
System.out.println("Random doubles will be generated");
System.out.println();
System.out.println("Please give the number of sqrt-calculation will be done");
int calcs = new Scanner(System.in).nextInt();
boolean output = true;
if (calcs > 10000)
{
System.out.println("You're asking much calculations");
System.out.println("Disabling output is recommend");
System.out.println("Disable output? (y/n)");
char a = (char) System.in.read();
if (a == 'y')
{
output = false;
}
}
System.out.println("Press enter to start");
System.in.read();
test(calcs, output);
System.out.println();
System.out.println("I was much faster I think");
System.out.println("Now you can check my precision");
System.out.println("Please give a complex double");
double x = Double.parseDouble(new Scanner(System.in).next());
System.out.println();
System.out.println("Math.sqrt(" + x + ") = " + Math.sqrt(x));
System.out.println("SqrtCalculator.sqrt(" + x + ") = " + sqrt(x));
System.out.println("------------------------");
System.out.println("Now please make your conclusion");
System.out.println("Thanks for trying");
}
public static void test(int calculations, boolean output)
{
double factor = Math.random() / 2;
// Math
long mathStart = System.currentTimeMillis();
for (int i = 1; i <= calculations; i++)
{
double x = i * factor;
double result = Math.sqrt(x);
if (output)
{
System.out.println("Math.sqrt(" + x + ") = " + result);
}
}
long mathStop = System.currentTimeMillis();
long mathTime = mathStop - mathStart;
// My Method
long myStart = System.currentTimeMillis();
for (int i = 1; i <= calculations; i++)
{
double x = i * factor;
double result = sqrt(x);
if (output)
{
System.out.println("SqrtCalculater.sqrt(" + x + ") = " + result);
}
}
long myStop = System.currentTimeMillis();
long myTime = myStop - myStart;
System.out.println();
if (output)
System.out.println("---------------------------");
System.out.println("Here are the results:");
System.out.println("Math and SqrtCalculator did each " + calculations + " of the same sqrt-calculations");
System.out.println();
System.out.println("Math: " + mathTime + " milliseconds");
System.out.println("I: " + myTime + " milliseconds");
}
public final static double sqrt(double x)
{
double previous = 1;
double now = 0;
for (;;)
{
now = (x / previous + previous) / 2;
if (previous == now)
{
return now;
}
previous = now;
}
}
}
This sqrt method is called "heroon".
If I run my program and I ask 80000 calculations and I disable the output, Math.sqrt() is much faster than my method. If I ask 80000 calcs and I enable the output, My method is much faster.
Can someone explain this?
Thanks
Sorry for bad English.
| 0
| 0
| 0
| 0
| 1
| 0
|
I'm trying to figure out how many possible ways there are to combine various elements form this string.
"{Hello|Hi|Hey} {world|earth}{!|.|?}"
Where one item (separated by a pipe/|) is selected at random from each group ({}) and combined into a single string.
So the above "template" could produce:
Hello world.
Hi earth?
Hey world.
Hi world?
I'm guessing this is a type of permutation, but I want to make sure I'm getting this right.
It would be really nice if this worked with "n" nested items as well.
"{{Hello|Hi|Hey} {world|earth}|{Goodbye|farewell} {noobs|n3wbz|n00blets}}"
I'd prefer a math/statistics based solution over brute-force looping to get the answer if possible.
Thanks!
| 0
| 0
| 0
| 0
| 1
| 0
|
I am currently parsing a bunch of mails and want to get words and other interesting tokens out of mails (even with spelling errors or combination of characters and letters, like "zebra21" or "customer242"). But how can I know that "0013lCnUieIquYjSuIA" and "anr5Brru2lLngOiEAVk1BTjN" are not words and not relevant? How to extract words and discard tokens that are encoding errors or parts of pgp signature or whatever else we get in mails and know that we will never be interested in those?
| 0
| 1
| 0
| 0
| 0
| 0
|
I noticed that translating radians to degrees and vice versa is like translating a percentage to a whole number and vice versa. For example, to get 60 percent of 345 you do the following
60 * 345/100
to convert 60 degrees to radians you do
60 * 3.14/180
There is a pattern there BUT... we use 100 to compare percentages to a number. So, why do we use 180 degrees instead of 360 degrees to compare degrees to radians?
%100 percent = a whole number
360 degrees represents a whole circle
using 180 degrees is like using 50% instead of 100%
I hope I am making some sense. Can anyone answer? Thanks
| 0
| 0
| 0
| 0
| 1
| 0
|
MS calculator on windows 7 has a "programmers" mode. When I type in (in binary): 1111111111111111111111111111111111111111111111111111111111111111
and then click "Dec", the binary turns into -1. When I click Oct, the value turns into
1777777777777777777777
However, whenever I use an online converter, it doesn't work. I need to know how the calculator is doing this so I can emulate it in c++.
| 0
| 0
| 0
| 0
| 1
| 0
|
I am creating a ping pong game. And I want to create the ability to control the direction of the ball based on the impact on the paddle. If the ball is coming down at vy = 4; vx = 4;
and the paddle is moving to the left at vx = -5; I want the ball to slightly change its course depending on how fast the paddle is moving. It would probably reduce the balls vx speed on collision, therefore making the ball move more straight (close to the Y axis) when it is moving back up. But before I go on a crazy trial and error journey, I was wanting to know if anyone knew the answer or probably have any sources.
I figure the solution for probably doing this would be to measure how fast the paddle is going. My problem is the paddle is controlled by the mouse and has no certain speed. I am trying to figure out how I can measure the speed of my mouse traveling on the x axis.
I am probably going to create a timer that fires every few seconds to determine where the mouse was and where it is at. figure the difference and that will be the speed
If anyone has any answers, that would be great. thanks
| 0
| 0
| 0
| 0
| 1
| 0
|
Given an array of prime factors of a natural number, how can I find the total number of divisors using LINQ upon the original array? I've already figured out most of this problem, but I'm having trouble with my LINQ statement.
Math Background:
The prime factors of a number are the prime integers that divide evenly into the number without a remainder. e.g. The prime factors of 60 are 2,2,3,5.
The divisors of a number are all integers (prime or otherwise) that divide evenly into the number without a remainder. The divisors of 60 are 1,2,3,4,5,6,10,12,15,20,30,60.
I am interested in finding the total number of divisors. The total number of divisors for 60 is 12.
Let's express the prime factorization using exponents:
60 = 2^2 * 3^1 * 5*1
To find the total number of divisors given the prime factorization of the number, all we have to do is add 1 to each exponent and then multiply those numbers together, like so:
(2 + 1) * (1 + 1) * (1 + 1) = 12;
That's how you find the number of divisors given the prime factorization of a number.
The Code I Have So Far:
I already have good code to get the prime factors of a number, so I'm not concerned about that. Using LINQ, I want to figure out what the total number of divisors is. I could use a few loops, but I'm trying to use LINQ (if possible).
I'm going to:
Use Distinct() to find the unique values in the array.
Use Count() to find how many time the unique values occur (this is equal to the exponent).
Use an Aggregate() function to multiply the values together.
Here's the code I have:
class Program
{
static void Main(string[] args)
{
var primeFactors = new int[] { 2, 2, 3, 5 };
Console.WriteLine(primeFactors.Distinct().PrintList("", ", "));
//Prints: 2, 3, 5
Console.WriteLine("[2]:{0} [3]:{1} [5]:{2}"
, primeFactors.Count(x => x == 2)
, primeFactors.Count(x => x == 3)
, primeFactors.Count(x => x == 5)
);
//Prints: [2]:2 [3]:1 [5]:1
\\THIS IS WHERE I HAVE TROUBLE:
Console.WriteLine(primeFactors.Distinct().Aggregate((total,next) =>
(primeFactors.Count(x => x ==next) + 1)* total));
//Prints: 8
Console.ReadLine();
}
}
Specifically, I'm having trouble with this part of code:
primeFactors.Distinct().Aggregate((total,next) =>
(primeFactors.Count(x => x ==next) + 1)* total)
Since the numbers in my array are not stored in the form of x^n, but rather in the form of n instances of x in the array, my thinking is to use Count() to find what n ought to be on a distinct array of x. The Aggregate function is intended to iterate through each distinct item in the array, find its Count + 1, and then multiply that by the total. The lambda expression in Count is supposed to use each distinct number as a parameter (next).
The above code should return 12, but instead it returns 8. I have trouble "stepping through" LINQ in debug mode and I can't figure out how I might better write this.
Why doesn't that portion of my code return the correct number of divisors as I expect? Is there a different (better) way to express this using LINQ?
| 0
| 0
| 0
| 0
| 1
| 0
|
I happened upon these values in my ColdFusion code but the Google calculator seems to have the same "bug" where the difference is non-zero.
416582.2850 - 411476.8100 - 5105.475 = -2.36468622461E-011
http://www.google.com/search?hl=en&rlz=1C1GGLS_enUS340US340&q=416582.2850+-+411476.8100+-+5105.475&aq=f&oq=&aqi=
JavaCast'ing these to long/float/double doesn't help- it results in other non-zero differences.
| 0
| 0
| 0
| 0
| 1
| 0
|
In mathematics the identity (1 + sqrt(2))^2 = 3 + 2*sqrt(2) holds true. But in floating point (IEEE 754, using single precision i.e. 32 bits) calculations it's not the case, as sqrt(2) doesn't have an exact representation in binary.
So does using a approximated value of sqrt(2) provide different results for left and right hand sides? If so why? Does squaring the approximated value reduce accuracy significantly?
Which of the equivalent expressions then gives the most accurate result?
| 0
| 0
| 0
| 0
| 1
| 0
|
Just curious. When I bounce a ball off the walls of the stage using the following technique.
if(y > sRef.stageHeight || y < 0)
{
yDir = yDir * -1;
}
else if ( x > sRef.stageWidth || x < 0)
{
xDir = xDir * -1;
}
x += xspeed * xDir;
y += yspeed * yDir;
The above seems fine and works well. But If I choose to use angles instead like the following...
if(y > sRef.stageHeight || y < 0)
{
angle += 45;
}
else if ( x > sRef.stageWidth || x < 0)
{
//angle = angle * -1;
angle += 45;
}
vx = Math.cos(angle * Math.PI / 180) * bSpeed;
vy = Math.sin(angle * Math.PI / 180) * bSpeed;
x += vx;
y += vy;
Not only is the ball jumpy and skippy. but after so often it begins to go either in a vertal motion y = 5; x = 0; or a horzontal motion x = 5, y = 0. And stays that way. Why is it that the first method works fine but the other method works terrible. Could it be because the Math.cos and Math.sin returns very large decimals. could someone help me out please, cause I really prefer to use the second method.
Thanks
| 0
| 0
| 0
| 0
| 1
| 0
|
I have heard of this algorithm, but is this algorithm good to use it with Bayesian Belief networks? Hugin is based on it and I'm looking for a book / article on this algorithm.
| 0
| 1
| 0
| 0
| 0
| 0
|
How would you go about creating a vector class in Delphi? I would prefer to put all math related stuff into a DLL. Should I use a record or a class implementing an interface?
Pros of record approach:
Fast and lightweight
Value type
Operator overloading
Cons of record approach:
Implementation cannot be hidden in DLL (no inheritance, so no abstract base class for the DLL interface possible)
Problems with records as properties of classes (Class.VectorProp.X := 42)
What do you think?
| 0
| 0
| 0
| 0
| 1
| 0
|
I am trying to display EXIF exposure time as a fraction of seconds but I am not getting expected result, probably a small mistake.
I have found two routines that do the calculation but both bring diffrent and wrong result.
The value I am having problem is: "0.0806451612903226" value is of type Extended.
DecimalToFractStr give me: "16129/200000" as a result,
DecToFrac gives me: "5/62" as a result
Expected result should be "1/12" since everyone is getting it (what is the trick). When I right click image in explorer and view details I get this value. How do I get it in my application? Hope someone can help me here.
Kind Regards
Roy M Klever
SOLVED!
Ok after some testing I figured it out. Using the result from DecToFrac they simply integer divide it with the result from the left side. 5 div 5 = 1 / 62 div 5 = 12 so I am left with wanted result 1 / 12.
Thank you for all your input.
Kind Regards
Roy M Klever
procedure DecimalToFract(value: double; AllowedDecimals: integer; var num, den:
integer);
var
d, i: integer;
ex: boolean;
begin
d := Trunc(power(10, AllowedDecimals));
num := Trunc(value * d);
den := d;
repeat
ex := true;
for i := 10 downto 2 do
if ((num mod i) = 0) and ((den mod i) = 0) then
begin
num := num div i;
den := den div i;
ex := false;
end;
until ex;
end;
function DecimalToFractStr(value: double): string;
var
num, den: integer;
begin
DecimalToFract(value, 6, num, den);
if den = 1 then
result := inttostr(num)
else
result := inttostr(num) + '/' + inttostr(den);
end;
function Dec2Frac(f: Double): String;
var
df: Double;
lUpperPart: Integer;
lLowerPart: Integer;
begin
lUpperPart := 1;
lLowerPart := 1;
df := lUpperPart / lLowerPart;
While (df <> f) do
begin
If (df < f) Then
lUpperPart := lUpperPart + 1
Else
begin
lLowerPart := lLowerPart + 1;
lUpperPart := Trunc(f * lLowerPart);
end;
df := lUpperPart / lLowerPart;
end;
if lLowerPart = 1 then
result := IntToStr(lUpperPart)
else
result := IntToStr(lUpperPart) + '/' + IntToStr(lLowerPart);
end;
| 0
| 0
| 0
| 0
| 1
| 0
|
Consider a Viterbi decoder on an additive model. It spends its time doing additions and comparisons. Now, consider two: one with C/C++ float as the data type, and another with int. On modern chips, would you expect int to run significantly faster than float? Or will the wonders of pipelining (and the absence of multiplication and division) make it all come out about even?
| 0
| 0
| 0
| 0
| 1
| 0
|
What will the code below be if value is 2 and counter is 11? What would $rating be?
$rating = (@round($rs[value] / $rs[counter],1)) * 10;
The complete code is below.
function getRating(){
$sql= "select * from vote";
$result=@mysql_query($sql);
$rs=@mysql_fetch_array($result);
$rating = (@round($rs[value] / $rs[counter],1)) * 10;
echo $rating;
}
| 0
| 0
| 0
| 0
| 1
| 0
|
I need a mathematical function/formula/expression to take a number as parameter and find the lowest number ending with certain digits that is larger than the parameter.
For instance, if the ending digits should be 88 these are some examples of what I want:
f(0) = 0
f(87) = 88
f(88) = 88
f(89) = 188 //NB: NOT 88*2=176
f(187) = 188
f(188) = 188
f(189) = 288
and so on. You get the idea.
So far I've used a function (in Delphi, not implemented by me) that does this:
function RoundToSpecificEndingDigits(aLength,aModMeasure : double) : double;
begin
Result := aModMeasure;
while Result < aLength do Result := Result + 100;
end;
Now I need a more "mathematical" approach with divs and mods and rounds etc. The reason is that I want to do it in SQL without creating functions.
| 0
| 0
| 0
| 0
| 1
| 0
|
I have the following function that rounds a number to the nearest number ending with the digits of $nearest, and I was wondering if there is a more elegant way of doing the same.
/**
* Rounds the number to the nearest digit(s).
*
* @param int $number
* @param int $nearest
* @return int
*/
function roundNearest($number, $nearest, $type = null)
{
$result = abs(intval($number));
$nearest = abs(intval($nearest));
if ($result <= $nearest)
{
$result = $nearest;
}
else
{
$ceil = $nearest - substr($result, strlen($result) - strlen($nearest));
$floor = $nearest - substr($result, strlen($result) - strlen($nearest)) - pow(10, strlen($nearest));
switch ($type)
{
case 'ceil':
$result += $ceil;
break;
case 'floor':
$result += $floor;
break;
default:
$result += (abs($ceil) <= abs($floor)) ? $ceil : $floor;
break;
}
}
if ($number < 0)
{
$result *= -1;
}
return $result;
}
Some examples:
roundNearest(86, 9); // 89
roundNearest(97, 9); // 99
roundNearest(97, 9, 'floor'); // 89
Thanks in advance!
PS: This question is not about rounding to the nearest multiple.
| 0
| 0
| 0
| 0
| 1
| 0
|
Kindly give me some hint of matrix multiplication using MTL 2. Or any ref. or link for the documentation of MTL 2.
| 0
| 0
| 0
| 0
| 1
| 0
|
Hellow Stack Overflow people. I'd like some suggestions regarding the following problem. I am using Java.
I have an array #1 with a number of Strings. For example, two of the strings might be: "An apple fell on Newton's head" and "Apples grow on trees".
On the other side, I have another array #2 with terms like (Fruits => Apple, Orange, Peach; Items => Pen, Book; ...). I'd call this array my "dictionary".
By comparing items from one array to the other, I need to see in which "category" the items from #1 fall into from #2. E.g. Both from #1 would fall under "Fruits".
My most important consideration is speed. I need to do those operations fast. A structure allowing constant time retrieval would be good.
I considered a Hashset with the contains() method, but it doesn't allow substrings. I also tried running regex like (apple|orange|peach|...etc) with case insensitive flag on, but I read that it will not be fast when the terms increase in number (minimum 200 to be expected). Finally, I searched, and am considering using an ArrayList with indexOf() but I don't know about its performance. I also need to know which of the terms actually matched, so in this case, it would be "Apple".
Please provide your views, ideas and suggestions on this problem.
I saw Aho-Corasick algorithm, but the keywords/terms are very likely to change often. So I don't think I can use that. Oh, I'm no expert in text mining and maths, so please elaborate on complex concepts.
Thank you, Stack Overflow people, for your time! :)
| 0
| 1
| 0
| 0
| 0
| 0
|
I develop a Python-based drawing program, Whyteboard (https://launchpad.net/whyteboard)
I'm developing features to allow the user to rotate and scale a polygon that they draw. Here's my problem:
I have a Polygon class containing a list of all points, which is "closed off" at the end. Users can select drawn shapes in my program, which "highlights" them, drawing selection handles at each point. These points can be "grabbed" to change its position, and altering the polygon's shape.
I have a problem: I need to figure out how to calculate a the resizing "scale" to apply to the polygon. For example, (with the mouse held down), the user moving their mouse away from the shape should be a "grow" action, and bringing the mouse towards the shape should shrink it.
I have code in place to perform the scale (which I believe is correct) but I just can't create a "good" scaling factor. The code below is what I've come up with, based on the answers
/edit -- here is the solved code.
def rescale(self, x, y):
"""
x and y are the current mouse positions. the center and "original" mouse
coords are calculated below
"""
if not self.center:
a = sum([x for x, y in self.points]) / len(self.points)
b = sum([y for x, y in self.points]) / len(self.points)
self.center = (a, b)
if not self.orig_click: # where the user first clicked on
self.orig_click = (x, y)
if not self.original_points: # the points before applying any scaling
self.original_points = list(self.points)
orig_click = self.orig_click
original_distance = math.sqrt((orig_click[0] - self.center[0]) ** 2 + (orig_click[1] - self.center[1]) ** 2)
current_distance = (math.sqrt((x - self.center[0]) ** 2 +
(y - self.center[1]) ** 2))
self.scale_factor = current_distance / original_distance
for count, point in enumerate(self.original_points):
dist = (point[0] - self.center[0], point[1] - self.center[1])
self.points[count] = (self.scale_factor * dist[0] + self.center[0], self.scale_factor * dist[1] + self.center[1])
Currently this code seems to scale my polygon down to nothing quickly, and no amount of mouse movement will grow it back. Sometimes it will do the opposite, and grow quickly; but not shrink back.
| 0
| 0
| 0
| 0
| 1
| 0
|
I am trying to construct an equilateral triangle with the following code, but I am not seeing what I would expect to.
I would expect to see a triangle drawn to the stage, but I don't see one.
I think there must be something wrong in terms of the location of the tri sprite on the screen.
public class test_drawing_triangle extends Sprite
{
public function test_drawing_triangle()
{
var tri:Sprite = new Sprite;
var nextx:int;
var nexty:int;
var prevx:int;
var prevy:int;
var angle:Number;
var radius:Number;
var deg:int;
var i:int;
radius = 10;
// tri.x = stage.stageWidth / 2;
tri.y = 50;
tri.graphics.clear();
tri.graphics.beginFill(0x000000, 0.5);
tri.graphics.moveTo(0,0);
for(deg = 0; deg < 360; deg += 120)
{
angle = deg * Math.PI / 180;
nextx = Math.cos(angle) * radius;
nexty = Math.sin(angle) * radius;
tri.graphics.lineTo(nextx, nexty);
}
tri.graphics.endFill();
addChild(tri);
}
}
UPDATE:
I can now see the triangle but it is not filled in.
It seems to have the generally-correct shape, but I would expect for it be 3 sided, rather than 4.
If anyone could take a sec to compile this and look at what I am describing it would really help.
| 0
| 0
| 0
| 0
| 1
| 0
|
Does anyone know a way to locate rectangles to best fit a certain area? The rectangles can be scaled up to a certain limit, but they should keep their proportions.
I basically want to rebuild Mac OS' Exposé:
Picture
Thanks,
eWolf
| 0
| 0
| 0
| 0
| 1
| 0
|
I want to find a value of z at y = 12 and x = 3.5, given the below example data. How can I do this in C++?
y = 10
x = [1,2, 3,4, 5,6]
z = [2.3, 3.4, 5.6, 7.8, 9.6, 11.2]
y = 20
x = [1,2, 3,4, 5,6]
z = [4.3, 5.4, 7.6, 9.8, 11.6, 13.2]
y = 30
x = [1,2, 3,4, 5,6]
z = [6.3, 7.4, 8.6, 10.8, 13.6, 15.2]
My current Python code:
import scipy
import math
import numpy
from scipy import interpolate
x = [1, 2, 3, 4, 5, 6]
y = [10, 20, 30]
Y = numpy.array([[i]*len(x) for i in y])
X = numpy.array([x for i in y])
Z = numpy.array([[2.3, 3.4, 5.6, 7.8, 9.6, 11.2],
[4.3, 5.4, 7.6, 9.8, 11.6, 13.2],
[6.3, 7.4, 8.6, 10.8, 13.6, 15.2]])
tck = interpolate.bisplrep(X, Y, Z)
print interpolate.bisplev(3.5, 15, tck)
| 0
| 0
| 0
| 0
| 1
| 0
|
Scenario
I am attempting to implement supervised learning over a data set within a Java GUI application. The user will be given a list of items or 'reports' to inspect and will label them based on a set of available labels. Once the supervised learning is complete, the labelled instances will then be given to a learning algorithm. This will attempt to order the rest of the items on how likely it is the user will want to view them.
To get the most from the user's time I want to pre-select the reports that will provide the most information about the entire collection of reports, and have the user label them. As I understand it, to calculate this, it would be necessary to find the sum of all the mutual information values for each report, and order them by that value. The labelled reports from supervised learning will then be used to form a Bayesian network to find the probability of a binary value for each remaining report.
Example
Here, an artificial example may help to explain, and may clear up confusion when I've undoubtedly used the wrong terminology :-) Consider an example where the application displays news stories to the user. It chooses which news stories to display first based on the user's preference shown. Features of a news story which have a correlation are country of origin, category or date. So if a user labels a single news story as interesting when it came from Scotland, it tells the machine learner that there's an increased chance other news stories from Scotland will be interesting to the user. Similar for a category such as Sport, or a date such as December 12th 2004.
This preference could be calculated by choosing any order for all news stories (e.g. by category, by date) or randomly ordering them, then calculating preference as the user goes along. What I would like to do is to get a kind of "head start" on that ordering by having the user to look at a small number of specific news stories and say if they're interested in them (the supervised learning part). To choose which stories to show the user, I have to consider the entire collection of stories. This is where Mutual Information comes in. For each story I want to know how much it can tell me about all the other stories when it is classified by the user. For example, if there is a large number of stories originating from Scotland, I want to get the user to classify (at least) one of them. Similar for other correlating features such as category or date. The goal is to find examples of reports which, when classified, provide the most information about the other reports.
Problem
Because my math is a bit rusty, and I'm new to machine learning I'm having some trouble converting the definition of Mutual Information to an implementation in Java. Wikipedia describes the equation for Mutual Information as:
However, I'm unsure if this can actually be used when nothing has been classified, and the learning algorithm has not calculated anything yet.
As in my example, say I had a large number of new, unlabelled instances of this class:
public class NewsStory {
private String countryOfOrigin;
private String category;
private Date date;
// constructor, etc.
}
In my specific scenario, the correlation between fields/features is based on an exact match so, for instance, one day and 10 years difference in date are equivalent in their inequality.
The factors for correlation (e.g. is date more correlating than category?) are not necessarily equal, but they can be predefined and constant. Does this mean that the result of the function p(x,y) is the predefined value, or am I mixing up terms?
The Question (finally)
How can I go about implementing the mutual information calculation given this (fake) example of news stories? Libraries, javadoc, code examples etc. are all welcome information. Also, if this approach is fundamentally flawed, explaining why that is the case would be just as valuable an answer.
PS. I am aware of libraries such as Weka and Apache Mahout, so just mentioning them is not really useful for me. I'm still searching through documentation and examples for both these libraries looking for stuff on Mutual Information specifically. What would really help me is pointing to resources (code examples, javadoc) where these libraries help with mutual information.
| 0
| 0
| 0
| 1
| 0
| 0
|
What does dimensionality reduction mean exactly?
I searched for its meaning, I just found that it means the transformation of raw data into a more useful form. So what is the benefit of having data in useful form, I mean how can I use it in a practical life (application)?
| 0
| 1
| 0
| 1
| 0
| 0
|
short sho1, sho2;
printf("Enter two shorts.
");
scanf("%hd %hd", &sho1, &sho2);
printf("%hd^%hd is %hd.
", sho1, sho2, sho1^sho2);
When I enter '2 2', I get this output:
2^2 is 0.
How come? I'm using the MinGW GCC compiler in Eclipse, in case that's of any importance.
| 0
| 0
| 0
| 0
| 1
| 0
|
Well as the questions says...
An equation might be more meaningful in its math-notated form than it is in code. Being able to put math in comments could improve readabibity on my projects.
In .NET btw.
| 0
| 0
| 0
| 0
| 1
| 0
|
I attached image:
(source: piccy.info)
So in this image there is a diagram of the function, which is defined on the given points.
For example on points x=1..N.
Another diagram, which was drawn as a semitransparent curve,
That is what I want to get from the original diagram,
i.e. I want to approximate the original function so that it becomes smooth.
Are there any methods for doing that?
I heard about least squares method, which can be used to approximate a function by straight line or by parabolic function. But I do not need to approximate by parabolic function.
I probably need to approximate it by trigonometric function.
So are there any methods for doing that?
And one idea, is it possible to use the Least squares method for this problem, if we can deduce it for trigonometric functions?
One more question!
If I use the discrete Fourier transform and think about the function as a sum of waves, so may be noise has special features by which we can define it and then we can set to zero the corresponding frequency and then perform inverse Fourier transform.
So if you think that it is possible, then what can you suggest in order to identify the frequency of noise?
| 0
| 0
| 0
| 0
| 1
| 0
|
I'm no professional programmer and I don't study it. I'm an aerospace student and did a numeric method for my diploma thesis and also coded a program to prove that it works.
I did several methods and implemented several algorithms and tried to show the proofs why different situations needed their own algorithm to solve the task.
I did this proof with a mathematical approach, but some algorithm was so specific that I do know what they do and they do it right, but it was very hard to find a mathematical function or something to show how many iterations or loops it has to do until it finishes.
So, I would like to know how you do this comparison. Do you also present a mathematical function, or do you just do a speedtest of both algorithms, and if you do it mathematically, how do you do that? Do you learn this during your university studies, or how?
Thank you in advance, Andreas
| 0
| 0
| 0
| 0
| 1
| 0
|
I have a 3D Plane defined by two 3D Vectors:
P = a Point which lies on the Plane
N = The Plane's surface Normal
And I want to calculate any vector that lies on the plane.
| 0
| 0
| 0
| 0
| 1
| 0
|
I need help converting this code from this thread: How to Rotate a 2D Array of Integers
to PHP arrays.
int [,] newArray = new int[4,4];
for (int i=3;i>=0;--i) {
for (int j=0;j<4;++j) {
newArray[j,3-i] = array[i,j];
}
}
Also, will this code work if the blocks are off-center?
| 0
| 0
| 0
| 0
| 1
| 0
|
Based on information in Chapter 7 of 3D Programming For Windows (Charles Petzold), I've attempted to write as helper function that projects a Point3D to a standard 2D Point that contains the corresponding screen coordinates (x,y):
public Point Point3DToScreen2D(Point3D point3D,Viewport3D viewPort )
{
double screenX = 0d, screenY = 0d;
// Camera is defined in XAML as:
// <Viewport3D.Camera>
// <PerspectiveCamera Position="0,0,800" LookDirection="0,0,-1" />
// </Viewport3D.Camera>
PerspectiveCamera cam = viewPort.Camera as PerspectiveCamera;
// Translate input point using camera position
double inputX = point3D.X - cam.Position.X;
double inputY = point3D.Y - cam.Position.Y;
double inputZ = point3D.Z - cam.Position.Z;
double aspectRatio = viewPort.ActualWidth / viewPort.ActualHeight;
// Apply projection to X and Y
screenX = inputX / (-inputZ * Math.Tan(cam.FieldOfView / 2));
screenY = (inputY * aspectRatio) / (-inputZ * Math.Tan(cam.FieldOfView / 2));
// Convert to screen coordinates
screenX = screenX * viewPort.ActualWidth;
screenY = screenY * viewPort.ActualHeight;
// Additional, currently unused, projection scaling factors
/*
double xScale = 1 / Math.Tan(Math.PI * cam.FieldOfView / 360);
double yScale = aspectRatio * xScale;
double zFar = cam.FarPlaneDistance;
double zNear = cam.NearPlaneDistance;
double zScale = zFar == Double.PositiveInfinity ? -1 : zFar / (zNear - zFar);
double zOffset = zNear * zScale;
*/
return new Point(screenX, screenY);
}
On testing however this function returns incorrect screen coordinates (checked by comparing 2D mouse coordinates against a simple 3D shape). Due to my lack of 3D programming experience I am confused as to why.
The block commented section contains scaling calculations that may be essential, however I am not sure how, and the book continues with the MatrixCamera using XAML. Initially I just want to get a basic calculation working regardless of how inefficient it may be compared to Matrices.
Can anyone advise what needs to be added or changed?
| 0
| 0
| 0
| 0
| 1
| 0
|
The theory is this: I have a circle C of radius R and centre S. Inside this circle, I want to place N (a "big" number) points such that the density of points in the vicinity V of a point P is equal everywhere in the circle for all points. As N goes to infinity and the vicinity goes to P, the density function in both polar and cartesian coordinates becomes a constant.
So, how should I approach this if I wanted to populate the circle with N points of constant density?
| 0
| 0
| 0
| 0
| 1
| 0
|
Working programmer looking for a math refresher or just developing mathematical thinking. Saw J Language http://www.jsoftware.com/jwiki/Books
The book "Math for the Layman" claims that the J language makes math easier to learn by providing interactive tools and simpler notation than conventional math. Can someone confirm this from experience, specifically for learning mathematical thinking? I thought I'd try a programming approach and maybe pick up a new language along the way. If not, I have my text books ready.
Is this worth my time?
Thank you.
| 0
| 0
| 0
| 0
| 1
| 0
|
I'm working on java program that can compute the differentiation of any given mathematical expression.
When User types the expression say Sin(Cos(x^2)) I need to check whether it is mathematically valid or not.
Of course we can do it by manual code writing but that would be tedious work.
Can I do it using regex package of java??
How??
thanx..
| 0
| 0
| 0
| 0
| 1
| 0
|
I have a list of video segment durations I need to add up to get the total duration.
The series is like this:
0:33
4:30
6:03
2:10
...etc
I need to add up the minutes and seconds to get a total video duration.
Here's the modified function of my accepted answer:
function getTotalDuration ($durations) {
$total = 0;
foreach ($durations as $duration) {
$duration = explode(':',$duration);
$total += $duration[0] * 60;
$total += $duration[1];
}
$mins = floor($total / 60);
$secs = str_pad ( $total % 60, '2', '0', STR_PAD_LEFT);
return $mins.':'.$secs;
}
Just made sure the output looks correct.
| 0
| 0
| 0
| 0
| 1
| 0
|
I have a simple C# function:
public static double Floor(double value, double step)
{
return Math.Floor(value / step) * step;
}
That calculates the higher number, lower than or equal to "value", that is multiple of "step". But it lacks precision, as seen in the following tests:
[TestMethod()]
public void FloorTest()
{
int decimals = 6;
double value = 5F;
double step = 2F;
double expected = 4F;
double actual = Class.Floor(value, step);
Assert.AreEqual(expected, actual);
value = -11.5F;
step = 1.1F;
expected = -12.1F;
actual = Class.Floor(value, step);
Assert.AreEqual(Math.Round(expected, decimals),Math.Round(actual, decimals));
Assert.AreEqual(expected, actual);
}
The first and second asserts are ok, but the third fails, because the result is only equal until the 6th decimal place. Why is that? Is there any way to correct this?
Update If I debug the test I see that the values are equal until the 8th decimal place instead of the 6th, maybe because Math.Round introduces some imprecision.
Note In my test code I wrote the "F" suffix (explicit float constant) where I meant "D" (double), so if I change that I can have more precision.
| 0
| 0
| 0
| 0
| 1
| 0
|
I tend to use math functions of constant expressions for convinience and coherence (i.e log(x)/log(2) instead of log(x)/0.3...). Since these functions aren't actually a part of the language itself, neither are they defined in math.h (only declared), will the constant ones get precalculated at compile time, or will they be wastefully calculated at runtime?
| 0
| 0
| 0
| 0
| 1
| 0
|
I'm analyzing financial data and would like to find the inflection points of a line. I know I can do this using derivatives, but first I need an equation. Is there a way to generate an equation based off of a series of numbers. I would need to do this programmaticly.
| 0
| 0
| 0
| 0
| 1
| 0
|
I have an application which decides whether a human is handwaving,running or walking.
The idea is i have segmented an action,say handwave,to its poses. Let's say
Example;
for human1:pose7-pose3-pose7-..... represents handwave
for human3:pose1-pose7-pose1-..... represents handwave
for human7:pose1-pose1-pose7-..... represents handwave
for human20:pose3-pose7-pose7-..... represents handwave
for human1 pose11-pose33-pose77-..... represents walking
for human2 pose31-pose33-pose77-..... represents walking
for human3 pose11-pose77-pose77-..... represents walking
for human20 pose11-pose33-pose11-..... represents walking
and i used above vectors for training SVM and Neural Net in Matlab..
Now I test with it test images. Again I have segmented poses for test images.
For the vector sizes of test and train sets in MATLAB; SVM and Neural Net requires same vector sizes.
To make it work;
If I append 0 (assume it like pose0-which is an invalid pose) , to make sizes equal I have really good performance.
If I copy initial poses at the beginning and append them to the end until sizes are equal performance decreases.
For example;
train set: pose1-pose2-pose4-pose7-pose2-pose4-pose7
(1st method)test set: pose3-pose1-pose4-0-0-0-0 or
(2nd method)test set: pose3-pose1-pose4-pose3-pose1-pose4-pose3
I would expect to have better classification with 2nd method since appended values are actual values for poses. But pose0 is not a real pose.
Do you have any ideas ?
Regards
| 0
| 0
| 0
| 1
| 0
| 0
|
I know that if we have some data representing some wave, for example image line values,
we can use fourier transform to get frequency function of that wave.
But we have N values at points x=0...N-1
And we get only N frequencies at the output.
So I want to analyze the wave everywhere in the range [0, N-1]
For example at point u = 1.5.
How can I do it?
| 0
| 0
| 0
| 0
| 1
| 0
|
I challenge you to write a mathematical expression evaluator that respects PEMDAS (order of operations: parentheses, exponentiation, multiplication, division, addition, subtraction) without using regular expressions, a pre-existing "Eval()"-like function, a parsing library, etc.
I saw one pre-existing evaluator challenge on SO (here), but that one specifically required left-to-right evaluation.
Sample inputs and outputs:
"-1^(-3*4/-6)" -> "1"
"-2^(2^(4-1))" -> "256"
"2*6/4^2*4/3" -> "1"
I wrote an evaluator in C#, but would like to see how badly it compares to those of smarter programmers in their languages of choice.
Related:
Code Golf: Evaluating mathematical expressions
Clarifications:
Let's make this a function that accepts a string argument and returns a string result.
As for why no regexes, well, that's to level the playing field. I think there ought to be a separate challenge for "the most compact regex".
Using StrToFloat() is acceptable. By "parsing library" I meant to exclude such things as general-purpose grammar parsers, also to level the playing-field.
Support floats.
Support paretheses, exponentiation, and the four arithmetic operators.
Give multiplication and division equal precedence.
Give addition and subtraction equal precedence.
For simplicity, you may assume all inputs are well-formed.
I don't have a preference as to whether your function accepts such things as ".1" or "1e3" as valid numbers, but accepting them would earn you brownie points. ;)
For divide-by-zero cases, you could perhaps return "NaN" (assuming you wish to implement error handling).
| 0
| 0
| 0
| 0
| 1
| 0
|
I have a product that sells in a strange way.
The formula to get the current price is:
total_products_sold * 0.05
I need a function that will return the total sales value, given a total_products_sold value.
This needs to figure out all past pricing, using the above formula.
e.g. if I sold 3 products, the total sales amount is:
1 * 0.5 + 2 * 0.5 + 3 * 0.5 = .30
I can't remember the formula, if its a factorial issue or a exponential type equation.
| 0
| 0
| 0
| 0
| 1
| 0
|
I have just started programming with Java and noticed I might need to improve my math skills if i'm to do anything worthwhile with it. I just noticed that some of the exercises should be easy for someone with a solid understanding in math as there seems to be some math formulae running the show. I finished high school two years ago and did not get any opportunity to do math at the highest level there. I'm deeply worried by this and so i'm looking for pointers from more experienced and knowledgeable people on what I should study to get a basic grasp of mathematics before indulging in deep waters.
I was generally a sharp student in math and I have got a real quick mind. My goal is to become a certified and well-experienced Java programmer by the end of the year. I know people will say experience takes time and effort but i'm willing to sacrifice whatever that I have towards fulfilment of this goal. I have programmed with PHP and MySQL a bit before and got a general understanding but Java gave me a real kick when I read about it. If you know any other stuff that may help me in this endeavour, please let me know.
Thanks.
| 0
| 0
| 0
| 0
| 1
| 0
|
I am hand tagging twitter messages as Positive, Negative, Neutral. I am try to appreciate is there some logic one can use to identify of the training set what proportion of message should be positive / negative and neutral ?
So for e.g. if I am training a Naive Bayes classifier with 1000 twitter messages should the proportion of pos : neg : neutral be 33 % : 33% : 33% or should it be 25 % : 25 % : 50 %
Logically in my head it seems that I i train (i.e. give more samples for neutral) that the system would be better at identifying neutral sentences then whether they are positive or negative - is that true ? or I am missing some theory here ?
Thanks
Rahul
| 0
| 1
| 0
| 0
| 0
| 0
|
Well
It's not a big question, obviously.
But you see, an application that is using a database on the servers, and is installed on multiple clients. Is called Client/Server application.
And an application that is constituted by two parts: Host (or server) part, and the client part.
They are both called client/server apps
How can we distinguish them, and what's the proper name of each type.
P.S. I'm talking about English, you know. I want to say that this application is Client/Server(only database on server) and not a Client/Server(as real client and server).
| 0
| 1
| 0
| 0
| 0
| 0
|
As a student of computational linguistics, I frequently do machine learning experiments where I have to prepare training data from all kinds of different resources like raw or annotated text corpora or syntactic tree banks. For every new task and every new experiment I write programs (normally in Python and sometimes Java) to extract the features and values I need and transform the data from one format to the other. This usually results in a very large number of very large files and a very large number of small programs which process them in order to get the input for some machine learning framework (like the arff files for Weka).
One needs to be extremely well organised to deal with that and program with great care not to miss any important peculiarities, exceptions or errors in the tons of data. Many principles of good software design like design patterns or refactoring paradigms are no big use for these tasks because things like security, maintainability or sustainability are of no real importance - once the program successfully processed the data one doesn't need it any longer. This has gone so far that I even stopped bothering about using classes or functions at all in my Python code and program in a simple procedural way. The next experiment will require different data sets with unique characteristics and in a different format so that their preparation will likely have to be programmed from scratch anyway. My experience so far is that it's not unusual to spend 80-90% of a project's time on the task of preparing training data. Hours and days go by only on thinking about how to get from one data format to another. At times, this can become quite frustrating.
Well, you probably guessed that I'm exaggerating a bit, on purpose even, but I'm positive you understand what I'm trying to say. My question, actually, is this:
Are there any general frameworks, architectures, best practices for approaching these tasks? How much of the code I write can I expect to be reusable given optimal design?
| 0
| 1
| 0
| 1
| 0
| 0
|
I'm trying to achieve something like the following in C++:
class MyVector; // 3 component vector class
MyVector const kA = /* ... */;
MyVector const kB = /* ... */;
MyVector const kC = /* ... */;
MyVector const kD = /* ... */;
// I'd like to shorten the remaining lines, ideally making it readable but less code/operations.
MyVector result = kA;
MyVector const kCMinusD = kC - kD;
if(kCMinusD.X <= 0)
{
result.X = kB.X;
}
if(kCMinusD.Y <= 0)
{
result.Y = kB.Y;
}
if(kCMinusD.Z <= 0)
{
result.Z = kB.Z;
}
Paraphrasing the code into English, I have four 'known' vectors. Two of the vectors have values that I may or may not want in my result, and whether I want them or not is contingent on a branch based on the components of two other vectors.
I feel like I should be able to simplify this code with some matrix math and masking, but I can't wrap my head around it.
For now I'm going with the branch, but I'm curious to know if there's a better way that still would be understandable, and less code-verbose.
Edit:
In reference to Mark's comment, I'll explain what I'm trying to do here.
This code is an excerpt from some spring physics I'm working on. The components are as follows:
kC is the springs length currently, and kD is minimum spring length.
kA and kB are two sets of spring tensions, each component of which may be unique per component (i.e., a different spring tension along the X, Y, or Z). kA is the springs tension if it's not fully compressed, and kB is the springs tension if it IS fully compressed.
I'd like to build up a resultant 'vector' that simply is the amalgamation of kC and kD, dependant on whether the spring is compressed or not.
| 0
| 0
| 0
| 0
| 1
| 0
|
Is there a research paper/book that I can read which can tell me for the problem at hand what sort of feature selection algorithm would work best.
I am trying to simply identify twitter messages as pos/neg (to begin with). I started out with Frequency based feature selection (having started with NLTK book) but soon realised that for a similar problem various individuals have choosen different algorithms
Although I can try Frequency based, mutual information, information gain and various other algorithms the list seems endless.. and was wondering if there an efficient way then trial and error.
any advice
| 0
| 1
| 0
| 0
| 0
| 0
|
Sorry if my question sounds dumb. But some time small things create big problem for you and take your whole time to solve it. But thanks to stackoverflow where i can get GURU advices. :)
So here is my problem. i search for a word in a string and put 0 where that word occur.
For example : search word is DOG and i have string "never ever let dog bite you" so the string
would be 000100 . Now when I try to convert this string into INT it produce result 100 :( which is bad. I also can not use int array i can only use string as i am concatinating it, also using somewhere else too in program.
Now i am sure you are wondering why i want to convert it into INT. So here my answer. I am using 3 words from each string to make this kind of binary string. So lets say i used three search queries like ( dog, dog, ever ) so all three strings would be
000100
000100
010000
Then I want to SUM them it should produce result like this "010200" while it produce result "10200" which is wrong. :(
Thanks in advance
| 0
| 0
| 0
| 0
| 1
| 0
|
I've three sets of data such as:
x y
4 0
6 60
8 0
Does anyone know any (efficient) Java codes that can give me back the values of a, b, and c (the coefficients)?
| 0
| 0
| 0
| 0
| 1
| 0
|
I have a problem where I have a set of numbers eg.
5, 7, 7, 8, 8, 8, 7, 20, 23, 23, 24, 24, 24, 25
In the above set, there is two "clusters" of numbers, I want to write a program to find the centers of these clusters. Could you call them attractors as in Fractal theory?
So the program would, I guess, find that the set can be divided into two:
A - 5, 7, 7, 8, 8, 8, 7
B - 20, 23, 23, 24, 24, 24, 25
Set A can then have it average calculated, set B can have its average calculated then I have the two centers of the attractors.
Maybe this is a simple problem for a good math/statistics person? Can anyone point me in the right direction?
I may have between 1 and 5 "attractors/clusters".
| 0
| 0
| 0
| 0
| 1
| 0
|
Recently, a correspondent mentioned float.as_integer_ratio(), new in Python 2.6, noting that typical floating point implementations are essentially rational approximations of real numbers. Intrigued, I had to try π:
>>> float.as_integer_ratio(math.pi);
(884279719003555L, 281474976710656L)
I was mildly surprised not to see the more accurate result due to Arima,:
(428224593349304L, 136308121570117L)
For example, this code:
#! /usr/bin/env python
from decimal import *
getcontext().prec = 36
print "python: ",Decimal(884279719003555) / Decimal(281474976710656)
print "Arima: ",Decimal(428224593349304) / Decimal(136308121570117)
print "Wiki: 3.14159265358979323846264338327950288"
produces this output:
python: 3.14159265358979311599796346854418516
Arima: 3.14159265358979323846264338327569743
Wiki: 3.14159265358979323846264338327950288
Certainly, the result is correct given the precision afforded by 64-bit floating-point numbers, but it leads me to ask: How can I find out more about the implementation limitations of as_integer_ratio()? Thanks for any guidance.
Additional links: Stern-Brocot tree and Python source.
| 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.