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'm not sure if this can be done without some determining factor....but wanted to see if someone knew of a way to do this. I want to create a shifting scale for numbers. Let's say I have the number 26000. I want the outcome of this algorithm to be 6500; or 25% of the original number. But if I have the number 5000, I want the outcome to be 2500; or 50% of the original number. The percentages don't have to be exact, this is just an example. I just want to have like a sine wave sort of thing. As the input number gets higher, the output number is a lower percentage of the input. Does that make sense?
0
0
0
0
1
0
The sensor module in my project consists of a rotating camera, that collects noisy information about moving objects in the surrounding environment. The information consists of distance, angle and relative change of the moving objects.. The limiting view range of the camera makes it essential to rotate the camera periodically to update environment information... I was looking for algorithms / ways to model these information, in order to be able to guess / predict / learn motion properties of these object.. My current proposed idea is to store last n snapshots of each object in a queue. I take weighted average of positions and velocities of moving object, but I think it is a poor method... Can you state some titles that suit this case? Thanks
0
1
0
1
0
0
Here's a math/geometry problem for the math whizzes (not my strongest subject). This is for WPF, but should be general enough to solve regardless: I have two embedded Border elements, with the outer one having a certain corner radius, R and border thickness, T. Given these two values, what should the corner radius of the inner Border, R' be set to such that the two corner edges meet with no overlap or holes? So far I've just been eyeballing it, but if someone can give me a proper formula that would be great. Respect points if you can!! ;)
0
0
0
0
1
0
How can I solve the issue of content existing in multiple versions and multiple languages? My current structure: Each content can only have one active version in each language, and that's how I'm curious on how to best solve. Right now I have a column of the contentversions table, which means for each change of active version I have to run a update and set active=false on all version and then a update to set active=true for the piece of content in question.
0
1
0
0
0
0
I have a fragment of bytes in a byte[]. The total size of the array is 4 and I want to convert this into a positive long number. For example if the byte array is having four bytes 101, 110, 10, 10000001 then i want to get the long number represented by binary sequence 00000000 00000000 00000000 00000000 00000101 00000110 00000010 10000001 which equals 84279937 What is the efficient way to do that in Java?
0
0
0
0
1
0
The update rule TD(0) Q-Learning: Q(t-1) = (1-alpha) * Q(t-1) + (alpha) * (Reward(t-1) + gamma* Max( Q(t) ) ) Then take either the current best action (to optimize) or a random action (to explorer) Where MaxNextQ is the maximum Q that can be got in the next state... But in TD(1) I think update rule will be: Q(t-2) = (1-alpha) * Q(t-2) + (alpha) * (Reward(t-2) + gamma * Reward(t-1) + gamma * gamma * Max( Q(t) ) ) My question: The term gamma * Reward(t-1) means that I will always take my best action at t-1 .. which I think will prevent exploring.. Can someone give me a hint? Thanks
0
1
0
1
0
0
A question about 20 questions games was asked here: However, if I'm understanding it correctly, the answers seem to assume that each question will go down a hierarchal branching tree. A binary tree should work if the game went like this: Is it an animal? Yes. Is it a mammal? Yes. Is it a feline? Yes. Because feline is an example of a mammal and mammal is an example of an animal. But what if the questions go like this? Is it a mammal? Yes. Is it a predator? Yes. Does it have a long nose? No. You can't branch down a tree with those kinds of questions, because there are plenty of predators that aren't mammals. So you can't have your program just narrow it down to mammal and have predators be a subset of mammals. So is there a way to use a binary search tree that I'm not understanding or is there a different algorithm for this problem? Just to clarify, I'm only using 20 questions as an example, so my question is about this kind of search problem in general, not other problems involved specifically in a 20 questions game.
0
1
0
0
0
0
For example, given a string: "Bob went fishing with his friend Jim Smith." Bob and Jim Smith are both names, but bob and smith are both words. Weren't for them being uppercase, there would be less indication of this outside of our knowledge of the sentence. Are there any well known algorithms for detecting the presence of names, at least Western names?
0
1
0
0
0
0
This maybe an over asked question, but my mind draws blank at this moment. I know what a candlestick chart is and how to draw it daily. But how to draw it intraday at asked time periods. I have this server, written in Java, that gives me trade depth (each trade done since the start of the day). Its just a stream of raw data: price, shares, timestamp. How does one go about calculating candlestick data from that? Lets say, they want to have 5 min candlestick or 1min candlestick. Or is there a library that will do that for me if I feed it data? Any help is appreciated!
0
0
0
0
1
0
This is a question in a previous exam paper that I have been asked to look at; the slide we have used to learn do not make sense of this. I understand how to use a table to get the Entropy, but not how to use the equation provided to do so Question Train a decision tree on the data represented by attributes A1, A2, A3 and outcome C described below: A1 A2 A3 C 1 0 1 0 0 1 1 1 0 0 1 0 For log2(1/3) = 1.6 and log2(2/3) = 0.6, answer the following questions: a) What is the value of entropy H for the given set of training example? b) What is the portion of the positive samples split by attribute A2? c) What is the value of information gain, G(A2), of attribute A2? d) What is IFTHEN rule(s) for the decision tree?
0
1
0
0
0
0
First of all I'm quite a Java beginner, so I'm not sure if this is even possible! Basically I have a huge (3+million) data source of relational data (i.e. A is friends with B+C+D, B is friends with D+G+Z (but not A - i.e. unmutual) etc.) and I want to find every cycle within this (not necessarily connected) directed graph. I've found the thread Finding all cycles in graph, which has pointed me to Donald Johnson's (elementary) cycle-finding algorithm which, superficially at least, looks like it'll do what I'm after (I'm going to try when I'm back at work on Tuesday - thought it wouldn't hurt to ask in the meanwhile!). I had a quick scan through the code of the Java implementation of Johnson's algorithm (in that thread) and it looks like a matrix of relations is the first step, so I guess my questions are: a) Is Java capable of handling a 3+million*3+million matrix? (was planning on representing A-friends-with-B by a binary sparse matrix) b) Do I need to find every connected subgraph as my first problem, or will cycle-finding algorithms handle disjoint data? c) Is this actually an appropriate solution for the problem? My understanding of "elementary" cycles is that in the graph below, rather than picking out A-B-C-D-E-F it'll pick out A-B-F, B-C-D etc. but that's not the end of the world given the task. E / \ D---F / \ / \ C---B---A d) If necessary, I can simplify the problem by enforcing mutuality in relations - i.e. A-friends-with-B <==> B-friends-with-A, and if really necessary I can maybe cut down the data size, but realistically it is always going to be around the 1mil mark. z) Is this a P or NP task?! Am I biting off more than I can chew? Thanks all, any help appreciated! Andy
0
0
0
0
1
0
How do I efficiently create a rock-scissors-paper game for n elements, where n is any odd number >=3. In other words, I want a non-transitive complete ordering of n elements such that each element is greater than (n-1)/2 other elements and each element is lesser than (n-1)/2 other elements.
0
0
0
0
1
0
I've created a Winamp-like music player in Delphi. Not so complex, of course. Just a simple one. But now I would like to add a more complex feature: Songs in the library should be automatically rated based on the user's listening habits. This means: The application should "understand" if the user likes a song or not. And not only whether he/she likes it but also how much. My approach so far (data which could be used): Simply measure how often a song was played per time. Start counting time when the song was added to the library so that recent songs don't have any disadvantage. Measure how long a song was played on average (minutes). Starting a song but directly change to another one should have a bad influence on the ranking since the user didn't seem to like the song. ... Could you please help me with this problem? I would just like to have some ideas. I don't need the implementation in Delphi.
0
1
0
0
0
0
I think I'm making a mistake in how I call setResultsName(): from pyparsing import * DEPT_CODE = Regex(r'[A-Z]{2,}').setResultsName("Dept Code") COURSE_NUMBER = Regex(r'[0-9]{4}').setResultsName("Course Number") COURSE_NUMBER.setParseAction(lambda s, l, toks : int(toks[0])) course = DEPT_CODE + COURSE_NUMBER course.setResultsName("course") statement = course From IDLE: >>> myparser import * >>> statement.parseString("CS 2110") (['CS', 2110], {'Dept Code': [('CS', 0)], 'Course Number': [(2110, 1)]}) The output I hope for: >>> myparser import * >>> statement.parseString("CS 2110") (['CS', 2110], {'Course': ['CS', 2110], 'Dept Code': [('CS', 0)], 'Course Number': [(2110, 1)]}) Does setResultsName() only work for terminals?
0
1
0
0
0
0
What is the difference between: foo = TOKEN1 + TOKEN2 and foo = Combine(TOKEN1 + TOKEN2) Thanks. UPDATE: Based on my experimentation, it seems like Combine() is for terminals, where you're trying to build an expression to match on, whereas plain + is for non-terminals. But I'm not sure.
0
1
0
0
0
0
I'm parsing sentences like "CS 2110 or INFO 3300". I would like to output a format like: [[("CS" 2110)], [("INFO", 3300)]] To do this, I thought I could use setParseAction(). However, the print statements in statementParse() suggest that only the last tokens are actually passed: >>> statement.parseString("CS 2110 or INFO 3300") Match [{Suppress:("or") Re:('[A-Z]{2,}') Re:('[0-9]{4}')}] at loc 7(1,8) string CS 2110 or INFO 3300 loc: 7 tokens: ['INFO', 3300] Matched [{Suppress:("or") Re:('[A-Z]{2,}') Re:('[0-9]{4}')}] -> ['INFO', 3300] (['CS', 2110, 'INFO', 3300], {'Course': [(2110, 1), (3300, 3)], 'DeptCode': [('CS', 0), ('INFO', 2)]}) I expected all the tokens to be passed, but it's only ['INFO', 3300]. Am I doing something wrong? Or is there another way that I can produce the desired output? Here is the pyparsing code: from pyparsing import * def statementParse(str, location, tokens): print "string %s" % str print "loc: %s " % location print "tokens: %s" % tokens DEPT_CODE = Regex(r'[A-Z]{2,}').setResultsName("DeptCode") COURSE_NUMBER = Regex(r'[0-9]{4}').setResultsName("CourseNumber") OR_CONJ = Suppress("or") COURSE_NUMBER.setParseAction(lambda s, l, toks : int(toks[0])) course = DEPT_CODE + COURSE_NUMBER.setResultsName("Course") statement = course + Optional(OR_CONJ + course).setParseAction(statementParse).setDebug()
0
1
0
0
0
0
Basically I can't get it right. I need something like this: if($p == 1) { $start = 0; $limit = 16; } The numbers must add on depending on the value of the $p, e.g. if $p is 5 then the values of $start and $limit would be: if($p == 5) { $start = 64; $limit = 80; } The math is to add 16, depending on the value of $p.
0
0
0
0
1
0
I'm looking for a library or existing code to simplify fractions. Does anyone have anything at hand or any links? P.S. I already understand the process but really don't want to rewrite the wheel Update Ok i've checked out the fraction library on the CodeProject BUT the problem I have is a little bit tricker than simplifying a fraction. I have to reduce a percentage split which could be 20% / 50% / 30% (always equal to 100%)
0
0
0
0
1
0
I've been struggling to wrap my head around this for some reason. I have 15 bits that represent a number. The bits must match a pattern. The pattern is defined in the way the bits start out: they are in the most flush-right representation of that pattern. So say the pattern is 1 4 1. The bits will be: 000000010111101 So the general rule is, take each number in the pattern, create that many bits (1, 4 or 1 in this case) and then have at least one space separating them. So if it's 1 2 6 1 (it will be random): 001011011111101 Starting with the flush-right version, I want to generate every single possible number that meets that pattern. The # of bits will be stored in a variable. So for a simple case, assume it's 5 bits and the initial bit pattern is: 00101. I want to generate: 00101 01001 01010 10001 10010 10100 I'm trying to do this in Objective-C, but anything resembling C would be fine. I just can't seem to come up with a good recursive algorithm for this. It makes sense in the above example, but when I start getting into 12431 and having to keep track of everything it breaks down.
0
0
0
0
1
0
I usually use ASP.net web forms for GUI, maybe one of most "stateful" technologies. But it applies to any technology which has states. Sometimes forms are tricky and complex, with >30 elements and > 3 states of each element. Intuitive way of designing such a form usually works for 90%. Other 10% usually find testers or end-users:). The problem as i see it that we should imagine a lot of scenarios on the same object, which is much harder than a consequence of independent operations. From functional programming courses I know that best way is not to use state management and use pure functions and variable passing by value and all these stuff, which is greatly formalized. Sometimes, we cannot avoid it. Do you use any math formalisms and approaches to state management of complex objects? Not like monads in Haskell, but which can be used in more traditional business applications and languages - Java, C#, C++. It may be not Turing-complete formalism, but 99% will be great also:). Sorry if it is just another tumbleweed question:)
0
0
0
0
1
0
I would like to ask how i should add the minus sign front of a decimal value. i want the user to add e.g. 100 and behind the scenes to convert it in -100 thank you.
0
0
0
0
1
0
I just need to know the difference between two int variables a and b. I'm new to Objective-C.
0
0
0
0
1
0
I'm writing a program to solve a geometry problem. My algorithm doesn't treat collinear point very well. Is there any transformation I can apply to the points to get rid of the collinearity?
0
0
0
0
1
0
i am having a line in normal graph,i want to know intersecting some points with that line , any formula for it?any help please? The line is from startpoint(50,50),endPoint(50,0)....the some point may be (0,10),(2,45),etc..
0
0
0
0
1
0
please refer to my quick diagram attached below. what i'm trying to do is get the coordinates of the yellow dots by using the angle from the red dots' known coordinates. assuming each yellow dot is about 20 pixels away from the x:50/y:250 red dot at a right angle (i think that's what it's called) how do i get their coordinates? i believe this is very basic trigonometry and i should use Math.tan(), but they didn't teach us much math in art school. alt text http://www.freeimagehosting.net/uploads/e8c848a357.jpg
0
0
0
0
1
0
Possible Duplicates: Why does 99.99 / 100 = 0.9998999999999999 Dealing with accuracy problems in floating-point numbers I've seen this issue in php and javascript. I have this number: float 0.699 if I do this: 0.699 x 100 = 69.89999999999999 why? edit round(0.699 x 10, 2): float 69.90000000000001
0
0
0
0
1
0
If i want to calculate the amount of k-dimensional contingency tables which formula should I use? For example, if i have 16 categorical variables in my dataset and want to calculate the amount of 1-dimensional contingency tables, then it's clear, there is only 1 table. If I want to calculate the amount of 2-dimensional contingency tables then I assume there are 120. But how do I calculate it? And what if i have much more variables and k-dimensional tables? I'm searching for one equations with gives me the number of available contingency tables, given the dimension (k) and the number of variables (n).
0
0
0
0
1
0
I'm interested in building a derivative calculator. I've racked my brains over solving the problem, but I haven't found a right solution at all. May you have a hint how to start? Thanks I'm sorry! I clearly want to make symbolic differentiation. Let's say you have the function f(x) = x^3 + 2x^2 + x I want to display the derivative, in this case f'(x) = 3x^2 + 4x + 1 I'd like to implement it in objective-c for the iPhone.
0
0
0
0
1
0
i'd like to negate a number and would like to know if there's a built in method that will convert a negative number to a positive OR a positive into a negative, depending on the number. i know about Math.abs(), but that only seems to convert negative into positive. is there a method that will do both?
0
0
0
0
1
0
I wanted to calculate the angle between two vectors but I have seen these inverse trig operations such as acos and atan uses lots of cpu cycles. Is there a way where I can get this calculation done without using these functions? Also, does these really hit you when you in your optimization?
0
0
0
0
1
0
Assume I have a point at the following location: Latitude: 47°36′N Longitude: 122°19′W Around the above point, I draw a 35Km radius. I have another point now or several and I want to see if they fall within the 35Km radius? How can I do this? Is it possible with Linq given the coordinates (lat, long) of both points?
0
0
0
0
1
0
Should we use double or BigDecimal for calculations in Java? How much is the overhead in terms of performance for BigDecimal as compared to double?
0
0
0
0
1
0
I have an array that looks similar to this, [4] => Common_Model Object ( [id] => 4 [name] => [date_created] => [last_updated] => [user_id_updated] => [_table] => [_aliases] => Array ( [id] => 4 [name] => [date_created] => [date_updated] => [user_id_updated] => [rating] => 3 [recipe_id] => 5 ) [_nonDBAliases] => Array ( ) [_default] => Array ( ) [_related] => Array ( ) [_enums] => [_alsoDelete] => Array ( ) [_readOnly] => Array ( [0] => date_updated ) [_valArgs] => Array ( ) [_valArgsHash] => Array ( [default] => Array ( ) ) [_valAliases] => Array ( ) [_extraData] => Array ( ) [_inputs] => Array ( ) [_tableName] => jm_ratings [_tablePrefix] => [_niceDateUpdated] => 1st Jan 70 [_niceDateCreated] => 1st Jan 70 [_fetchAdminData] => [_mCache] => [_assets] => Array ( ) ) [3] => Common_Model Object ( [id] => 3 [name] => [date_created] => [last_updated] => [user_id_updated] => [_table] => [_aliases] => Array ( [id] => 3 [name] => [date_created] => [date_updated] => [user_id_updated] => [rating] => 1 [recipe_id] => 5 ) [_nonDBAliases] => Array ( ) [_default] => Array ( ) [_related] => Array ( ) [_enums] => [_alsoDelete] => Array ( ) [_readOnly] => Array ( [0] => date_updated ) [_valArgs] => Array ( ) [_valArgsHash] => Array ( [default] => Array ( ) ) [_valAliases] => Array ( ) [_extraData] => Array ( ) [_inputs] => Array ( ) [_tableName] => jm_ratings [_tablePrefix] => [_niceDateUpdated] => 1st Jan 70 [_niceDateCreated] => 1st Jan 70 [_fetchAdminData] => [_mCache] => [_assets] => Array ( ) ) [2] => Common_Model Object ( [id] => 2 [name] => [date_created] => [last_updated] => [user_id_updated] => [_table] => [_aliases] => Array ( [id] => 2 [name] => [date_created] => [date_updated] => [user_id_updated] => [rating] => 1 [recipe_id] => 5 ) [_nonDBAliases] => Array ( ) [_default] => Array ( ) [_related] => Array ( ) [_enums] => [_alsoDelete] => Array ( ) [_readOnly] => Array ( [0] => date_updated ) [_valArgs] => Array ( ) [_valArgsHash] => Array ( [default] => Array ( ) ) [_valAliases] => Array ( ) [_extraData] => Array ( ) [_inputs] => Array ( ) [_tableName] => jm_ratings [_tablePrefix] => [_niceDateUpdated] => 1st Jan 70 [_niceDateCreated] => 1st Jan 70 [_fetchAdminData] => [_mCache] => [_assets] => Array ( ) ) I wanting to add up the [rating] and get the mean average. But I dont know how do this with PHP, my attempt looks like this, <?php foreach ($rt as $rating) { $total = $rating->rating + $rating->rating } $total / count($rt); ?>
0
0
0
0
1
0
I have a 3 file program, basically teaching myself c++. I have an issue. I made a switch to use the math function. I need and put it in a variable, but for some reason I get a zero as a result. Also another issue, when I select 4 (divide) it crashes... Is there a reason? Main file: #include <iostream> #include "math.h" #include <string> using namespace std; int opersel; int c; int a; int b; string test; int main(){ cout << "Welcome to Math-matrix v.34"<< endl; cout << "Shall we begin?" <<endl; //ASK USER IF THEY ARE READY TO BEGIN string answer; cin >> answer; if(answer == "yes" || answer == "YES" || answer == "Yes") { cout << "excellent lets begin..." << endl; cout << "please select a operator..." << endl << endl; cout << "(1) + " << endl; cout << "(2) - " << endl; cout << "(3) * " << endl; cout << "(4) / " << endl; cin >> opersel; switch(opersel){ case 1: c = add(a,b); break; case 2: c = sub(a,b); break; case 3: c = multi(a,b); break; case 4: c = divide(a,b); break; default: cout << "error... retry" << endl; }// end retry cout << "alright, how please select first digit?" << endl; cin >> a; cout << "excellent... and your second?" << endl; cin >> b; cout << c; cin >> test; }else if (answer == "no" || answer == "NO" || answer == "No"){ }//GAME ENDS }// end of int main Here is my math.h file #ifndef MATH_H #define MATH_H int add(int a, int b); int sub(int a, int b); int multi(int a, int b); int divide(int a, int b); #endif Here is my math.cpp: int add(int a, int b) { return a + b; } int sub(int a, int b) { return a - b; } int multi(int a, int b) { return a * b; } int divide(int a, int b) { return a / b; } }// end of int main
0
0
0
0
1
0
Being unable to reproduce a given result. (either because it's wrong or because I was doing something wrong) I was asking myself if it would be easy to just write a small program which takes all the constants and given number and permutes it with a possible operators (* / - + exp(..)) etc) until the result is found. Permutations of n distinct objects with repetition allowed is n^r. At least as long as r is small I think you should be able to do this. I wonder if anybody did something similar here..
0
0
0
0
1
0
to calculate some longitude and latitude values I need more decimal places like mysql is possible to do. For instance with mysql I get this result: cos( RADIANS( 47.685618 ) ) = 0.67319814951254 With PHP 5.2 I only get: cos( deg2rad( 47.685618 ) ) = 0.673198149513 Two decimal places shorter but I need them. I know I also can do the calulation with mysql, but in my case it need to be done with PHP. I hope you can help me? Thx.
0
0
0
0
1
0
Write a program that takes 3 integers separated by spaces and perform every single combination of addition, subtraction, multiplication and division operations possible and display the result with the operation combination used. Example: $./solution 1 2 3 Results in the following output 1+2+3 = 6 1-2-3 = -4 1*2*3 = 6 1/2/3 = 0 (integer answers only, round up at .5) 1*2-3 = -1 3*1+2 = 5 etc... Order of operation rules apply, assume there will be no parenthesis used i.e. (3-1)*2 = 4 is not a combination, although you could implement this for "extra credit" For results where a divide by 0 occurs simply return NaN Edit: Permuting the input is required, i.e., if the input is 1 2 3, then 3*1*2 is a valid combination.
0
0
0
0
1
0
Say the input will always be the same number N of numbers (e.g., 5) and assume the integers actually have a mathematical relation (no lengths of the numbers 'one', 'two', days in the nth month, etc.). The output would be either the next integer and the rule discovered or a message that no rule could be detected. I was thinking to have in one-two-three order, a module that tries to find arithmetic sequence rules by doing sums and/or differences between numbers adjacent, one away, two away, etc. looking for patterns, then having a module focused on geometric sequences by multiplying and/or dividing in the same way, and then, if there is a general approach, a module for detecting recursive sequences. Thanks!
0
0
0
0
1
0
Consider the 0/1 knapsack problem. The standard Dynamic Programming algorithm applies only when the capacity as well as the weights to fill the knapsack with are integers/ rational numbers. What do you do when the capacity/weights are irrational? The issue is that we can't memoize like we do for integer weights because we may need potentially infinite decimal places for irrational weights - leading to an infinitely large number of columns for the Dynamic Programming Table . Is there any standard method for solving this? Any comments on the complexity of this problem? Any heuristics? What about associated recurrences like (for example): f(x)=1, for x< sqrt(2) f(x)=f(x-sqrt(2))+sqrt(3),otherwise ? Or the Pibonacci number problem here: http://www.spoj.pl/problems/PIB/ ?
0
0
0
0
1
0
I'm looking for a way to determine the optimal X/Y/Z rotation of a set of vertices for rendering (using the X/Y coordinates, ignoring Z) on a 2D canvas. I've had a couple of ideas, one being pure brute-force involving performing a 3-dimensional loop ranging from 0..359 (either in steps of 1 or more, depending on results/speed requirements) on the set of vertices, measuring the difference between the min/max on both X/Y axis, storing the highest results/rotation pairs and using the most effective pair. The second idea would be to determine the two points with the greatest distance between them in Euclidean distance, calculate the angle required to rotate the 'path' between these two points to lay along the X axis (again, we're ignoring the Z axis, so the depth within the result would not matter) and then repeating several times. The problem I can see with this is first by repeating it we may be overriding our previous rotation with a new rotation, and that the original/subsequent rotation may not neccesarily result in the greatest 2D area used. The second issue being if we use a single iteration, then the same problem occurs - the two points furthest apart may not have other poitns aligned along the same 'path', and as such we will probably not get an optimal rotation for a 2D project. Using the second idea, perhaps using the first say 3 iterations, storing the required rotation angle, and averaging across the 3 would return a more accurate result, as it is taking into account not just a single rotation but the top 3 'pairs'. Please, rip these ideas apart, give insight of your own. I'm intreaged to see what solutions you all may have, or algorithms unknown to me you may quote.
0
0
0
0
1
0
I am looking to create a special type of combination in which no two sets have more than one intersecting element. Let me explain with an example: Let us say we have 9 letter set that contains A, B, C, D, E, F, G, H, and I If you create the standard non-repeating combinations of three letters you will have 9C3 sets. These will contain sets like ABC, ABD, BCD, etc. I am looking to create sets that have at the most only 1 common letter. So in this example, we will get following sets: ABC, ADG, AEI, AFH, BEH, BFG, BDI, CFI, CDH, CEG, DEF, and GHI - note that if you take any two sets there are no more than 1 repeating letter. What would be a good way to generate such sets? It should be scalable solution so that I can do it for a set of 1000 letters, with sub set size of 4. Any help is highly appreciated. Thanks
0
0
0
0
1
0
I am developing functional domain specific embedded language within C++ to translate formulas into working code as concisely and accurately as possible. I posted a prototype in the comments, it is about two hundred lines long. Right now my language looks something like this (well, actually is going to look like): // implies two nested loops j=0:N, i=0,j (range(i) < j < N)[T(i,j) = (T(i,j) - T(j,i))/e(i+j)]; // implies summation over above expression sum(range(i) < j < N))[(T(i,j) - T(j,i))/e(i+j)]; I am looking for possible syntax improvements/extensions or just different ideas about expressing mathematical formulas as clearly and precisely as possible (in any language, not just C++). Can you give me some syntax examples relating to my question which can be accomplished in your language of choice which consider useful. In particular, if you have some ideas about how to translate the above code segments, I would be happy to hear them. Thank you. Just to clarify and give an actual formula, my short-term goal is to express the following expression concisely where values in <> are already computed as 4-dimensional arrays.
0
0
0
0
1
0
I was randomly looking at the FAQ for bu.mp (http://bu.mp/faq), and this part caught my eye: Q: No way. What if somebody else bumps at the same time? Way. We use various techniques to limit the pool of potential matches, including location information and characteristics of the bump event. If you are bumping in a particularly dense area (ex, at a conference), and we cannot resolve a unique match after a single bump, we'll just ask you to bump again. Our CTO has a PhD in Quantum Mechanics and can show the math behind that, but we suggest downloading Bump and trying it yourself! Is there really any reason why there might be some non-trivial math behind bumping, or is the "Our CTO has a PhD in Quantum Mechanics and can show the math behind that" probably just a bit tongue-in-cheek? [I'm having a hard time imagining why something more complicated than looking at the location+time would be necessary, but maybe I'm just underestimating the problem or the kinds of data an iPhone could collect from a bump (e.g., some kind of tremor waveform?).]
0
0
0
0
1
0
I'm using R. I have 25 variables over 15 time points, with 3 or more replicates per variable per time point. I've melted this into a data.frame, which I can plot happily using (amongst other things) ggplot's facet_wrap() command. My melted data frame is called lis; here's its head and tail, so you get an idea of the data: > head(lis) time variable value 1 10 SELL 8.170468 2 10 SELL 8.215892 3 10 SELL 8.214246 4 15 SELL 8.910654 5 15 SELL 7.928537 6 15 SELL 8.777784 > tail(lis) time variable value 145 1 GAS5 10.92248 146 1 GAS5 11.37983 147 1 GAS5 10.95310 148 1 GAS5 11.60476 149 1 GAS5 11.69092 150 1 GAS5 11.70777 I can get a beautiful plot of all the time series, along with a fitted spline and 95% confidence intervals using the following ggplot2 commands: p <- ggplot(lis, aes(x=time, y=value)) + facet_wrap(~variable) p <- p + geom_point() + stat_smooth(method = "lm", formula = y ~ ns(x,3)) The trouble is that the smoother is not to my liking - the 95% confidence intervals are way off. I would like to use Gaussian Processes (GP) to get a better regression and estimate of covariance for my time series. I can fit a GP using something like library(tgp) out <- bgp(X, Y, XX = seq(0, 200, length = 100)) which takes time X, observations Y and makes predictions at each point in XX. The object out contains a bunch of things about those predictions, including a covariance matrix I can use in place of the 95% confidence interval I get (I think?) from ns(). The trouble is I'm not how to wrap this function to make it interface with ggplot2::stat_smooth(). Any ideas or pointers as to how to proceed would be greatly appreciated!
0
0
0
1
0
0
I solved this problem by following a straightforward but not optimal algorithm. I sorted the vector in descending order and after that substracted numbers from max to min to see if I get a + b + c = d. Notice that I haven't used anywhere the fact that elements are natural, distinct and 10 000 at most. I suppose these details are the key. Does anyone here have a hint over an optimal way of solving this? Thank you in advance! Later Edit: My idea goes like this: '<<quicksort in descending order>>' for i:=0 to count { // after sorting, loop through the array int d := v[i]; for j:=i+1 to count { int dif1 := d - v[j]; int a := v[j]; for k:=j+1 to count { if (v[k] > dif1) continue; int dif2 := dif1 - v[k]; b := v[k]; for l:=k+1 to count { if (dif2 = v[l]) { c := dif2; return {a, b, c, d} } } } } } What do you think?(sorry for the bad indentation)
0
0
0
0
1
0
I know relational databases are based on set-theory, functional programming is based on lambda calculus, logic programming is based on logic (of course :)), and now that I think of it; I'm not sure if imperative and generic programming is based on any particular branch of mathematics either.
0
0
0
0
1
0
Aye it's been done a million times before, but damnit I want to do it again. I'm writing a simple Matrix Library for C++ with the intention of doing it right. I've come across something that's fairly obvious in mathematics, but not so obvious to a strongly typed system -- the fact that a 1x1 matrix is just a number. To avoid this, I started walking down the hairy path of matrices as a composition of vectors, but also stumbled upon the fact that two vectors multiplied together could either be a number or a dyad, depending on the orientation of the two. My question is, what is the right way to deal with this situation in a strongly typed language like C++ or Java?
0
0
0
0
1
0
I have no clue of where to start on this. I've never done any NLP and only programmed in Python 3.1, which I have to use. I'm looking at the site http://www.linkedin.com and I have to gather all of the public profiles and some of them have very fake names, like 'aaaaaa k dudujjek' and I've been told I can use NLP to find the real names, where would I even start?
0
1
0
0
0
0
I'm looking for some guidance about which techniques/algorithms I should research to solve the following problem. I've currently got an algorithm that clusters similar-sounding mp3s using acoustic fingerprinting. In each cluster, I have all the different metadata (song/artist/album) for each file. For that cluster, I'd like to pick the "best" song/artist/album metadata that matches an existing row in my database, or if there is no best match, decide to insert a new row. For a cluster, there is generally some correct metadata, but individual files have many types of problems: Artist/songs are completely misnamed, or just slightly mispelled the artist/song/album is missing, but the rest of the information is there the song is actually a live recording, but only some of the files in the cluster are labeled as such. there may be very little metadata, in some cases just the file name, which might be artist - song.mp3, or artist - album - song.mp3, or another variation A simple voting algorithm works fairly well, but I'd like to have something I can train on a large set of data that might pick up more nuances than what I've got right now. Any links to papers or similar projects would be greatly appreciated. Thanks!
0
0
0
1
0
0
In a current project, people can order goods delivered to their door and choose 'pay on delivery' as a payment option. To make sure the delivery guy has enough change customers are asked to input the amount they will pay (e.g. delivery is 48,13, they will pay with 60,- (3*20,-)). Now, if it were up to me I'd make it a free field, but apparantly higher-ups have decided is should be a selection based on available denominations, without giving amounts that would result in a set of denominations which could be smaller. Example: denominations = [1,2,5,10,20,50] price = 78.12 possibilities: 79 (multitude of options), 80 (e.g. 4*20) 90 (e.g. 50+2*20) 100 (2*50) It's international, so the denominations could change, and the algorithm should be based on that list. The closest I have come which seems to work is this: for all denominations in reversed order (large=>small) add ceil(price/denomination) * denomination to possibles baseprice = floor(price/denomination) * denomination; for all smaller denominations as subdenomination in reversed order add baseprice + (ceil((price - baseprice) / subdenomination) * subdenomination) to possibles end for end for remove doubles sort Is seems to work, but this has emerged after wildly trying all kinds of compact algorithms, and I cannot defend why it works, which could lead to some edge-case / new countries getting wrong options, and it does generate some serious amounts of doubles. As this is probably not a new problem, and Google et al. could not provide me with an answer save for loads of pages calculating how to make exact change, I thought I'd ask SO: have you solved this problem before? Which algorithm? Any proof it will always work?
0
0
0
0
1
0
I'm looking for a library to find the integral of a given set of random data (rather than a function) in C++ (or C, but preferably C++). There is another question asking about integration in C but the answers discuss more how to integrate a function (I think...). I understand that this can be done simply by calculating the area under the line segment between each pair of points from start to finish, but I'd rather not reinvent the wheel if this has already been done. I apologize in advance if this is a duplicate; I searched pretty extensively to no avail. My math isn't as strong as I'd like it so it's entirely possible I'm using the wrong terminology. Thanks in advance for any help! Chris Edit: In case anybody is interested, I feel like an idiot. Even adding in a bunch of OO abstraction to make my other code easier to use, that was maybe 30 lines of code. This is what 3 years away from any sort of math will do to you...thanks for all of the help!
0
0
0
0
1
0
everybody. I am entirely new to the topic of classification algorithms, and need a few good pointers about where to start some "serious reading". I am right now in the process of finding out, whether machine learning and automated classification algorithms could be a worthwhile thing to add to some application of mine. I already scanned through "How to Solve It: Modern heuristics" by Z. Michalewicz and D. Fogel (in particular, the chapters about linear classifiers using neuronal networks), and on the practical side, I am currently looking through the WEKA toolkit source code. My next (planned) step would be to dive into the realm of Bayesian classification algorithms. Unfortunately, I am lacking a serious theoretical foundation in this area (let alone, having used it in any way as of yet), so any hints at where to look next would be appreciated; in particular, a good introduction of available classification algorithms would be helpful. Being more a craftsman and less a theoretician, the more practical, the better... Hints, anyone?
0
1
0
1
0
0
There is a recurrence equation on page 1789 of this paper and I need some help making a python program to calculate pi_i. I have no idea what is going on here. Other references:original paper, pages (according to adobe, not the physical pages) 43 and 86 edit and i had already deleted what i wrote because all the answers i got were 0, even though all the values were floats. i believe what i had looked somewhat like the code posted below
0
0
0
0
1
0
I'm in the middle of porting David Blei's original C implementation of Latent Dirichlet Allocation to Haskell, and I'm trying to decide whether to leave some of the low-level stuff in C. The following function is one example—it's an approximation of the second derivative of lgamma: double trigamma(double x) { double p; int i; x=x+6; p=1/(x*x); p=(((((0.075757575757576*p-0.033333333333333)*p+0.0238095238095238) *p-0.033333333333333)*p+0.166666666666667)*p+1)/x+0.5*p; for (i=0; i<6 ;i++) { x=x-1; p=1/(x*x)+p; } return(p); } I've translated this into more or less idiomatic Haskell as follows: trigamma :: Double -> Double trigamma x = snd $ last $ take 7 $ iterate next (x' - 1, p') where x' = x + 6 p = 1 / x' ^ 2 p' = p / 2 + c / x' c = foldr1 (\a b -> (a + b * p)) [1, 1/6, -1/30, 1/42, -1/30, 5/66] next (x, p) = (x - 1, 1 / x ^ 2 + p) The problem is that when I run both through Criterion, my Haskell version is six or seven times slower (I'm compiling with -O2 on GHC 6.12.1). Some similar functions are even worse. I know practically nothing about Haskell performance, and I'm not terribly interested in digging through Core or anything like that, since I can always just call the handful of math-intensive C functions through FFI. But I'm curious about whether there's low-hanging fruit that I'm missing—some kind of extension or library or annotation that I could use to speed up this numeric stuff without making it too ugly. UPDATE: Here are two better solutions, thanks to Don Stewart and Yitz. I've modified Yitz's answer slightly to use Data.Vector. invSq x = 1 / (x * x) computeP x = (((((5/66*p-1/30)*p+1/42)*p-1/30)*p+1/6)*p+1)/x+0.5*p where p = invSq x trigamma_d :: Double -> Double trigamma_d x = go 0 (x + 5) $ computeP $ x + 6 where go :: Int -> Double -> Double -> Double go !i !x !p | i >= 6 = p | otherwise = go (i+1) (x-1) (1 / (x*x) + p) trigamma_y :: Double -> Double trigamma_y x = V.foldl' (+) (computeP $ x + 6) $ V.map invSq $ V.enumFromN x 6 The performance of the two seems to be almost exactly the same, with one or the other winning by a percentage point or two depending on the compiler flags. As camccann said over at Reddit, the moral of the story is "For best results, use Don Stewart as your GHC backend code generator." Barring that solution, the safest bet seems to be just to translate the C control structures directly into Haskell, although loop fusion can give similar performance in a more idiomatic style. I'll probably end up using the Data.Vector approach in my code.
0
0
0
0
1
0
I'm learning about the theory of the projective plane. Very generally speaking, it is an extension of the plane, which includes additional points which are defined as the intersection points of two parallel lines. In the projective plane, every two lines have an interesection point. Whether they're parallel or not. Every point in the projective plane can be represented by three numbers (you actually need less than that, but nevemind now). Is there any real life application which uses the projective plane? I can think that, for instance, a software which needs to find the intersections of a line, can benefit from always having an intersection point which might lead to simpler code, but is it really used?
0
0
0
0
1
0
Given an arbitary polygon with vertices stored in either clockwise/counterclockwise fashion (depicted as a black rectangle in the diagram), I need to be able to subtract an arbitrary number of circles (in red on the diagram) from that polygon. Removing a circle could possibly split the polygon into two seperate polygons (as depicted by the second line in the diagram). I'm not sure where to start. Example http://www.freeimagehosting.net/uploads/89a0276d9d.jpg
0
0
0
0
1
0
I have a set of data (in ArrayCollection) and I need to fit a power function { f(x)= B + x^alpha } to it, before display in LineChart. As result I need the alpha and B paremeter. How to do this with Flex?
0
0
0
0
1
0
>>> import math >>> math.pow(2, 3000) Traceback (most recent call last): File "<stdin>", line 1, in <module> OverflowError: math range error How can I fix it?
0
0
0
0
1
0
First of all thanks for your time reading my question :-) I have an original image (w': 2124, h': 3204) and the same image scaled (w: 512, h: 768). The ratio for width is 4.14 (rw) and the ratio for height is 4.17 (rh). I'm trying to know the coordinates (x', y') in the original image when I receive the coordinates in the scaled image (x, y). I'm using the formula: x' = x * rw and y' = y * rh. But when I'm painting a line, or a rectangle always appears a shift that is incremented when x or y is higher. Please anybody knows how do I transform coordinates without losing accuracy? Thanks in advance! Oscar.
0
0
0
0
1
0
There are two data types: tasks and actions. An action costs a certain time to complete, and a set of tasks this actions consists of. A task has a set of actions, and our job is to choose one of them. So: class Task { Set<Action> choices; } class Action { float time; Set<Task> dependencies; } For example the primary task could be "Get a house". The possible actions for this task: "Buy a house" or "Build a house". The action "Build a house" costs 10 hours and has the dependencies "Get bricks" (which may cost 6 hours) and "Get cement" (which costs 9 hours), etcetera. The total time is the sum of all the times of the actions required to perform (in this case 10+6+9 hours). We want to choose actions such that the total time is minimal. Note that the dependencies can be diamond shaped. For example "Get bricks" could require "Get a car" (to transport the bricks) and "Get cement" would also require a car. Even if you do "Get bricks" and "Get cement" you only have to count the time it takes to get a car once. Note also that the dependencies can be circular. For example "Money" -> "Job" -> "Car" -> "Money". This is no problem for us, we simply select all of "Money", "Job" and "Car". The total time is simply the sum of the time of these 3 things. Mathematical description: Let actions be the chosen actions. valid(task) = ∃action ∈ task.choices. (action ∈ actions ∧ ∀tasks ∈ action.dependencies. valid(task)) time = sum {action.time | action ∈ actions} minimize time subject to valid(primaryTask) I'm interested in an optimal solution but also in an approximate solution. Perhaps some kind of dynamic programming can help there? If the problem is tree structured then dynamic programming can give an optimal solution in polynomial time, but diamond structures seem to make the problem much more difficult. If you have an algorithm but it doesn't work if there are cycles, do post it! I can probably still learn a lot from it. The boxes represent tasks and the circles represent actions (the time to perform the action is in the circle). An action has a line to a task if that task is a dependency for the action. Here's the description of the problem again in terms of pictures: if a rectangle (=task) is chosen, then one of the circles (=actions) inside must be chosen. If a circle is chosen, then all of the connected rectangles must be chosen. The goal is to minimize the sum of the numbers in the chosen circles. An optimal solution in this case is to choose the action with time 2 in the top task, and the actions with time 1 in the bottom tasks. The total time is 2+1+1=4. In this case there are 2 optimal solutions. The second solution is to choose the action with time 3 in the top task, and the action with time 1 in the bottom right task. The total time is 3+1=4 again. If we choose the action with time 3 in the top task we do not have to perform the left bottom task, because there is no line between the action with time 3 and the left bottom task. I apologize for the crappy drawing ;) And two more examples (the optimal solution for each has been indicated with blue, and the primary task has been indicated with grey):
0
0
0
0
1
0
How can I compute the z-score for matrices in Python? Suppose I have the array: a = array([[ 1, 2, 3], [ 30, 35, 36], [2000, 6000, 8000]]) and I want to compute the z-score for each row. The solution I came up with is: array([zs(item) for item in a]) where zs is in scipy.stats.stats. Is there a better built-in vectorized way to do this? Also, is it always good to z-score numbers before using hierarchical clustering with euclidean or seuclidean distance? Can anyone discuss the relative advantages/disadvantages? thanks.
0
0
0
1
0
0
I have been trying for... about 4 hours now lmao. currentCalc returns 50 currentSum returns 0 when i alert them. Yet I cannot add them together with parseInt???? what am i doing wrong :'( var identRow = $('tr.identRow'); identRow.each(function () { var getIdentClass = $(this).attr('class').split(' ').slice(1); $('tr.ohp' + getIdentClass + ' td.EURm').each(function (index) { var currentCalc = parseInt($(this).text().replace('.', ''), 10); var currentSum = $('tr.' + getIdentClass + ' td.totalEURm', this).text().replace('.', ''); total = parseInt(currentCalc, 10) + parseInt(currentSum, 10); $('tr.' + getIdentClass + ' td.totalEURm').text(total); if (index == 6) { alert(total); } }); }); EDIT: Oh goodness. Im completely confused now. I putr the break there. It says total = 50. I want each iteration to add itself to the total. That is why I add currentCalc to the text of the field im plopping the currentCalc into. $('tr.' + getIdentClass + ' td.totalEURm').text(total); with my code now like this: var identRow = $('tr.identRow'); identRow.each(function () { var getIdentClass = $(this).attr('class').split(' ').slice(1); $('tr.ohp' + getIdentClass + ' td.EURm').each( function (index) { var currentCalc = parseInt($(this).text().replace('.', ''), 10) || 0; var currentSum = parseInt($('tr.' + getIdentClass + ' td.totalEURm', this).text().replace('.', ''), 10) || 0; var total = currentCalc + currentSum; $('tr.' + getIdentClass + ' td.totalEURm').text(total); if (index === 6) { alert(total); } }); }); it alerts: 50, then 0, then 50, then 0. EDIT: How do I add currentCalc to its last value? So first iteration its 10, seconds its 20. How do i make it so on the 2nd iteration it equals 30. currentCalc++ is just adding 1 to it. Now you understand how crap i am :)
0
0
0
0
1
0
I want to implement a media recommendation engine. I saw a similar posts on this, but I think my requirements are bit different from those, so posting here. Here is the deal. I want to implement a recommendation engine for media players like VLC, which would be an engine that has to care for only single user. Like, it would be embedded in a media player on a PC which is typically used by single user. And it will start learning the likes and dislikes of the user and gradually learns what a user likes. Here it will not be able to find similar users for using their data for recommendation as its a single user system. So how to go about this? Or you can consider it as a recommendation engine that has to be put in say iPods, which has to learn about a single user and recommend music/Movies from the collections it has. I thought of start collecting the genre of music/movies (maybe even artist name) that user watches and recommend movies from the most watched Genre, but it look very crude, isn't it? So is there any algorithms I can use or any resources I can refer up to? Regards, MicroKernel :)
0
1
0
0
0
0
Given a circle with a known center point and two points on the circle (thus known radius), how do I determine the angle of the minimum arc between the two points on the circle?
0
0
0
0
1
0
I have four objects - for the sake of arguments, let say that they are the following letters: A B C D I need to calculate the number of variations that can be made for these under the following two conditions: No repetition Objects are position agnostic Taking the above, this means that with a four object sequence, I can have only one sequence that matches the criteria (since order is not considered for being unique): ABCD There are four variations for a three object combination from the four object pool: ABC, ABD, ACD, and BCD There are six variations for a two object combination from the four object pool: AB, AC, AD, BC, BD, and CD And the most simple one, if taken on at a time: A, B, C, and D I swear that this was something covered in school, many, many years ago - and probably forgotten since I didn't think I would use it. :-) I am anticipating that factorials will come into play, but just trying to force an equation is not working. Any advice would be appreciated.
0
0
0
0
1
0
I have a robot that uses an optical mouse as a position track. Basically, as the robot moves it is able to track change in X and Y directions using the mouse. The mouse also tracks which direction you are moving - ie negative X or positive X. These values are summed into separate X and Y registers. Now, the robot rotates in place and moves forward only. So the movement of the robot is ideally in straight lines (although the mouse tracking can pickup deviations if you veer off) at particular angles. A particular set of movements of the robot would be like: A: Rotate 45 degrees, move 3 inches B: Rotate 90 degrees, move 10 inches C: Rotate -110 degrees, move 5 inches D: Rotate 10 degrees, move 1 inch But each time the mouse X and mouse Y registers give the real distances you moved in each direction. Now, if I want to repeat the movement set going from A to D only, how can I do this using the information I have already gathered. I know I can basically sum all the angles and distances I feed into it already, but this would prove to be inaccurate if there were large errors in each movement orders. How can I use the raw information from my mouse? A friend provided an idea that I could continuously sine and cosine the mouse values and calculate the final vector but I'm not really sure how this would work. The problem is that the mouse only gives relative readings so rotating or moving backwards, you are potentially erasing information. So yeah, what I am wondering is how you can implement the algorithm so it can continually track changes to give you a shortest path if you moved in zigzags to get there originally.
0
1
0
0
0
0
How could I, having a path defined by several points that are not in a uniform distance from each other, redefine along the same path the same number of points but with a uniform distance. I'm trying to do this in Objective-C with NSArrays of CGPoints but so far I haven't had any luck with this. Thank you for any help. EDIT I was wondering if it would help to reduce the number of points, like when detecting if 3 points are collinear we could remove the middle one, but I'm not sure that would help. EDIT Illustrating: Reds are the original points, blues the post processed points: The new path defined by the blue dots does not correspond to the original one.
0
0
0
0
1
0
I know, Int32.MaxValue * Int32.MaxValue will yield a number larger than Int32; But, shouldn't this statement raise some kind of an exception? I ran across this when doing something like IF (X * Y > Z) where all are Int32. X and Y are sufficiently large enough, you get a bogus value from X * Y. Why is this so and how to get around this? besides casting everything to Int64.
0
0
0
0
1
0
The ellipse is actually a circle. I know all the coordinates of both things, I just need to know whether or not a line goes through an ellipse. Is this built in anywhere? SPecifically I am using QGraphicsEllipseIem and QLine but i can convert them to any other type thanks
0
0
0
0
1
0
I want to use SMO (Sequential Minimal Optimization) in order to train an SVM (Support Vector Machine). Can anyone suggest existing C++ libraries which implement SMO? I plan to use this to train an SVM to find an object in a picture (probably a human).
0
0
0
1
0
0
i'm terrible at math. trust me, you math experts will see why after reading my question. i have an object that is 300px in height. i need to calculate the percentage of that height where 90% = 300px (or the full height), 45% = 150px, 0% = 0px. so essentially, if i ask for 45% of the object's height, it will return 150px, or if i ask for 32% of the object's height, it will return ____? i believe this is really basic math, so i apologize in advance.
0
0
0
0
1
0
Is there a tool which converts a graphical representation of an equation to that equation? (Graphical representation to aprox. math equation)
0
0
0
0
1
0
Possible Duplicate: Math - mapping numbers I have value "x" that can be from 0 to 127 and a value "y" that can be from -1000 to 0. I need to make that if x = 0 than y = -1000 and if x = 127 than y = 0... How can i make it?
0
0
0
0
1
0
How do you solve something like 7Xd =(congruent to) 1 mod 40? find the smallest d that satisfies this equation
0
0
0
0
1
0
On my midterm I had the problem: T(n) = 8T(n/2) + n^3 and I am supposed to find its big theta notation using either the masters or alternative method. So what I did was a = 8, b = 2 k = 3 log28 = 3 = k therefore, T(n) is big theta n3. I got 1/3 points so I must be wrong. What did I do wrong?
0
0
0
0
1
0
I'm trying to find the angle of the the triangle in MATLAB. e.g. in the triangle below, I want to find the angle of ABC (marked as black). if a = 40, b=50, How I can I find the angle (in degree) of ABC in MATLAB ? Thanks
0
0
0
0
1
0
We know that the general form of complex numbers is like this: z=a+i*b, where i is sqrt(-1). I have a question about how to express this in Java ?
0
0
0
0
1
0
It might be that my math is rusty or I'm just stuck in my box after trying to solve this for so long, either way I need your help. Background: I'm making a 2d-based game in C# using XNA. In that game I want a camera to be able to zoom in/out so that a certain part of objects always are in view. Needless to say, the objects move in two dimensions while the camera moves in three. Situation: I'm currently using basic trigonometry to calculate which height the camera should be at for all objects to show. I also position the camera between those objects. It looks something like this: 1.Loop through all objects to find the outer edges of our objects : farRight, farLeft, farUp, farDown. 2.When we know what the edges of what has to be shown are, calculate the center, also known as the camera position: CenterX = farLeft + (farRight - farLeft) * 0.5f; CenterY = farUp + (farDown - farUp) * 0.5f; 3.Loop through our edges to find the largest value compared to our camera position, thus the furthest distance from the center of screen. 4.Using the largest distance-value we can easily calculate the needed height to show all of those objects (points): float T = 90f - Constants.CAMERA_FIELDOFVIEW * 0.5f; float height = (float)Math.Tan(MathHelper.ToRadians(T)) * (length); So far so good, the camera positions itself perfectly based on the calculations. Problem: a) My rendering target is 1280*720 with a Field of View of 45 degrees, so one always sees a bit more on the X-axis, 560 pixels more actually. This is not a problem per se but more one that on b)... b) I want the camera to be a bit further out than it is, so that one sees a bit more on what is happening beyond the furthest point. Sure, this happens on the X-axis, but that is technically my flawed logic's result. I want to be able to see more on both the X- and Y-axis and to control this behavior. Question Uhm, so to clarify. I would like to have some input on a way to make the camera position itself, creating this state: Objects won't get closer than say... 150 pixels to the edge of the X-axis and 100 pixels to the edge of the Y-axis. To do this the camera shall position itself along the Z-axis so that the field of view covers it all. I don't need help with the coding, just the math and logic of calculating the height of my camera. As you probably can see, I have a hard time wrapping this inside my head and even harder time trying to explain it to you. If anyone out there has been dealing with this or is just better than me at math, I'd appreciate whatever you have to say! :)
0
0
0
0
1
0
i have a mathematical problem: i have a function where the only parameter is the current time. the return should be a position which is used to place an object on a certain place. int position(int time) { int x = 0; //TODO implement x depending on time return x; } so basically the function is called every frame to put the object in motion. the motion should look like this (this is the actual question): a linear motion for time A, the object moves at constant speed no motion for time B, the object is stopped repeat at 1. thanks! edit: ok in other words: imagine a car that drives at constant speed for A minutes and then stops for B minutes. then drives again for A minutes and stops again for B minutes. where is the car at time X?
0
0
0
0
1
0
Can anyone suggest some clustering algorithm which can work with distance matrix as an input? Or the algorithm which can assess the "goodness" of the clustering also based on the distance matrix? At this moment I'm using a modification of Kruskal's algorithm (http://en.wikipedia.org/wiki/Kruskal%27s_algorithm) to split data into two clusters. It has a problem though. When the data has no distinct clusters the algorithm will still create two clusters with one cluster containing one element and the other containing all the rest. In this case I would rather have one cluster containing all the elements and another one which is empty. Are there any algorithms which are capable of doing this type of clustering? Are there any algorithms which can estimate how well the clustering was done or even better how many clusters are there in the data? The algorithms should work only with distance(similarity) matrices as an input.
0
0
0
0
1
0
I'm searching for a plot .NET component to plot a 2D line chart, given an array of data. It will be used with WindowsForm (C#) and It will be very helpful if it could be freeware. It is for a scientific application. This is my first asked question in stackoverflow, and excuse me for my terrible English written.
0
0
0
0
1
0
I'm constructing a geolocation based application and I'm trying to figure out a way to make my application realise when a user is facing the direction of the given location (a particular long / lat co-ord). I've got the math figured, I just have the triangle to construct. //UPDATE So I've figured out a good bit of this... Below is a method which takes in a long / lat value and attempts to compute a triangle finding a point 700 meters away and one to its left + right. It'd then use these to construct the triangle. It computes the correct longitude but the latitude ends up somewhere off the coast of east Africa. (I'm in Ireland!). public void drawtri(double currlng,double currlat, double bearing){ bearing = (bearing < 0 ? -bearing : bearing); System.out.println("RUNNING THE DRAW TRIANGLE METHOD!!!!!"); System.out.println("CURRENT LNG" + currlng); System.out.println("CURRENT LAT" + currlat); System.out.println("CURRENT BEARING" + bearing); //Find point X(x,y) double distance = 0.7; //700 meters. double R = 6371.0; //The radius of the earth. //Finding X's y value. Math.toRadians(currlng); Math.toRadians(currlat); Math.toRadians(bearing); distance = distance/R; Global.Alat = Math.asin(Math.sin(currlat)*Math.cos(distance)+ Math.cos(currlat)*Math.sin(distance)*Math.cos(bearing)); System.out.println("CURRENT ALAT!!: " + Global.Alat); //Finding X's x value. Global.Alng = currlng + Math.atan2(Math.sin(bearing)*Math.sin(distance) *Math.cos(currlat), Math.cos(distance)-Math.sin(currlat)*Math.sin(Global.Alat)); Math.toDegrees(Global.Alat); Math.toDegrees(Global.Alng); //Co-ord of Point B(x,y) // Note: Lng = X axis, Lat = Y axis. Global.Blat = Global.Alat+ 00.007931; Global.Blng = Global.Alng; //Co-ord of Point C(x,y) Global.Clat = Global.Alat - 00.007931; Global.Clng = Global.Alng; } From debugging I've determined the problem lies with the computation of the latitude done here.. Global.Alat = Math.asin(Math.sin(currlat)*Math.cos(distance)+ Math.cos(currlat)*Math.sin(distance)*Math.cos(bearing)); I have no idea why though and don't know how to fix it. I got the formula from this site.. http://www.movable-type.co.uk/scripts/latlong.html It appears correct and I've tested multiple things... I've tried converting to Radians then post computations back to degrees, etc. etc. Anyone got any ideas how to fix this method so that it will map the triangle ONLY 700 meters in from my current location in the direction that I am facing? Thanks,
0
0
0
0
1
0
Possible Duplicate: Why does (360 / 24) / 60 = 0 … in Java This line of code: System.out.println ("array[j], "+array[j]+", divided by sum, "+sum+", equals: array[j]/sum: "+ array[j]/sum) ; is yeilding this line of text: array[j], 21, divided by sum, 100, equals: array[j]/sum: 0 why is it doing this? (everything is right eccept that the answer should be .21)
0
0
0
0
1
0
I have a set of simple (no holes, no self-intersections) polygons, and I need to check that they don't intersect each other (one can be entirely contained in another; that is okay). I can check this by simply checking the per-vertex inside-ness of one polygon versus other polygons. I also need to determine the containment tree, which is the set of relationships that say which polygon contains any given polygon. Since no polygon can intersect any other, then any contained polygon has a unique container; the "next-bigger" one. In other words, if A contains B contains C, then A is the parent of B, and B is the parent of C, and we don't consider A the parent of C. The question: How do I efficiently determine the containment relationships and check the non-intersection criterion? I ask this as one question because maybe a combined algorithm is more efficient than solving each problem separately. The algorithm should take as input a list of polygons, given by a list of their vertices. It should produce a boolean B indicating if none of the polygons intersect any other polygon, and also if B = true, a list of pairs (P, C) where polygon P is the parent of child C. This is not homework. This is for a hobby project I am working on.
0
0
0
0
1
0
i would like to write a simple line of code, without resorting to if statements, that would evaluate whether a number is within a certain range. i can evaluate from 0 - Max by using the modulus. 30 % 90 = 30 //great however, if the test number is greater than the maximum, using modulus will simply start it at 0 for the remaining, where as i would like to limit it to the maximum if it's past the maximum 94 % 90 = 4 //i would like answer to be 90 it becomes even more complicated, to me anyway, if i introduce a minimum for the range. for example: minimum = 10 maximum = 90 therefore, any number i evaluate should be either within range, or the minimum value if it's below range and the maximum value if it's above range -76 should be 10 2 should be 10 30 should be 30 89 should be 89 98 should be 90 23553 should be 90 is it possible to evaluate this with one line of code without using if statements?
0
0
0
0
1
0
does anybody familiar with a way that I could implement a matrix with values from a field (not the real or complex number, but lets say Z mod p). so I could perform all the operation of matlab on the matrix (with the values of the chosen field) Ariel
0
0
0
0
1
0
I am trying to use IDF scores to find interesting phrases in my pretty huge corpus of documents. I basically need something like Amazon's Statistically Improbable Phrases, i.e. phrases that distinguish a document from all the others The problem that I am running into is that some (3,4)-grams in my data which have super-high idf actually consist of component unigrams and bigrams which have really low idf.. For example, "you've never tried" has a very high idf, while each of the component unigrams have very low idf.. I need to come up with a function that can take in document frequencies of an n-gram and all its component (n-k)-grams and return a more meaningful measure of how much this phrase will distinguish the parent document from the rest. If I were dealing with probabilities, I would try interpolation or backoff models.. I am not sure what assumptions/intuitions those models leverage to perform well, and so how well they would do for IDF scores. Anybody has any better ideas?
0
1
0
1
0
0
Given.. 1 - The start-point GPS coordinates, 2 - The end-point GPS coordinates, 3 - The speed at which the object is travelling, 4 - Knowing that the trip trajectory will be a straight line... How can I calculate what my GPS coordinated will be in n minutes' time? That is to say, how can I calculate my position at a given time after the trip has started before the trip has ended?
0
0
0
0
1
0
Criteria for 'better': fast in math and simple (few fields, many records) db transactions, convenient to develop/read/extend, flexible, connectible. The task is to use a common web development scripting language to process and calculate long time series and multidimensional surfaces (mostly selecting/inserting sets of floats and doing maths with them). The choice is Ruby 1.9, Python 2, Python 3, PHP 5.3, Perl 5.12, or JavaScript (node.js). All the data is to be stored in a relational database (due to its heavily multidimensional nature); all the communication with outer world is to be done by means of web services.
0
0
0
0
1
0
I'm working on some code where I have a Time object with a member time. Time.time gives me the time since my application started in seconds (float value). Now I want to create a pulsating value between 0 and 1 and then from 1 to 0 again, which continues doing thins untill the application stops. I was thinking to use sin() but don't know what to pass to it as paramters to create this pulsing value. How would I create this pulsating value? Kind regards, Pollux
0
0
0
0
1
0
Is there any good reference to Algorithms that people use for rare event detection ? Also, How is the time factor taken into account ? If i have a case where successive data points tell something (t_1 to t_n) , How can one factor this into normal Machine learning scenario ? Any pointer will be appreciated.
0
0
0
1
0
0
I wished I paid more attention to the math classes back in Uni. :) How do I implement this math formula for naked triples? Naked Triples Take three cells C = {c1, c2, c3} that share a unit U. Take three numbers N = {n1, n2, n3}. If each cell in C has as its candidates ci ⊆ N then we can remove all ni ∈ N from the other cells in U.** I have a method that takes a Unit (e.g. a Box, a row or a column) as parameter. The unit contains 9 cells, therefore I need to compare all combinations of 3 cells at a time that from the box, perhaps put them into a stack or collection for further calculation. Next step would be taking these 3-cell-combinations one by one and compare their candidates against 3 numbers. Again these 3 numbers can be any possible combination from 1 to 9. Thats all I need. But how would I do that? How many combinations would I get? Do I get 3 x 9 = 27 combinations for cells and then the same for numbers (N)? How would you solve this in classic C# loops? No Lambda expression please I am already confused enough :) Code: I had to cut the classes short in order to represent them here. public class Cell : INotifyPropertyChanged { public ObservableCollection<ObservableCollection<Candidate>> CandidateActual {...} public int Id { ... } //Position of the Cell inside a box if applicable public int CellBoxPositionX { get; private set; } public int CellBoxPositionY { get; private set; } //Position of the Cell inside the game board public int CellBoardPositionX { get; private set; } public int CellBoardPositionY { get; private set; } //Position of the Box inside the game board public int BoxPositionX { get; private set; } public int BoxPositionY { get; private set; } public int CountCandidates { ... } public int? Value { ...} public Candidate this[int number] { get { if (number < 1 || number > PossibleValues.Count) { throw new ArgumentOutOfRangeException("number", number, "Invalid Number Index"); } switch (number) { case 1: return CandidateActual[0][0]; case 2: return CandidateActual[0][1]; case 3: return CandidateActual[0][2]; case 4: return CandidateActual[1][0]; case 5: return CandidateActual[1][1]; case 6: return CandidateActual[1][2]; case 7: return CandidateActual[2][0]; case 8: return CandidateActual[2][1]; case 9: return CandidateActual[2][2]; default: return null; } } } } Candidate public class Candidate : INotifyPropertyChanged { private int? _value; public int? Value { ... } } Box: public class Box : INotifyPropertyChanged { public ObservableCollection<ObservableCollection<Cell>> BoxActual { ... } public Cell this[int row, int column] { get { if(row < 0 || row >= BoxActual.Count) { throw new ArgumentOutOfRangeException("row", row, "Invalid Row Index"); } if(column < 0 || column >= BoxActual.Count) { throw new ArgumentOutOfRangeException("column", column, "Invalid Column Index"); } return BoxActual[row][column]; } } } Board public class Board : INotifyPropertyChanged { public ObservableCollection<ObservableCollection<Box>> GameBoard {...} public Cell this[int boardRowPosition, int boardColumnPosition] { get { int totalSize = GameBoard.Count*GameBoard.Count(); if (boardRowPosition < 0 || boardRowPosition >= totalSize) throw new ArgumentOutOfRangeException("boardRowPosition", boardRowPosition, "Invalid boardRowPosition index"); if (boardColumnPosition < 0 || boardColumnPosition >= totalSize) throw new ArgumentOutOfRangeException("boardColumnPosition", boardColumnPosition, "Invalid boardColumnPosition index"); return GameBoard[boardRowPosition/GameBoard.Count][boardColumnPosition/GameBoard.Count][ boardRowPosition%GameBoard.Count, boardColumnPosition%GameBoard.Count]; } } public Box this[int boardRowPosition, int boardColumnPosition, bool b] { get { int totalSize = GameBoard.Count * GameBoard.Count(); if (boardRowPosition < 0 || boardRowPosition >= totalSize) throw new ArgumentOutOfRangeException("boardRowPosition", boardRowPosition, "Invalid boardRowPosition index"); if (boardColumnPosition < 0 || boardColumnPosition >= totalSize) throw new ArgumentOutOfRangeException("boardColumnPosition", boardColumnPosition, "Invalid boardColumnPosition index"); return GameBoard[boardRowPosition / GameBoard.Count][boardColumnPosition / GameBoard.Count]; } } } Many Thanks for any help,
0
0
0
0
1
0
I am trying to code a function for a camera that orbits a point. Assume a 3d coordinate plane where Z is up. Ignore Z. Let's say the camera's position starts at (0, 0, z). The object to orbit is at, say (50, 50, z). So we have a distance of ~70 units. Calling the function with {(50, 50, z), 70, x} where x is the position in orbit, in radians, should return where the position of the camera should be. I believe this involves cos and tan but my trig isn't that great... point3d getCameraPosition(point3d objectPosition, float distance, float rotationRadians) { // ??? }
0
0
0
0
1
0
I'm in the process of creating a game where the user will be presented with 2 sets of colored tiles. In order to ensure that the puzzle is solvable, I start with one set, copy it to a second set, then swap tiles from one set to another. Currently, (and this is where my issue lies) the number of swaps is determined by the level the user is playing - 1 swap for level 1, 2 swaps for level 2, etc. This same number of swaps is used as a goal in the game. The user must complete the puzzle by swapping a tile from one set to the other to make the 2 sets match (by color). The order of the tiles in the (user) solved puzzle doesn't matter as long as the 2 sets match. The problem I have is that as the number of swaps I used to generate the puzzle approaches the number of tiles in each set, the puzzle becomes easier to solve. Basically, you can just drag from one set in whatever order you need for the second set and solve the puzzle with plenty of moves left. What I am looking to do is after I finish building the puzzle, calculate the minimum number of moves required to solve the puzzle. Again, this is almost always less than the number of swaps used to create the puzzle, especially as the number of swaps approaches the number of tiles in each set. My goal is to calculate the best case scenario and then give the user a "fudge factor" (i.e. 1.2 times the minimum number of moves). Solving the puzzle in under this number of moves will result in passing the level. A little background as to how I currently have the game configured: Levels 1 to 10: 9 tiles in each set. 5 different color tiles. Levels 11 to 20: 12 tiles in each set. 7 different color tiles. Levels 21 to 25: 15 tiles in each set. 10 different color tiles. Swapping within a set is not allowed. For each level, there will be at least 2 tiles of a given color (one for each set in the solved puzzle). Is there any type of algorithm anyone could recommend to calculate the minimum number of moves to solve a given puzzle?
0
0
0
0
1
0
I've looked at the related threads on StackOverflow and Googled with not much luck. I'm also very new to Java (I'm coming from a C# and .NET background) so please bear with me. There is so much available in the Java world it's pretty overwhelming. I'm starting on a new Java-on-Linux project that requires some heavy and highly repetitious numerical calculations (i.e. statistics, FFT, Linear Algebra, Matrices, etc.). So maximizing the performance of the mathematical operations is a requirement, as is ensuring the math is correct. So hence I have an interest in finding a Java library that perhaps leverages native acceleration such as MKL, and is proven (so commercial options are definitely a possibility here). In the .NET space there are highly optimized and MKL accelerated commercial Mathematical libraries such as Centerspace NMath and Extreme Optimization. Is there anything comparable in Java? Most of the math libraries I have found for Java either do not seem to be actively maintained (such as Colt) or do not appear to leverage MKL or other native acceleration (such as Apache Commons Math). I have considered trying to leverage MKL directly from Java myself (e.g. JNI), but me being new to Java (let alone interoperating between Java and native libraries) it seemed smarter finding a Java library that has already done this correctly, efficiently, and is proven. Again I apologize if I am mistaken or misguided (even in regarding any libraries I've mentioned) and my ignorance of the Java offerings. It's a whole new world for me coming from the heavily commercialized Microsoft stack so I could easily be mistaken on where to look and regarding the Java libraries I've mentioned. I would greatly appreciate any help or advice.
0
0
0
0
1
0
I am programming a game and I have come to a very hard spot. Basically I have a circle and I have 2 angles on this circle. Angle 1 (A) is a point I want angle 2 (B) to go to. During my game every frame I need to check weither or not to increase or decrease my angle value by a certain amount (speed) to eventually reach the first angle. My question is how do I do this? I tried doing this but I don't seem to be doing it right. bool increase = false; float B = [self radiansToDegrees:tankAngle]; float A = [self radiansToDegrees:tankDestinationAngle]; float newAngle = B; if(B < A) { float C = B - (360 - A); float D = A - B; if(C < D) increase = false; else increase = true; } else if(B > A) { float C = B - A; float D = A - (360 - B); if(C < D) increase = false; else increase = true; } if(increase) { newAngle += 1.0; } else { newAngle -= 1.0; } if(newAngle > 360.0) { newAngle = 0 + (newAngle - 360.0); } else if(newAngle < 0.0) { newAngle = 360 + newAngle; } if(newAngle == 0) newAngle = 360; newAngle = [self degreesToRadians:newAngle]; [self setTanksProperPositionRotation:newAngle]; The basic effect I am trying to achieve is when the user makes a new point, which would be angle 1, angle 2 would move towards angle 1 choosing the fastest direction. I think I have spent around 4 hours trying to figure this out.
0
0
0
0
1
0
I am working through a problem for my MCTS certification. The program has to calculate pi until the user presses a key, at which point the thread is aborted, the result returned to the main thread and printed in the console. Simple enough, right? This exercise is really meant to be about threading, but I'm running into another problem. The procedure that calculates pi returns -1.#IND. I've read some of the material on the web about this error, but I'm still not sure how to fix it. When I change double to Decimal type, I unsurprisingly get Overflow Exception very quickly. So, the question is how do I store the numbers correctly? Do I have to create a class to somehow store parts of the number when it gets too big to be contained in a Decimal? Class PiCalculator Dim a As Double = 1 Dim b As Double = 1 / Math.Sqrt(2) Dim t As Double = 1 / 4 Dim p As Double = 1 Dim pi As Double Dim callback As DelegateResult Sub New(ByVal _callback As DelegateResult) callback = _callback End Sub Sub Calculate() Try Do While True Dim a1 = (a + b) / 2 Dim b1 = Math.Sqrt(a * b) Dim t1 = t - p * (a - a1) ^ 2 Dim p1 = 2 * p a = a1 b = b1 t = t1 p = p1 pi = ((a + b) ^ 2) / (4 * t) Loop Catch ex As ThreadAbortException Finally callback(pi) End Try End Sub End Class
0
0
0
0
1
0
I can not figure out why this won't work. Please help me from math import sqrt pN = 0 numPrimes = 0 num = 1 def checkPrime(x): '''Check's whether a number is a prime or not''' prime = True if(x==2): prime = True elif(x%2==0): prime=False else: root=int(sqrt(x)) for i in range(3,root,2): if(x%i==0): prime=False break return prime n = int(input("Find n number of primes. N being:")) while( numPrimes != n ): if( checkPrime( num ) == True ): numPrimes += 1 pN = num print("{0}: {1}".format(numPrimes,pN)) num += 1 print("Prime {0} is: {1}".format(n,pN))
0
0
0
0
1
0
I have two different resolutions, the original one is 567x756 (wXh), the one which I want to display is 768x1024 (wXh). How to find out the scaling ratio for these two resolutions? For example if the font size used in 567x756 resolution is 7 pts then what's the values I should multiply with the font size (7 pts) to display the text in 768x1024 resolution.
0
0
0
0
1
0
I'm looking for a mathmatical ranking formula. Sample is 2008 2009 2010 A 5 6 4 B 6 7 5 C 7 8 2 I want to add a rank column for each period code field rank 2008 2009 2010 2008 2009 2010 B 6 7 5 2 1 1 A 5 6 4 3 2 2 C 7 2 2 1 3 3 please do not reply with methods that loop thru the rows and columns, incrementing the rank value as it goes, that's easy. I'm looking for a formula much like finding the percent total (item / total). I know i've seen this before but an havning a tough time locating it. Thanks in advance!
0
0
0
0
1
0