Dataset Viewer
Auto-converted to Parquet
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 bunch of latitude/longitude pairs that map to known x/y coordinates on a (geographically distorted) map. Then I have one more latitude/longitude pair. I want to plot it on the map as best is possible. How do I go about doing this? At first I decided to create a system of linear equations for the three nearest lat/long points and compute a transformation from these, but this doesn't work well at all. Since that's a linear system, I can't use more nearby points either. You can't assume North is up: all you have is the existing lat/long->x/y mappings. EDIT: it's not a Mercator projection, or anything like that. It's arbitrarily distorted for readability (think subway map). I want to use only the nearest 5 to 10 mappings so that distortion on other parts of the map doesn't affect the mapping I'm trying to compute. Further, the entire map is in a very small geographical area so there's no need to worry about the globe--flat-earth assumptions are good enough.
0
0
0
0
1
0
I suck at math. I need to figure out how to calculate a video duration with only a few examples of values. For example, a value of 70966 is displayed as 1:10 minutes. A value of 30533 displays as 30 seconds. A value of 7007 displays as 7 seconds.
0
0
0
0
1
0
Moving through the maze forward is pretty easy, but I can't seem to figure out how to back up through the maze to try a new route once you hit a dead end without going back too far?
0
1
0
0
0
0
I was browsing this thread, which has good recommendation but a bit too general for me. So, if anyone has a collection of nice game programming feeds,please share them. :) (both general and specific topics are welcome)
0
1
0
0
0
0
I want to get the base 10 logarithm of a Fixnum using Ruby, but found that n.log or n.log10 are not defined. Math::log is defined but uses a different base than 10. What is the easiest way to get the base 10 logarithm of a Fixnum?
0
0
0
0
1
0
I have an array of numbers that potentially have up to 8 decimal places and I need to find the smallest common number I can multiply them by so that they are all whole numbers. I need this so all the original numbers can all be multiplied out to the same scale and be processed by a sealed system that will only deal with whole numbers, then I can retrieve the results and divide them by the common multiplier to get my relative results. Currently we do a few checks on the numbers and multiply by 100 or 1,000,000, but the processing done by the *sealed system can get quite expensive when dealing with large numbers so multiplying everything by a million just for the sake of it isn’t really a great option. As an approximation lets say that the sealed algorithm gets 10 times more expensive every time you multiply by a factor of 10. What is the most efficient algorithm, that will also give the best possible result, to accomplish what I need and is there a mathematical name and/or formula for what I’m need? *The sealed system isn’t really sealed. I own/maintain the source code for it but its 100,000 odd lines of proprietary magic and it has been thoroughly bug and performance tested, altering it to deal with floats is not an option for many reasons. It is a system that creates a grid of X by Y cells, then rects that are X by Y are dropped into the grid, “proprietary magic” occurs and results are spat out – obviously this is an extremely simplified version of reality, but it’s a good enough approximation. So far there are quiet a few good answers and I wondered how I should go about choosing the ‘correct’ one. To begin with I figured the only fair way was to create each solution and performance test it, but I later realised that pure speed wasn’t the only relevant factor – an more accurate solution is also very relevant. I wrote the performance tests anyway, but currently the I’m choosing the correct answer based on speed as well accuracy using a ‘gut feel’ formula. My performance tests process 1000 different sets of 100 randomly generated numbers. Each algorithm is tested using the same set of random numbers. Algorithms are written in .Net 3.5 (although thus far would be 2.0 compatible) I tried pretty hard to make the tests as fair as possible. Greg – Multiply by large number and then divide by GCD – 63 milliseconds Andy – String Parsing – 199 milliseconds Eric – Decimal.GetBits – 160 milliseconds Eric – Binary search – 32 milliseconds Ima – sorry I couldn’t figure out a how to implement your solution easily in .Net (I didn’t want to spend too long on it) Bill – I figure your answer was pretty close to Greg’s so didn’t implement it. I’m sure it’d be a smidge faster but potentially less accurate. So Greg’s Multiply by large number and then divide by GCD” solution was the second fastest algorithm and it gave the most accurate results so for now I’m calling it correct. I really wanted the Decimal.GetBits solution to be the fastest, but it was very slow, I’m unsure if this is due to the conversion of a Double to a Decimal or the Bit masking and shifting. There should be a similar usable solution for a straight Double using the BitConverter.GetBytes and some knowledge contained here: http://blogs.msdn.com/bclteam/archive/2007/05/29/bcl-refresher-floating-point-types-the-good-the-bad-and-the-ugly-inbar-gazit-matthew-greig.aspx but my eyes just kept glazing over every time I read that article and I eventually ran out of time to try to implement a solution. I’m always open to other solutions if anyone can think of something better.
0
0
0
0
1
0
I did this Just for kicks (so, not exactly a question, i can see the downmodding happening already) but, in lieu of Google's newfound inability to do math correctly (check it! according to google 500,000,000,000,002 - 500,000,000,000,001 = 0), i figured i'd try the following in C to run a little theory. int main() { char* a = "399999999999999"; char* b = "399999999999998"; float da = atof(a); float db = atof(b); printf("%s - %s = %f ", a, b, da-db); a = "500000000000002"; b = "500000000000001"; da = atof(a); db = atof(b); printf("%s - %s = %f ", a, b, da-db); } When you run this program, you get the following 399999999999999 - 399999999999998 = 0.000000 500000000000002 - 500000000000001 = 0.000000 It would seem like Google is using simple 32 bit floating precision (the error here), if you switch float for double in the above code, you fix the issue! Could this be it? /mp
0
0
0
0
1
0
Can databases (MySQL in particular, any SQL--MS, Oracle, Postgres--in general) do mass updates, and figure out on their own what the new value should be? Say for example I've got a database with information about a bunch of computers, and all of these computers have drives of various sizes--anywhere from 20 to 250 GB. Then one day we upgrade every single computer by adding a 120 GB hard drive. Is there a way to say something like update computers set total_disk_space = (whatever that row's current total_disk_space is plus 120)
0
0
0
0
1
0
I'm trying to reteach myself some long forgotten math skills. This is part of a much larger project to effectively "teach myself software development" from the ground up (the details are here if you're interested in helping out). My biggest stumbling block so far has been math - how can I learn about algorithms and asymptotic notation without it?? What I'm looking for is some sort of "dependency tree" showing what I need to know. Is calculus required before discrete? What do I need to know before calculus (read: components to the general "pre-calculus" topic)? What can I cut out to fast track the project ("what can I go back for later")? Thank!
0
0
0
0
1
0
Pascal's rule on counting the subset's of a set works great, when the set contains unique entities. Is there a modification to this rule for when the set contains duplicate items? For instance, when I try to find the count of the combinations of the letters A,B,C,D, it's easy to see that it's 1 + 4 + 6 + 4 + 1 (from Pascal's Triangle) = 16, or 15 if I remove the "use none of the letters" entry. Now, what if the set of letters is A,B,B,B,C,C,D? Computing by hand, I can determine that the sum of subsets is: 1 + 4 + 8 + 11 + 11 + 8 + 4 + 1 = 48, but this doesn't conform to the Triangle I know. Question: How do you modify Pascal's Triangle to take into account duplicate entities in the set?
0
0
0
0
1
0
Without calculating them, I mean?
0
0
0
0
1
0
Where can i find some .Net or conceptual resources to start working with Natural Language where I can pull context and subjects from text. I wish not to work with word frequency algorithms.
0
1
0
0
0
0
I use a byte to store some flag like 10101010, and I would like to know how to verify that a specific bit is at 1 or 0.
0
0
0
0
1
0
I seek an algorithm that will let me represent an incoming sequence of bits as letters ('a' .. 'z' ), in a minimal matter such that the stream of bits can be regenerated from the letters, without ever holding the entire sequence in memory. That is, given an external bit source (each read returns a practically random bit), and user input of a number of bits, I would like to print out the minimal number of characters that can represent those bits. Ideally there should be a parameterization - how much memory versus maximum bits before some waste is necessary. Efficiency Goal - The same number of characters as the base-26 representation of the bits. Non-solutions: If sufficient storage was present, store the entire sequence and use a big-integer MOD 26 operation. Convert every 9 bits to 2 characters - This seems suboptimal, wasting 25% of information capacity of the letters output.
0
0
0
0
1
0
I need to explain to the client why dupes are showing up between 2 supposedly different exams. It's been 20 years since Prob and Stats. I have a generated Multiple choice exam. There are 192 questions in the database, 100 are chosen at random (no dupes). Obviously, there is a 100% chance of there being at least 8 dupes between any two exams so generated. (Pigeonhole principle) How do I calculate the probability of there being 25 dupes? 50 dupes? 75 dupes? -- Edit after the fact -- I ran this through excel, taking sums of the probabilities from n-100, For this particular problem, the probabilities were n P(n+ dupes) 40 97.5% 52 ~50% 61 ~0
0
0
0
0
1
0
If one has a peer-to-peer system that can be queried, one would like to reduce the total number of queries across the network (by distributing "popular" items widely and "similar" items together) avoid excess storage at each node assure good availability to even moderately rare items in the face of client downtime, hardware failure, and users leaving (possibly detecting rare items for archivists/historians) avoid queries failing to find matches in the event of network partitions Given these requirements: Are there any standard approaches? If not, is there any respected, but experimental, research? I'm familiar some with distribution schemes, but I haven't seen anything really address learning for robustness. Am I missing any obvious criteria? Is anybody interested in working on/solving this problem? (If so, I'm happy to open-source part of a very lame simulator I threw together this weekend, and generally offer unhelpful advice). @cdv: I've now watched the video and it is very good, and although I don't feel it quite gets to a pluggable distribution strategy, it's definitely 90% of the way there. The questions, however, highlight useful differences with this approach that address some of my further concerns, and gives me some references to follow up on. Thus, I'm provisionally accepting your answer, although I consider the question open.
0
0
0
1
0
0
Using assorted matrix math, I've solved a system of equations resulting in coefficients for a polynomial of degree 'n' Ax^(n-1) + Bx^(n-2) + ... + Z I then evaulate the polynomial over a given x range, essentially I'm rendering the polynomial curve. Now here's the catch. I've done this work in one coordinate system we'll call "data space". Now I need to present the same curve in another coordinate space. It is easy to transform input/output to and from the coordinate spaces, but the end user is only interested in the coefficients [A,B,....,Z] since they can reconstruct the polynomial on their own. How can I present a second set of coefficients [A',B',....,Z'] which represent the same shaped curve in a different coordinate system. If it helps, I'm working in 2D space. Plain old x's and y's. I also feel like this may involve multiplying the coefficients by a transformation matrix? Would it some incorporate the scale/translation factor between the coordinate systems? Would it be the inverse of this matrix? I feel like I'm headed in the right direction... Update: Coordinate systems are linearly related. Would have been useful info eh?
0
0
0
0
1
0
How can I set points on a 24h period spreaded by the Gaussian distributions? For example to have the peak at 10 o'clock?
0
0
0
0
1
0
How do I calculate the position of an accelerating body (e.g. a car) after a certain time (e.g. 1 second)? For a moving body that it not accelerating, it is a linear relationship, so I presume for an accelerating body it involves a square somewhere. Any ideas?
0
0
0
0
1
0
For a right triangle specified by an equation aX + bY <= c on integers I want to plot each pixel(*) in the triangle once and only once, in a pseudo-random order, and without storing a list of previously hit points. I know how to do this with a line segment between 0 and x pick a random point'o' along the line, pick 'p' that is relatively prime to x repeat for up to x times: Onext = (Ocur + P) MOD x To do this for a triangle, I would 1. Need to count the number of pixels in the triangle sans lists 2. Map an integer 0..points into a x,y pair that is a valid pixel inside the triangle I hope any solution could be generalized to pyramids and higher dimensional shapes. (*) I use the CG term pixel for the pair of integer points X,Y such that the equation is satisfied.
0
0
0
0
1
0
What are some good algorithms for automatically labeling text with the city / region or origin? That is, if a blog is about New York, how can I tell programatically. Are there packages / papers that claim to do this with any degree of certainty? I have looked at some tfidf based approaches, proper noun intersections, but so far, no spectacular successes, and I'd appreciate ideas! The more general question is about assigning texts to topics, given some list of topics. Simple / naive approaches preferred to full on Bayesian approaches, but I'm open.
0
1
0
0
0
0
I know of a couple of routines that work as follows: Xn+1 = Routine(Xn, max) For example, something like a LCG generator: Xn+1 = (a*Xn + c) mod m There isn't enough parameterization in this generator to generate every sequence. Dream Function: Xn+1 = Routine(Xn, max, permutation number) This routine, parameterized by an index into the set of all permutations, would return the next number in the sequence. The sequence may be arbitrarily large (so storing the array and using factoradic numbers is impractical. Failing that, does anyone have pointers to similar functions that are either stateless or have a constant amount of state for arbitrary 'max', such that they will iterate a shuffled list.
0
0
0
0
1
0
Is there any easy web application or user control that allows math equations to be easily created and stored as a text string? Update: An ASP.NET control would be ideal.
0
0
0
0
1
0
In c# double tmp = 3.0 * 0.05; tmp = 0.15000000000000002 This has to do with money. The value is really $0.15, but the system wants to round it up to $0.16. 0.151 should probably be rounded up to 0.16, but not 0.15000000000000002 What are some ways I can get the correct numbers (ie 0.15, or 0.16 if the decimal is high enough).
0
0
0
0
1
0
I am using the term "Lexical Encoding" for my lack of a better one. A Word is arguably the fundamental unit of communication as opposed to a Letter. Unicode tries to assign a numeric value to each Letter of all known Alphabets. What is a Letter to one language, is a Glyph to another. Unicode 5.1 assigns more than 100,000 values to these Glyphs currently. Out of the approximately 180,000 Words being used in Modern English, it is said that with a vocabulary of about 2,000 Words, you should be able to converse in general terms. A "Lexical Encoding" would encode each Word not each Letter, and encapsulate them within a Sentence. // An simplified example of a "Lexical Encoding" String sentence = "How are you today?"; int[] sentence = { 93, 22, 14, 330, QUERY }; In this example each Token in the String was encoded as an Integer. The Encoding Scheme here simply assigned an int value based on generalised statistical ranking of word usage, and assigned a constant to the question mark. Ultimately, a Word has both a Spelling & Meaning though. Any "Lexical Encoding" would preserve the meaning and intent of the Sentence as a whole, and not be language specific. An English sentence would be encoded into "...language-neutral atomic elements of meaning ..." which could then be reconstituted into any language with a structured Syntactic Form and Grammatical Structure. What are other examples of "Lexical Encoding" techniques? If you were interested in where the word-usage statistics come from : http://www.wordcount.org
0
1
0
0
0
0
I'm looking for an existing library to summarize or paraphrase content (I'm aiming at blog posts) - any experience with existing natural language processing libraries? I'm open to a variety of languages, so I'm more interested in the abilities & accuracy.
0
1
0
0
0
0
I want to do sparse high dimensional (a few thousand features) least squares regression with a few hundred thousands of examples. I'm happy to use non fancy optimisation - stochastic gradient descent is fine. Does anyone know of any software already implemented for doing this, so I don't have to write to my own? Kind regards.
0
0
0
0
1
0
Let X be the set of all sets that do not contain themselves. Is X a member of X?
0
0
0
0
1
0
I have experimented with a sigmoid and logarithmic fade out for volume over a period of about half a second to cushion pause and stop and prevent popping noises in my music applications. However neither of these sound "natural". And by this I mean, they sound botched. Like an amateur engineer was in charge of the sound decks. I know the ear is logarithmic when it comes to volumes, or at least, twice as much power does not mean twice as loud. Is there a magic formula for volume fading? Thanks.
0
0
0
0
1
0
I use int.MaxValue as a penalty and sometimes I am computing the penalties together. Is there a function or how would you create one with the most grace and efficiency that does that. ie. 50 + 100 = 150 int.Max + 50 = int.Max and not int.Min + 50
0
0
0
0
1
0
What's the shortest Perl one-liner that print out the first 9 powers of a hard-coded 2 digit decimal (say, for example, .37), each on its own line? The output would look something like: 1 0.37 0.1369 [etc.] Official Perl golf rules: Smallest number of (key)strokes wins Your stroke count includes the command line
0
0
0
0
1
0
I've been playing with some algorithms on the internet for a while and I can't seem to get them to work, so I'm tossing the question out here; I am attempting to render a velocity vector line from a point. Drawing the line isn't difficult: just insert a line with length velocity.length into the graph. This puts the line centered at the point in the y-axis direction. We need to get this now in the proper rotation and translation. The translational vector is not difficult to calculate: it is half the velocity vector. The rotational matrix, however, is being exceedingly elusive to me. Given a directional vector <x, y, z>, what's the matrix I need? Edit 1: Look; if you don't understand the question, you probably won't be able to give me an answer. Here is what I currently have: Vector3f translation = new Vector3f(); translation.scale(1f/2f, body.velocity); Vector3f vec_z = (Vector3f) body.velocity.clone(); vec_z.normalize(); Vector3f vec_y; // reference vector, will correct later if (vec_z.x == 0 && vec_z.z == 0) { vec_y = new Vector3f(-vec_z.y, 0f, 0f); // could be optimized } else { vec_y = new Vector3f(0f, 1f, 0f); } Vector3f vec_x = new Vector3f(); vec_x.cross(vec_y, vec_z); vec_z.normalize(); vec_y.cross(vec_x, vec_z); vec_y.normalize(); vec_y.negate(); Matrix3f rotation = new Matrix3f( vec_z.z, vec_z.x, vec_z.y, vec_x.z, vec_x.x, vec_x.y, vec_y.z, vec_y.x, vec_y.y ); arrowTransform3D.set(rotation, translation, 1f); based off of this article. And yes, I've tried the standard rotation matrix (vec_x.x, vec_y.x, etc) and it didn't work. I've been rotating the columns and rows to see if there's any effect. Edit 2: Apologies about the rude wording of my comments. So it looks like there were a combination of two errors; one of which House MD pointed out (really bad naming of variables: vec_z was actually vec_y, and so on), and the other was that I needed to invert the matrix before passing it off to the rendering engine (transposing was close!). So the modified code is: Vector3f vec_y = (Vector3f) body.velocity.clone(); vec_y.normalize(); Vector3f vec_x; // reference vector, will correct later if (vec_y.x == 0 && vec_y.z == 0) { vec_x = new Vector3f(-vec_y.y, 0f, 0f); // could be optimized } else { vec_x = new Vector3f(0f, 1f, 0f); } Vector3f vec_z = new Vector3f(); vec_z.cross(vec_x, vec_y); vec_z.normalize(); vec_x.cross(vec_z, vec_y); vec_x.normalize(); vec_x.negate(); Matrix3f rotation = new Matrix3f( vec_x.x, vec_x.y, vec_x.z, vec_y.x, vec_y.y, vec_y.z, vec_z.x, vec_z.y, vec_z.z ); rotation.invert();
0
0
0
0
1
0
What sort of mathematics do you use in your .NET application, excluding everything that's in System.Math? I think that System.Math is woefully inadequate. For example, in several official .NET frameworks, I can count three different implementations of matrices. The same goes for vectors. One implementation of a complex number; several different implementations of arbitrary rational numbers, and so on. So, what would you like to see in a hypothetical System.Mathematics namespace?
0
0
0
0
1
0
I have a variable that contains a 4 byte, network-order IPv4 address (this was created using pack and the integer representation). I have another variable, also a 4 byte network-order, subnet. I'm trying to add them together and add one to get the first IP in the subnet. To get the ASCII representation, I can do inet_ntoa($ip&$netmask) to get the base address, but it's an error to do inet_ntoa((($ip&$netmask)+1); I get a message like: Argument " \r&\0" isn't numeric in addition (+) at test.pm line 95. So what's happening, the best as I can tell, is it's looking at the 4 bytes, and seeing that the 4 bytes don't represent a numeric string, and then refusing to add 1. Another way of putting it: What I want it to do is add 1 to the least significant byte, which I know is the 4th byte? That is, I want to take the string \r&\0 and end up with the string \r&\1. What's the simplest way of doing that? Is there a way to do this without having to unpack and re-pack the variable?
0
0
0
0
1
0
What is BODMAS and why is it useful in programming?
0
0
0
0
1
0
I am looking for an algorithm to hatch a rectangle with shortest overall line length, so that an object of given area can be passed through the hatching. For example given a rectangle of 5x3 cm, and I hatch using parallel lines 1cm across, the biggest object I can pass through the hatch is a square of 1cm side. I have used an overall 22 cm (ie 4x3+2x5) of hatch lines. So to pass an area of 1sqcm I have used 22cm of hatch lines. The algorithm should find a pattern that minimize the overall hatch lines from current 22cm while not allowing an area with more than 1sqcm to pass through (the object need not be in the form of a square or even rectangle, it's overall area that matters). Edit: Following the lead of nlucaroni I found the Honeycomb Conjecture which states that any partition of the plane into regions of equal area has perimeter at least that of the regular hexagonal grid, which answers my question partially.
0
0
0
0
1
0
I think there is a wealth of natural language data associated with sites like reddit or digg or news.google.com. I have done a little bit of research with text mining, but can't find how I could use those tools to parse something like reddit. What kind of applications can you come up with?
0
1
0
0
0
0
I have an implicit scalar field defined in 2D, for every point in 2D I can make it compute an exact scalar value but its a somewhat complex computation. I would like to draw an iso-line of that surface, say the line of the '0' value. The function itself is continuous but the '0' iso-line can have multiple continuous instances and it is not guaranteed that all of them are connected. Calculating the value for each pixel is not an option because that would take too much time - in the order of a few seconds and this needs to be as real time as possible. What I'm currently using is a recursive division of space which can be thought of as a kind of quad-tree. I take an initial, very coarse sampling of the space and if I find a square which contains a transition from positive to negative values, I recursively divide it to 4 smaller squares and checks again, stopping at the pixel level. The positive-negative transition is detected by sampling a sqaure in its 4 corners. This work fairly well, except when it doesn't. The iso-lines which are drawn sometimes get cut because the transition detection fails for transitions which happen in a small area of an edge and that don't cross a corner of a square. Is there a better way to do iso-line drawing in this settings?
0
0
0
0
1
0
I have to generate two random sets of matrices Each containing 3 digit numbers ranging from 2 - 10 like that matrix 1: 994,878,129,121 matrix 2: 272,794,378,212 the numbers in both matrices have to be greater then 100 and less then 999 BUT the mean for both matrices has to be in the ratio of 1:2 or 2:3 what ever constraint the user inputs my math skills are kind of limited so any ideas how do i make this happen?
0
0
0
0
1
0
I know that tan(angle) gets me the tangent. But how do I do the "reverse tangent" so that I can get the angle given the length of both sides of the right triangle? I'm assuming there is a method for this in math.h?
0
0
0
0
1
0
I'm making a shell script to find bigrams, which works, sort of. #tokenise words tr -sc 'a-zA-z0-9.' '\012' < $1 > out1 #create 2nd list offset by 1 word tail -n+2 out1 > out2 #paste list together paste out1 out2 #clean up rm out1 out2 The only problem is that it pairs words from the end and start of the previous sentence. eg for the two sentences 'hello world.' and 'foo bar.' i'll get a line with ' world. foo'. Would it be possible to filter these out with grep or something? I know i can find all bigrams containing a full stop with grep [.] but that also finds the legitimate bigrams.
0
1
0
0
0
0
I need to match a string like "one. two. three. four. five. six. seven. eight. nine. ten. eleven" into groups of four sentences. I need a regular expression to break the string into a group after every fourth period. Something like: string regex = @"(.*.\s){4}"; System.Text.RegularExpressions.Regex exp = new System.Text.RegularExpressions.Regex(regex); string result = exp.Replace(toTest, ". "); doesn't work because it will replace the text before the periods, not just the periods themselves. How can I count just the periods and replace them with a period and new line character?
0
1
0
0
0
0
Omitting details of methods to calculate primes, and methods of factorisation. Why bother to factorise ? What are its applications ?
0
0
0
0
1
0
I need to plan a voyage connecting n locations in the sea with a specified origin and specified destination with following constraints. The voyage has to touch all locations. If there is a reservation from A to B then a has to be touched before B The time spend at each location varies (depends upon the reservations to that location) Each location has a working window. If the vessel reaches before working window it has to wait. Note: "Minimum spanning tree" algorithms may not be as the time required at each port depends on the previous route (due to working window) Is there any algorithm available for this?
0
0
0
0
1
0
I'm trying to make a triangle (isosceles triangle) to move around the screen and at the same time slightly rotate it when a user presses a directional key (like right or left). I would like the nose (top point) of the triangle to lead the triangle at all times. (Like that old asteroids game). My problem is with the maths behind this. At every X time interval, I want the triangle to move in "some direction", I need help finding this direction (x and y increments/decrements). I can find the center point (Centroid) of the triangle, and I have the top most x an y points, so I have a line vector to work with, but not a clue as to "how" to work with it. I think it has something to do with the old Sin and Cos methods and the amount (angle) that the triangle has been rotated, but I'm a bit rusty on that stuff. Any help is greatly appreciated.
0
0
0
0
1
0
What is the time complexity? Why? (define (mult a b) (define (internal a accum) (if (= a 1) accum (internal (- a 1) (+ accum b)))) (internal a b)) (define (to-the-power-of m n) (define (internal x accum) (if (= x 0) accum (internal (- x 1) (mult accum m)))) (internal n 1))
0
0
0
0
1
0
I have a menu of product brands that I want to split over 4 columns. So if I have 39 brands, then I want the maximum item count for each column to be 10 (with a single gap in the last column. Here's how I'm calculating the item count for a column (using C#): int ItemCount = Convert.ToInt32(Math.Ceiling(Convert.ToDecimal(BrandCount) / 4m)); All that conversion seems really ugly to me. Is there a better way to do math on integers in C#?
0
0
0
0
1
0
I have a program that will calculate the minimal area taken by fitting rectangles together. Input: Rectangles of different height and width. Output: One rectangle that contains all these rectangles. Rules: One cannot turn or roll the rectangles around and they cannot overlap. I understand that this is related or is possibly defined as a bin packing problem (NP-hard). However the algorithms i found for those often set a limit on for example width. I have no such limits, the only goal is to get the resulting area as small as possible. Any pointers on what algorithm is appropriate to get a decent solution?
0
0
0
0
1
0
Is there a practical algorithm that gives "multiplication chains" To clarify, the goal is to produce a multiplication change of an arbitrary and exact length Multiplication chains of length 1 are trivial. A "multiplication chain" would be defined as 2 numbers, {start} and {multiplier}, used in code: Given a pointer to array of size [{count}] // count is a parameter a = start; do { a = a * multiplier; // Really: a = (a * multiplier) MOD (power of 2 *(pointer++) = a; } while (a != {constant} ) // Postcondition: all {count} entries are filled. I'd like to find a routine that takes three parameters 1. Power of 2 2. Stopping {constant} 3. {count} - Number of times the loop will iterate The routine would return {start} and {multiplier}. Ideally, a {Constant} value of 0 should be valid. Trivial example: power of 2 = 256 stopping constant = 7 number of times for the loop = 1 returns {7,1} Nontrivial example: power of 2 = 256 stopping constant = 1 number of times for the loop = 49 returns {25, 19} The maximum {count} for a given power of 2 can be fairly small. For example, 2^4 (16) seems to be limited to a count of 4
0
0
0
0
1
0
I'm looking for a an R package which can be used to train a Dirichlet prior from counts data. I'm asking for a colleague who's using R, and don't use it myself, so I'm not too sure how to look for packages. It's a bit hard to search for, because "R" is such a nonspecific search string. There doesn't seem to be anything on CRAN, but are there any other places to look?
0
0
0
0
1
0
Is there a way (a program, a library) to approximately know which language a document is written in? I have a bunch of text documents (~500K) in mixed languages to import in a i18n enabled CMS (Drupal).. I don't need perfect matches, only some guess.
0
1
0
0
0
0
I have signed numbers (2s complement) stored in 32-bit integers, and I want to extract 16-bit fields from them. Is it true that if I extract the low 16 bits from a 32-bit signed number, the result will be correct as long as the original (32-bit) number fits into 16 bits ? For positive numbers it is trivially true, and it seems that for negatives as well. But can it be proven ? Thanks in advance
0
0
0
0
1
0
I've got the equivalent of an AST that a user has built using a rule engine. But when displaying a list of the rules, I'd like to be able to "pretty print" each rule into something that looks nice**. Internally when represented as a string they look like s-expressions so imagine something like: (and (contains "foo" "foobar") (equals 4 (plus 2 2 ))) Can anyone point me at a program that has done a good job of displaying rules in a readable fashion? ** Needs to be localizable too, but I guess we'll leave that for extra credit.
0
1
0
0
0
0
What is the difference between these three heavily related fields? Is there one specific whole they are all a part of (aside from CS)?
0
1
0
1
0
0
I have seen 3d surface plots of data before but i do not know what software i could use to make it. I have 3 series of data (X, Y, Z) basically i want each of the rows on the table to be a point in 3d space, all joined as a mesh. The data is currently csv, but i can change the format, as it is data i generated myself. Can anyone help
0
0
0
0
1
0
For example, in http://homepages.cwi.nl/~paulv/papers/algorithmicstatistics.pdf at the bottom of page 5 and top of page 6, he uses a plus/equal symbol and a similar plus/lessthan symbol. I can't figure out how to make that symbol, and I'd like to quote him. Any help?
0
0
0
0
1
0
I have an unsorted list of noisy X, Y points. They do, however, form a path through the world. I would like an algorithm to draw an approximation of this data using line segments. This is similar to how you would use a line -fitting algorithm to pick an approximation of linear data. My problem is only harder because the path bends and winds around the world. alt text http://www.praeclarum.org/so/pathfinder.png Does anyone know of any standard / robust / easy to comprehend algorithms to accomplish this? Q&A: What do you mean by noisy? If I had an ideal realization of the path, then my set of points would be sampled from that ideal path with gaussian noise added to the X and Y elements. I do not know the mean or standard deviation of that noise. I may be able to guess at the std dev... Do the points lie near, but not on, some ideal but complicated path which you seek to approximate? Yes. Do you have any a priori information about he shape of the path? Any other way to get such information? Unfortunately not.
0
0
0
0
1
0
I need a function count_permutations() that returns the number of permutations of a given range. Assuming that the range is allowed to be modified, and starts at the first permutation, I could naively implement this as repeated calls to next_permutation() as below: template<class Ret, class Iter> Ret count_permutations(Iter first, Iter last) { Ret ret = 0; do { ++ret; } while (next_permutation(first, last)); return ret; } Is there a faster way that doesn't require iterating through all the permutations to find the answer? It could still assume that the input can be modified, and starts in the first permutation, but obviously if it is possible to implement without those assumtions it'd be great too.
0
0
0
0
1
0
I'm new to cryptography and modular arithmetic. So, I'm sure it's a silly question, but I can't help it. How do I calculate a from      pow(a,q) = 1 (mod p), where p and q are known? I don't get the "1 (mod p)" part, it equals to 1, doesn't it? If so, than what is "mod p" about? Is this the same as      pow(a,-q) (mod p) = 1?
0
0
0
0
1
0
Are there any known hash algorithms which input a vector of int's and output a single int that work similarly to an inner product? In other words, I am thinking about a hash algorithm that might look like this in C++: // For simplicity, I'm not worrying about overflow, and assuming |v| < 7. int HashVector(const vector<int>& v) { const int N = kSomethingBig; const int w[] = {234, 739, 934, 23, 828, 194}; // Carefully chosen constants. int result = 0; for (int i = 0; i < v.size(); ++i) result = (result + w[i] * v[i]) % N; return result; } I'm interested in this because I'm writing up a paper on an algorithm that would benefit from any previous work on similar hashes. In particular, it would be great if there is anything known about the collision properties of a hash algorithm like this. The algorithm I'm interested in would hash integer vectors, but something for float vectors would also be cool. Clarification The hash is intended for use in a hash table for fast key/value lookups. There is no security concern here. The desired answer is something like a set of constants that provably work particularly well for a hash like this - analogous to a multiplier and modulo which works better than others as a pseudorandom number generator. For example, some choices of constants for a linear congruential pseudorandom generator are known to give optimal cycle lengths and have easy-to-compute modulos. Maybe someone has done research to show that a certain set of multiplicative constants, along with a modulo constant, in a vector hash can reduce the chance of collisions amongst nearby integer vectors.
0
0
0
0
1
0
I have the following equation 1 - ((.5 * 0.83333333333333) ^ 2 + (.5 * 0.83333333333333) ^ 2 + (.5 * (1 - 0.83333333333333)) ^ 2 + (.5 * (1 - 0.83333333333333)) ^ 2) In Php5, this results in an answer of 1 as opposed to .63 (on two machines, OSx and Centos). Should I be exclusively using the bc math functions of Php to do equations like this?
0
0
0
0
1
0
This is my very first question so I am a bit nervous about it because I am not sure whether I get the meaning across well enough. Anyhow, here we go.... Whenever new milestones in programming have been reached it seems they always have had one goal in common: to make it easier for programmers, well, to program. Machine language, opcodes/mnemonics, procedures/functions, structs, classes (OOP) etc. always helped, in their time, to plan, structure and code programs in a more natural, understandable and better maintainable way. Of course functional programming is by no means a novelty but it seems that it has experienced a sort of renaissance in recent years. I also believe that FP will get an enormous boost when Microsoft will add F# to their mainstream programming languages. Returning to my original question, I believe that ultimately programming will be done in a natural language (English) with very few restrictions or rules. The compiler will be part of an AI/NLP system that extracts information from the code or should I say text and transforms it into an intermediate language which the compiler can compile. So, does FP take programming closer to natural-language programming or is it rather an obstacle and mainstream OOP will lead us faster to natural-language programming? This question should not be used to discuss the useability or feasability of natural-language programming because only the future will tell.
0
1
0
0
0
0
I have been trying to learn more about lambda expressions lately, and thought of a interesting exercise... is there a way to simplify a c++ integration function like this: // Integral Function double integrate(double a, double b, double (*f)(double)) { double sum = 0.0; // Evaluate integral{a,b} f(x) dx for(int n = 0 ; n <= 100; ++n) { double x = a + n*(b-a)/100.0; sum += (*f)(x) * (b-a)/101.0; } return sum; } by using c# and lambda expressions?
0
0
0
0
1
0
How to convert last 3 digits of number into 0 example 3444678 to 3444000 I can do like (int)(3444678/1000) * 1000= 3444000 But division and multiplication could be costly... Any other solution????
0
0
0
0
1
0
I have a language-agnostic question about an algorithm. This comes from a (probably simple) programming challenge I read. The problem is, I'm too stupid to figure it out, and curious enough that it is bugging me. The goal is to sort a list of integers to ascending order by swapping the positions of numbers in the list. Each time you swap two numbers, you have to add their sum to a running total. The challenge is to produce the sorted list with the smallest possible running total. Examples: 3 2 1 - 4 1 8 9 7 6 - 41 8 4 5 3 2 7 - 34 Though you are free to just give the answer if you want, if you'd rather offer a "hint" in the right direction (if such a thing is possible), I would prefer that.
0
0
0
0
1
0
On SO 18 Joel mentioned an algorithm that would rank items based on their age and popularity and it's based on gravity. Could someone post this? C# would be lovely, but really any language (well, I can't do LISP) would be fine.
0
0
0
0
1
0
So I have written a Quaternion based 3D Camera oriented toward new programmers so it is ultra easy for them to integrate and begin using. While I was developing it, at first I would take user input as Euler angles, then generate a Quaternion based off of the input for that frame. I would then take the Camera's Quaternion and multiply it by the one we generated for the input, and in theory that should simply add the input rotation to the current state of the camera's rotation, and things would be all fat and happy. Lets call this: Accumulating Quaternions, because we are storing and adding Quaternions only. But I noticed that there was a problem with this method. The more I used it, even if I was only rotating on one Euler angle, say Yaw, it would, over some iterations, begin bleeding over into another, say Pitch. It was slight, but fairly unacceptable. So I did some more research and found an article stating it was better to accumulate Euler angles, so the camera stores it's current rotation as Euler angles, and input is simply added to them each frame. Then I generate a Quaternion from them each frame, which is in turn used to generate my rotation matrix. And this fixed the issue of rotation bleeding into improper axes. So do any Stackoverflow members have any insight into this problem? Is that a proper way of doing things?
0
0
0
0
1
0
Here is pseudo-code of how I setup an array representing the MandelBrot set, yet it becomes horribly stretched when leaving an aspect ratio of 1:1. xStep = (maxX - minX) / width; yStep = (maxY - minY) / height; for(i = 0; i < width; i++) for(j = 0; j < height; j++) { constantReal = minReal + xStep * i; constantImag = minImag + yStep * j; image[i][j] = inSet(constantReal, constantImag); } Thanks!
0
0
0
0
1
0
Say we have normal distribution n(x): mean=0 and \int_{-a}^{a} n(x) = P. What is the easiest way to compute standard deviation of such distribution? May be there are standard libraries for python or C, that are suitable for that task?
0
0
0
0
1
0
In a program to find whether the given number is an Armstrong number, I stored the input no (3 digit) as string as follows. char input[10]; scanf("%s",&input); Now I have to calculate cube of each digit by using pow method of math.h as follows. int a; a = pow(input[0],3); By coding like this, I could not get correct result. If I print the value of "a", it shows some irrelevant answer. My doubt is, how to convert from string value to integer value?
0
0
0
0
1
0
With one worker, who can only perform one task at a time (but can switch between tasks instantly) Given a list of tasks, -- defined as "n seconds, every m seconds" (eg, 5 seconds every 3600 seconds) How could I find the best starting times and count for each task? If every task were "1 second, every 60 seconds", each would have an unique starting second, and the count would be infinite (steady state). If it was "1 second every 4 seconds" and "1 second every 3 seconds", the result would be: " 0, infinite and 3, 3 times" -- Hopefully simplest form If already I have a list of tasks, elaborated with "start second and number of times", what would a function that returns: {start, count} for an additional {n seconds every m seconds} task look like? -- (Slightly more complex form -- if instead of "n seconds every m seconds", the tasks were defined as "n seconds every l..o seconds", where I could pick a number m in the range l - o (but would have to commit to that m until the task was finished), would that allow better worker utilization? How would I choose the best 'm' ?
0
0
0
0
1
0
We had an ISP failure for about 10 minutes one day, which unfortunately occurred during a hosted exam that was being written from multiple locations. Unfortunately, this resulted in the loss of postback data for candidates' current page in progress. I can reconstruct the flow of events from the server log. However, of 317 candidates, 175 were using a local proxy, which means they all appear to come from the same IP. I've analyzed the data from the remaining 142 (45%), and come up with some good numbers as to what happened with them. Question: How correct is it to multiply all my numbers by 317/142 to achieve probable results for the entire set? What would be my region of (un)certainty? Please, no guesses. I need someone who didn't fall asleep in stats class to answer. EDIT: by numbers, I was refering to counts of affected individuals. for example, 5/142 showed evidence of a browser crash during the session. How correct is the extrapolation of 11/317 having browser crashes?
0
0
0
0
1
0
In my program I have one array with 25 double values 0.04 When I try to sum these values in a loop I get following results: 0.0 + 0.04 = 0.04 0.04 + 0.04 = 0.08 0.08 + 0.04 = 0.12 0.12 + 0.04 = 0.16 0.16 + 0.04 = 0.2 0.2 + 0.04 = 0.24000000000000002 0.24000000000000002 + 0.04 = 0.28 0.28 + 0.04 = 0.32 0.32 + 0.04 = 0.36 0.36 + 0.04 = 0.39999999999999997 0.39999999999999997 + 0.04 = 0.43999999999999995 0.43999999999999995 + 0.04 = 0.4799999999999999 0.4799999999999999 + 0.04 = 0.5199999999999999 0.5199999999999999 + 0.04 = 0.5599999999999999 0.5599999999999999 + 0.04 = 0.6 0.6 + 0.04 = 0.64 0.64 + 0.04 = 0.68 0.68 + 0.04 = 0.7200000000000001 0.7200000000000001 + 0.04 = 0.7600000000000001 0.7600000000000001 + 0.04 = 0.8000000000000002 0.8000000000000002 + 0.04 = 0.8400000000000002 0.8400000000000002 + 0.04 = 0.8800000000000002 0.8800000000000002 + 0.04 = 0.9200000000000003 0.9200000000000003 + 0.04 = 0.9600000000000003 Why on earth could that happen?!
0
0
0
0
1
0
I'm not looking for a general discussion on if math is important or not for programming. Instead I'm looking for real world scenarios where you have actually used some branch of math to solve some particular problem during your career as a software developer. In particular, I'm looking for concrete examples.
0
0
0
0
1
0
I have seen this topic here about John Carmack's magical way to calculate square root, which refers to this article: http://www.codemaestro.com/reviews/9. This surprised me a lot, I just didn't ever realized that calculating sqrt could be so faster. I was just wondering what other examples of "magic" exist out there that computer games use to run faster. UPDATE: John Carmack is not the author of the magic code. This article tells more. Thanks @moocha.
0
0
0
0
1
0
I was wondering if it's possible to calculate the average of some numbers if I have this: int currentCount = 12; float currentScore = 6.1123 (this is a range of 1 <-> 10). Now, if I receive another score (let's say 4.5), can I recalculate the average so it would be something like: int currentCount now equals 13 float currentScore now equals ????? or is this impossible and I still need to remember the list of scores?
0
0
0
0
1
0
Possible Duplicate: Fastest way to determine if an integer's square root is an integer What's a way to see if a number is a perfect square? bool IsPerfectSquare(long input) { // TODO } I'm using C# but this is language agnostic. Bonus points for clarity and simplicity (this isn't meant to be code-golf). Edit: This got much more complex than I expected! It turns out the problems with double precision manifest themselves a couple ways. First, Math.Sqrt takes a double which can't precisely hold a long (thanks Jon). Second, a double's precision will lose small values ( .000...00001) when you have a huge, near perfect square. e.g., my implementation failed this test for Math.Pow(10,18)+1 (mine reported true).
0
0
0
0
1
0
I am trying to build a function grapher, The user enters xmin, xmax, ymin, ymax, function. I got the x, y for all points. Now i want to translate this initial referential to a Canvas starting at 0,0 up to 250,250. Is there a short way or should i just check if x < 0 new x = (x - xmin) * (250 / (xmax - xmin)) ? etc .. Also this basic approach does not optimise sampling. For example if my function f(x) = 5 i dont need to sample the xrange in 500 points, i only need two points. I could do some heuristic checks. But for a function like sin(2/x) i need more sampling around x (-1,1) how would you aproach such a thing ? Thanks
0
0
0
0
1
0
I have a small math problem I am trying to solve Given a number x and resolution y, I need to find the next x' with the required resolution. e.g. x = 1.002 y = 0.1 x'= 1.1 x = 0.348 y = 0.1 x'= 0.4 x = 0.50 y = 1 x'= 1 x = 0.32 y = 0.05 x'= 0.35 Is there any smart way of doing this in Python?
0
0
0
0
1
0
X = 01001001 and Y = 10101010 If I want to add them together how do I do that? They are "Two's Complement"... I have tried a lots of things but I am not quite sure I am getting the right answer since there seems to be different type of rules. Just want to make sure it is correct: 1. Add them as they are do not convert the negative 2. Convert the negative number you get and that's the sum. f.eks 01001001+10101010 = 11110011 => 00001100 => 1101 => -13 Or? 1. Convert the negative 2. Add them together and convert the negative f.eks 01001001+10101010 => 01001001 + 01010110 => 10011111 => 01100001 => -97 So basically what I want to do is to take: X-Y, and X+Y Can someone tell me how to do that? Some resource sites: student-binary celtickane swarthmore
0
0
0
0
1
0
I am trying to figure out the following problem. I am building Yet another math function grapher, The function is drawn on its predefined x,y range, that's all good. Now I am working on the background and the ticking of X, Y axes (if any axes are shown). I worked out the following. I have a fixed width of 250 p The tick gap should be between 12.5 and 50p. The ticks should indicate either unit or half unit range, by that i mean the following. x range (-5, 5): one tick = 1 x range (-1, 1): one tick = 0.5 or 0.1 depending on the gap that each of this option would generate. x range (0.1, 0.3): 0.05 Given a Xrange How would you get the number of ticks between either full or half unit range ? Or maybe there are other way to approach this type of problems.
0
0
0
0
1
0
We have a SaaS application requirement to allow a user responsible for building a CMS site to define up to 10 custom fields in a form. As part of this field definition we want to add a field validation option which we will store (and apply at runtime) as a reg-ex. Are there any tools, code samples or similar that offer a wizard style front end for building a reg-ex. We are looking to embed a control or code into our .NET site that will generate the reg-ex from (pseudo) user friendly terms (close to natural language if possible). e.g. Field 1 = (5 alphanumerics) followed-by (1 to 3 numerics) followed by "-" followed by 1 alpha
0
1
0
0
0
0
My question, his question, but blogs as resources to be specific. I find blogs great to keep up to date... refresh material... So do you know any blogs who tackle math-related programming problems...
0
0
0
0
1
0
I'm just trying to do simple scripting with F#, and Math.PI seems to have 'disappeared'. I've referenced FSharp.PowerPack.dll, but still can't find it.
0
0
0
0
1
0
Suppose we have n elements, a1, a2, ..., an, arranged in a circle. That is, a2 is between a1 and a3, a3 is between a2 and a4, an is between an-1 and a1, and so forth. Each element can take the value of either 1 or 0. Two arrangements are different if there are corresponding ai's whose values differ. For instance, when n=3, (1, 0, 0) and (0, 1, 0) are different arrangements, even though they may be isomorphic under rotation or reflection. Because there are n elements, each of which can take two values, the total number of arrangements is 2n. Here is the question: How many arrangements are possible, such that no two adjacent elements both have the value 1? If it helps, only consider cases where n>3. I ask here for several reasons: This arose while I was solving a programming problem It sounds like the problem may benefit from Boolean logic/bit arithmetic Maybe there is no closed solution.
0
0
0
0
1
0
Over the last few days I have noted a few web sites that demonstrated TS solution using genetic algorithms. Which is approach produces the shorter tour in the TSP problem: nearest neighbour or genetic algorithms?
0
1
0
0
0
0
I am doing some TTF work for MOSA (the correlating body between all the C# operating systems). Me and Colin Burn are currently working on getting some TTF code working (less me these days :) - he made a lot of progress). In any case, the TTF spec allows for an arbitrary amount of control points between the 'handles' and gasp NO handles at all (the TTF has an example of a circle demonstrating it - well done idiots - you saved 10 bytes). Can anyone give me a pointer on how this could be done? I looked at the Bezier article on Wikipedia but it wasn't really that much help - they show it happening, but don't give any math. Something 'program' ready would help (my Calculus isn't what it should be) - some pseudocode or something. Thanks guys.
0
0
0
0
1
0
I've been asked to help out on an XNA project with the AI. I'm not totally new to the concepts (pathfinding, flocking, etc.) but this would be the first "real" code. I'd be very thankful for any resources (links or books); I want to make sure I do this right.
0
1
0
0
0
0
I have been working on this for the greater part of the day and I cant seem to make this part of my code work. The intent of the code is to allow the user to input a set of values in order to calculate the missing value. As an additional feature I placed a CheckBox on the form to allow the user to do further calculation. That is where my problem lies. I know the code works because if I change the formula the value that appears in tb3_aic.Text changes per the formula. However, when I use the below the answer does not change like it should. Please reference the attached code. If a jpg image is needed of the formula I can e-mail it. void Calc3Click(object sender, EventArgs e) { if (String.IsNullOrEmpty(tb3_skv.Text) | String.IsNullOrEmpty(tb3_kva.Text) | String.IsNullOrEmpty(tb3_z.Text)) { MessageBox.Show("Enter all required values", "Missing Data", MessageBoxButtons.OK); } //If user does not enter all the values required for the calculation show error message box else { if (!String.IsNullOrEmpty(tb3_skv.Text) & !String.IsNullOrEmpty(tb3_kva.Text) & !String.IsNullOrEmpty(tb3_z.Text)) { //If motor load check box is not checked and required values are entered calculate AIC based on formula. int y; decimal x, z, a; x = decimal.Parse(tb3_skv.Text); y = int.Parse(tb3_kva.Text); a = decimal.Parse(tb3_z.Text); z = (y * 1000) / (x * 1.732050808m) / (a / 100); //the m at the end of the decimal allows for the multiplication of decimals tb3_aic.Text = z.ToString(); tb3_aic.Text = Math.Round(z,0).ToString(); } if (cb3_ml.Checked==true) {//If Motor Load CB is checked calculate the following int y, b; decimal x, z, a; x = decimal.Parse(tb3_skv.Text); y = int.Parse(tb3_kva.Text); a = decimal.Parse(tb3_z.Text); b = int.Parse(tb3_ml.Text); z = ((y * 1000) / (x * 1.732050808m) / (a / 100))+((b / 100)*(6*y)/(x*1.732050808m)*1000); tb3_aic.Text = z.ToString(); tb3_aic.Text = Math.Round(z,5).ToString(); } } I am grateful for any help that can be provided. Thank you, Greg Rutledge
0
0
0
0
1
0
if i have a function A,which can apply a certain rule on a given matrix to generate a another matrix which i call it the next state of the origin matrix,also the function can determine the the final state of the matrix by given times N(apply the rule on origin,and apply the rule on the next state of the origin matrix again,and apply rule apply rule... for N times). So suppose for a given matrix,apply the rule on it for 5 times and the final matrix become the same as the origin matrix,and we call that matrix's period is 5. And I have another function B,how can i make the functionB can determine the period of a given function under the same rule of the functionA,and return the period?I just have no idea how to start to make it...Thanks in advance. def functionA(origin_matrix,N_times): #apply rule on the origin_matrix to generate another matrix which is the next sate of it. #apply rule on origin_matrix for N_times return the_final_matrix def functionB(origin_matrix): #determine the period of the the origin_matrix. return period
0
0
0
0
1
0
Make a new AS3 Document in Flash, paste in the following code and run it: var a:Number=0; trace(a) // 0 a+=0.3; trace(a) // 0.3 a+=0.3; trace(a) // 0.6 a+=0.3; trace(a) // 0.8999999999999999 a+=0.3; trace(a) // 1.2 a+=0.3; trace(a) // 1.5 a+=0.3; trace(a) // 1.8 a+=0.3; trace(a) // 2.1 a+=0.3; // ^ This is the output. Notice the inaccuracy starting from 0.9 / 0.89 Why the error? I'm just doing an ordinary hi resolution addition. Any workarounds?
0
0
0
0
1
0
I have these 2 vectors: alpha = 1 1 1 1 1 1 1 1 1 f_uv = 193 193 194 192 193 193 190 189 191 And when I do this: alphaf_uv = alpha * f_uv' I get the error message: "??? Error using ==> mtimes Integers can only be combined with integers of the same class, or scalar doubles." The interesting part is that this error doesn't appear if I define the same vectors in the console and try the multiplication there. alpha is defined by me and f_uv is obtained from some pixels in a PNG image.
0
0
0
0
1
0
Let's in fact generalize to a c-confidence interval. Let the common rate parameter be a. (Note that the mean of an exponential distribution with rate parameter a is 1/a.) First find the cdf of the sum of n such i.i.d. random variables. Use that to compute a c-confidence interval on the sum. Note that the max likelihood estimate (MLE) of the sum is n/a, ie, n times the mean of a single draw. Background: This comes up in a program I'm writing to make time estimates via random samples. If I take samples according to a Poisson process (ie, the gaps between samples have an exponential distribution) and n of them happen during Activity X, what's a good estimate for the duration of Activity X? I'm pretty sure the answer is the answer to this question.
0
0
0
0
1
0
This is a really basic question but this is the first time I've used MATLAB and I'm stuck. I need to simulate a simple series RC network using 3 different numerical integration techniques. I think I understand how to use the ode solvers, but I have no idea how to enter the differential equation of the system. Do I need to do it via an m-file? It's just a simple RC circuit in the form: RC dy(t)/dt + y(t) = u(t) with zero initial conditions. I have the values for R, C the step length and the simulation time but I don't know how to use MATLAB particularly well. Any help is much appreciated!
0
0
0
0
1
0
I love to work on AI optimization software (Genetic Algorithms, Particle Swarm, Ant Colony, ...). Unfortunately I have run out of interesting problems to solve. What problem would you like to have solved?
0
1
0
0
0
0
The idea is to move all of the right elements into the left and the left into the right with an empty space in the middle. The elements can either jump over one or two pieces into an empty space. LLL[ ]RRR I'm trying to think of a heuristic for this task. Is the heuristic meant to aid in finding a possible solution, or actually return a number of moves as the solution? How would I express such a heuristic?
0
1
0
0
0
0
For the holiday currently described as [ck]?hann?ukk?ah? or thereabouts, 1 candle is lit on the first day, increasing up to a final 8 candles on day 8. However, there is an extra candle each day that is used to light the others. So, when you buy that box in the store, how many candles do you get?
0
0
0
0
1
0
I have two simple while loops in my program that I feel ought to be math equations, but I'm struggling to convert them: float a = someValue; int b = someOtherValue; int c = 0; while (a <= -b / 2) { c--; a += b; } while (a >= b / 2) { c++; a -= b; } This code works as-is, but I feel it could be simplified into math equations. The idea here being that this code is taking an offset (someValue) and adjusting a coordinate (c) to minimize the distance from the center of a tile (of size someOtherValue). Any help would be appreciated.
0
0
0
0
1
0
I find Google's In Quotes a really nifty application, and as a CS guy, I have to understand how it works. How do you think it turns news articles into a list of quotes attributed to specific persons? Sure, there are some mistakes, but their algorithm seems to be smarter than just a simple heuristic or multiple regular expressions. For example, a quote can be attributed to someone even though his/her name was only mentioned in the last paragraph. Any ideas? Any known paper on the subject?
0
1
0
0
0
0
Every so often I get the impression that my knowledge of mathematics (as it pertains to the field of software development) has some gaps. I'm an educated person. I have a college degree. I've always enjoyed learning, which is why I would like to try to fill in these gaps. My job is in the financial industry, and I feel like many of the large-scale number crunching tasks that we do could be made more efficient, possibly, if I had a better grasp on the mathematics/logic that's going into it, or concepts that could be leveraged as a shortcut. Do you have any suggestions? Books that you've found helped with this? Video lectures? EDIT: I should note that my degree is in Computer Science, so I am familiar with some of the areas of mathematics that are relevant. I'm just not sure how best to brush up on them or to refine what I already know :)
0
0
0
0
1
0
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
41