Showing posts with label Math. Show all posts
Showing posts with label Math. Show all posts

Sunday, January 24, 2016

Least Squares Fit

I could have sworn that I'd created a post about the process of understanding how Tom used least squares fit to determine the slope of a set of data points. But I can't find it, so here is where I will go over the process in order.

First off, the concept of finding a least-squares fit can be understood simply as finding a linear function that most closely fits a set of points in (x,y) where for all (x,y), the sum of the squares of the differences of y=f(x) to the corresponding point (which is to say the errors) is a minimum.

This turns out to be something natural to solve using matrices, because the set of errors which is y - (mx + b) for all y's and x's turns out to be just a set of matrices:

[y0] - (m[x0] + b) = [e0]
[y1] - (m[x1] + b) = [e1]
. . . .
. . . .
[yn] - (m[xn] + b) = [en]



Some more links:

An example of a C program to compute standard deviation: http://alstatr.blogspot.com/2013/09/cc-variance-and-standard-deviation.html

An example of C code for computing the mean (as well as median and mode): http://stackoverflow.com/questions/20636914/c-mean-median-and-mode

A fairly obtuse presentation of least-squares-fitting basic concepts: http://mathworld.wolfram.com/LeastSquaresFitting.html




Saturday, January 23, 2016

Triangular Number Series

It turns out that the minimum number of point to point resistance measurements that you have to make to test between all of the pins on any connector is given by something called the triangular number series. If you have only 2 pins to test, you just need to make one measurement. If you have three pins, you test from the first to the second, the first to the third, and the second to the third for three measurements. For four pins it's 6 measurements, for 5 it's 10 and so on. Each number of the series, 1, 3, 6, 10... is the previous number of the series plus the number of the next place!

Here is an online calculator for numbers in this series, although it's mostly of passing interest since it's really easy to code a triangular number calculator in any language:
http://www.mathgoodies.com/calculators/triangular-numbers.html