Tuesday, April 14, 2009

Seeking help from Statistician

Suppose I have distinct samples of a cumulative density function at 0.01, 0.25, 0.5, 0.75, and 0.99 obtained from an interview. I can provide some constraint that the 0.01 point is not "too close" to the 0.25 point and similarly for the 0.99 and the 0.75 points.

I need to interpolate between the given points.

Now, of course there is not a unique interpolation, but I guess there is a maximum entropy interpolation that is in some sense closest to a Gaussian. I wonder how I would find out what it is.

Secondly, I would like to find distributions of the sum of two such distributions. I am imagining a Monte Carlo method would work, but if there is a closed form, so much the better. It needs to be reasonably computationally efficient and either available as a Python package or relatively easily programmed and tested. 

Thirdly, similarly for a product of two such distributions.

If there is not a closed form, I need a way to take samples of the distribution from Python. It's not hard for me to construct a method that is crudely correct in the sense that the biases are unlikely to matter for the purposes at hand, but it seems someone ought to be able to tell me how to do better.

It would be nearly hopeless for a small traffic blog like this to get an answer by itself, but I wonder if Twitter isn't going to prove useful for scientists to answer questions of this sort. So I've tweeted a call for assistance and pointed to this posting. It will be very encouraging if I get a useful response; I have little hangups like this one all the time.

Monday, April 13, 2009

Python float input validation

If you put 'nan' in as a string, a cast to float will not raise an exception.

I am not sure this is a good design, but the counterintuitive workaround is this.

To test if a Python float is not a number, see if it is equal to itself!
try:
....val = float(raw_input("Air speed of an unladen swallow: "))
except:
....print "foo"
if val != val
....print "foo also!"

Thursday, April 2, 2009

Turing Test Passed; Humanity Obsolete

@LizNeeley tweets:
A reverse image search engine - upload a pic, find where it came from, modified versions. Still in beta, but incredible. http://tineye.com


So I submitted this image, stolen for my main blog from Tom the Dancing Bug here.



I wanted to see if tineye could find the original, but it outdid me, and came up with this from
here: a different clip from the same strip of the same size and shape!

Google chat bug: Majitao

Who is Majitao?