analytics

Sunday, February 12, 2012

Measuring areas

I had this idea for measuring the area of ordinarily difficult to measure shapes. Consider a simple shape like the following:
You can imagine drawing a line just inside the perimeter of this shape, and then a line just inside that and so on and eventually I believe you will end up with something like a "skeleton" line:

So the perimeter of the skeleton line is 40. It is basically twice the length of the line.  The original perimeter is 46.28. The rule for the area is it is the average of the two perimeters times the thickness around the skeleton. The area of the shape above is (46.28+40)/2 = 43.14*1
If it were twice as thick everywhere it would be times 2 instead of times 1. 

It's easy to verify that the rule works for either a circle or a square where you consider the length of the skeleton to be 0. Also it works for rectangles.  I haven't yet extended it to more complicated shapes. 


Monday, February 6, 2012

bouncing dot analysis

I made a "level" comprised of walls that are either vertical, horizontal or halfway in between. Then you put a point in the level and it can move in one of the basic eight directions one pixel at a time. Then it bounces off the walls like so:
You can see it gets back to the original point moving in the same direction and then it repeats about every 30 seconds.  A little bit of analysis shows that what actually happens is there are two points in the pattern where the point completely reverses direction. And a bit of thought can deduce that a necessary condition for that to happen is two walls that can be connected by an uninterrupted line of possible point travel are aligned 45 degrees apart. By the way this video is 5000 frames long. 
   So you can design a level without that necessary condition, one easy way is to avoid diagonal lines in the level altogether so all the levels walls can only be increments of 90 degrees apart. Though I found you have to delete the very corner pixel of each rectangle when using my bouncing algorithm. 



In this 5000 frames of video the position and velocity of the point never repeats. It's easy to tell because around 3 minutes in the point eventually squeezed between the top left block and the wall and it never had before that.
  So a good question might be how long it would take to repeat a position moving in the same direction. If I find out I'll update this blog entry.

Monday, January 30, 2012

Comparing distributions

I was thinking if you have these various distributions, like here are four different normal distributions:
I got to wondering how you could find out if you randomly pick a number from say the green distribution, how often a number picked from say the red distribution would be greater. One way of doing it is simulating say a million trials on a computer and seeing how often one was bigger than the other. So doing that first:
The answer is 94.8768%

  But I was more interested in an exact solution so I thought of this formula:

I'll explain the reasoning in a second, let's see that it works first:

It came out to 94.8753% or pretty much the same. 
Anyway Maple makes it look really ugly but the just above is evaluating the integral in the next image up with the two distributions and over a suitable interval. And you see the result is the same to within a couple millionths as the computer simulation. Probably my formula is correct so I'll explain the reasoning:
Looking at the bounds of integration the inner integral is from r to d and the outer is from a to d, that means the integral is only being evaluated over points q,r where q is greater than r. Like for a particular r in the outer integral the inner one looks at every q greater than that r up to d and so on. Q>R
So for every possible pair of q,r such that q>r the function being evaluated is X(q)*Y(r) which is to say the probability of choosing a point q,r. There's a certain probability of picking a q from X and a certain probability of picking an r from Y so X(q)*Y(r) is the probability of picking both. So when you add up all those infinitesimal probabilities you end up with the total probability of picking a pair such that q > r for those two distributions. 
So in other words you have the probability if you pick a number from each distribution that the first is greater than the second. 
*Edit* 
This formula scales to any number of variables, incidentally. Here is an example where you have 6 independent uniform variables ranging from 0 to 1. And you want to know the likelihood of them being chosen so that each one you choose is bigger than the last one. 
So it turns out 1/6! which makes sense there are 6! possible orderings and any one should be one over that probability. The 1^6 I just wrote it like that so you could see it would be six distributions multiplied together. 

*UPDATE 2
Another interesting thing to do is something like calculate the probability that 3 uniformly random numbers between 0 and 1 will be able to form a triangle. You can set up the integral like this:
C is forced to be between b and a+b and b is greater than a. But there are 3 ways to choose which variable will be the hypotenuse so all in all there is a 50% chance that the three numbers will be able to form a triangle. 

Saturday, January 28, 2012

My campaign

I thought I could run for senator and have this website where people could discuss each bill and vote on it and I promised however the vote on the site came out that is how I would vote. Each bill could have a page something like:

Tuesday, January 24, 2012

Ping Pong waterer

I removed the other blog post about the rain barrel water distributor. Here is my new design:
Basically there is a rain bucket with a hose going to the bottom, and on the other end there is the top of a plastic soda bottle with a ping pong ball in it. Water will I hope drain from the rain barrel that's at a higher elevation but as the water gets higher in the container being filled the ping pong ball floats until it blocks off the water from filling it any more. Then as a pet or a plant drinks the water the ping pong ball sinks with the level of the water and open the flow from the barrel again.

*EDIT*
Works like a charm here is a picture. The orange thing in the neck of the bottle is the ping pong ball. The only thing different from the design above is there has to be a hole in the bottle just below where the ping pong ball seals it off so the air can get out of the bottle.


To see how this problem is normally solved look at this:
http://en.wikipedia.org/wiki/Float_valve
Mine's a lot simpler isn't it?


Monday, January 9, 2012

Sum of sine of decreasing angles

I thought of this sum to check and see if Maple knew how to calculate it:

You see you add the sum of the sin of pi/2, pi/4, pi/8... But maple does not know what it is.
But I found that it seems to have a finite limit...

It seems to be converging to something like 2.481... which doesn't get any google results for the first few digits the way most well known mathematical limits would. 
Just a reminder the sin(pi/2) = 1, the sin(pi/4)=sq(2)/2, and then:
sin(pi/8)=


So anyway when you add these all up it apparently has a finite sum but it doesn't seem anyone has mentioned this particular limit before. 

Thursday, January 5, 2012

one formula for regular polyhedra

I never realized this before but one formula does the area for every regular polygon's area given a perimeter and a number of sides. And then the limit as the number of sides goes to infinity gives a formula for the area of the circle based on circumference.