math

Matrix Library for .NET

I'm looking for a good (well-tested, fully-featured, and ideally with a nice interface) matrix library for .NET/C#. My main requirements here are only that it should be free (I don't particularly care whether it's open-source in this case) and preferably support sparse matrix operations. The obligatory requirements are all the basic oper...

probability and relative frequency

If I use relative frequency to estimate the probability of an event, how good is my estimate based on the number of experiments? Is standard deviation a good measure? A paper/link/online book would be perfect. http://en.wikipedia.org/wiki/Frequentist ...

What is meant by the statement that functional programs are "more tractable mathematically"?

What is meant by the statement that functional programs are "more tractable mathematically"? ...

Normalizing FFT Data for Human Hearing

The typical FFT for audio looks pretty similar to this, with most of the action happening on the far left side http://www.flight404.com/blog/images/fft.jpg He multiplied it by a partial sine wave to get it to the bottom, but the article isn't too specific on this part of it. It also seems like a "good enough" modification of the datase...

Using Compile Assembly From Source to evaluate math equations in C#

I am considering parsing simple math equations by compiling from source at runtime. I have heard that there are security considerations that I should be aware of before using this approach, but I can’t find any info on this. Thanks C# .net 2.0, winforms ...

Math programming help for a gimble-based painting machine

Hi - I'm an artist involved with building various sorts of computer controlled machines. I've started prototyping a gimble-based XY painting machine and have realized that the maths needed are out of my reach. I'm a decent enough programmer but not strong in math- esp. 3D math. To get a sense of what I'm needing to do, it might be help...

What is the C++ function to raise a number to a power?

How do I raise a number to a power? 2^1 2^2 2^3 etc... ...

Splitting Probabilities

I've the following code in PHP which works fine (returns more or less 10 results each time it runs): function GetAboutTenRandomNumbers() { $result = array(); for ($i = 0; $i < 240; $i++) { if (Chance(10, 240) === true) { $result[] = $i; } } echo '<pre>'; print_r($result); echo '</pre>';...

.Net Round Bug

The Math.Round function for .Net 3.5 SP1 appears to round 0.5 to zero, while it rounds 1.5 to 2.0. I have tested this with decimal numbers, and the following code: decimal pos = 0.5m; decimal neg = -0.5m; Console.WriteLine("Pos: {0} Rnd: {1}", pos, Math.Round(pos)); Console.WriteLine("Neg: {0} Rnd: {1}", neg, Math.Round(neg)); Console...

Distance between 2 System.Drawing.Point

How can I find the distance between 2 System.Drawing.Point? I googled and didn't find it... Dim p1 As New Point(0, 10) Dim p2 As New Point(10, 10) Dim distance = ?? In this case, it should be 10, but what about here? Dim p1 As New Point(124, 942) Dim p2 As New Point(34, 772) Dim distance = ?? Thanks! ...

Best way to calculate ETA of an operation?

I am looking for the best way to calculate ETA of an operation (IE: file download) using a linear progress information. Lets say that I have the following method that gets called: void ReportProgress(double position, double total) { ... } I have a couple of ideas: calculate the progress in a set amount of time (like last 10s) a...

How can I improve this square root method?

I know this sounds like a homework assignment, but it isn't. Lately I've been interested in algorithms used to perform certain mathematical operations, such as sine, square root, etc. At the moment, I'm trying to write the Babylonian method of computing square roots in C#. So far, I have this: public static double SquareRoot(double x) ...

why does this simple shuffle algorithm produce biased results? what is a simple reason?

it seems that this simple shuffle algorithm will produce biased results: # suppose $arr is filled with 1 to 52 for ($i < 0; $i < 52; $i++) { $j = rand(0, 51); # swap the items $tmp = $arr[j]; $arr[j] = $arr[i]; $arr[i] = $tmp; } you can try it... instead of using 52, use 3 (suppose only 3 cards are used), and run it 10,0...

Implementing shuffle on the celestial jukebox

How would one implement shuffle for the "Celestial Jukebox"? More precisely, at each time t, return an uniform random number between 0..n(t), such that there are no repeats in the entire sequence, with n() increasing over time. For the concrete example, assume a flat-rate music service which allows playing any song in the catalog by ...

How to improve my math skills to become a better programmer

Even though I consider myself one of the better programmers on my CompSci course, I am fascinated by people who are really good at math. I have to say whenever I had a math-type assignment or exam my approach has been very formulaic, i.e. if I encounter a problem that looks like A I must use method B and the result should look like C, o...

Can someone explain Mathematical Induction (to prove a recursive method)

Can someone explain mathematical induction to prove a recursive method? I am a freshmen computer science student and I have not yet taken Calculus (I have had up through Trig). I kind of understand it but I have trouble when asked to write out an induction proof for a recursive method. ...

Binary math

If I know the number number y and know that 2^x=y, how do I compute x? ...

Max square size for unknown number inside rectangle

If I have a set of tiles (squares) which can be any number and they are to fill a container (rectangle) of an unknown size how do I work out the maximum size of the tiles without having any of them overlap. So if I have 2 tiles and the rectangle is 100 * 100 then the max tile size is 50 * 50. This would also be the max size of tile if ...

How do I generate character sequences like hexadecimal with a different base?

I have the following Perl script that generates a string based on a number: my @chars; push @chars, map(chr, 48..57), map(chr, 97..122); my $c = $#chars+1; for (0..50) { my $string; my $l = $_ / $c; my $i = int $l; my $r = ($l - $i) * $c; $string .= $chars[$r]; while ($i > 0) { $l = $i / $c; $i =...

Deducing item cost from totals?

This can be broken down into a simple trio of equations: a + b = 3 b + c = 5 a + c = 4 How can I best approximate the values? Note, I'll have many more such totals and variables in real applications. Particularly, I want to find if its possible to usefully approximate the cost of food by item lists and totals from grocery receipts. I ...