analytics

Saturday, April 23, 2011

Streaming Content

I'm not sure where to begin with this idea, I guess I'll start by pointing out some interesting web pages for streaming content over the internet. In a couple hours I found all these different websites (some I'd heard of before)
  The first thing I noticed is in the networks section, every channel I could think of that we get of on our cable plan has a website that has all the content from the channel. Except online it seems you can watch any episode of the show that ever aired, start it whenever you want, pause and rewind and so on. So that got me thinking about cancelling the cable all together. I'd still need the internet part of the service but not the box or that service.  It seems the content providers are cutting out the middle man of the cable companies except it happens that the cable companies are also the ones providing the internet so not completely. 
   Not to mention all the other streaming content in all the other boxes. But I feel like it leaves something to be desired first googling for a show to find out where on the internet you can watch it and navigating through each website's different layout to eventually find the episode you want and finally playing it. 
  So that brings me to my idea, I think it would be nice to have a front end to all this content where you can type in the name of a show and it returns links to the video you want that you can click on and it takes you to the relevant website and starts playing the video. But then I started thinking of more features the front end could have like keeping a list of the shows you like and giving you a notification of which shows had released new episodes and providing links to where you could watch them. So no more having to web surf to every individual site and find the show you like and check if there are new episodes or having to know when they air on TV it would just give you a list of what new stuff was available. I'm still coming up with more features the front end could have but I think you get the idea.  
  Anyway there's so much content on the internet now but it'd be nice to design a cohesive front end to easily find what you want and perhaps some additional features like I mentioned. I think it would be nice if it worked with a remote. Basically to try and capture what is nice about watching it on cable but with all the nice features that internet streaming provides. 
  

Thursday, April 21, 2011

Traveling Salesman

I wrote a computer program that tries to find a Hamilton Circuit , which is given a bunch of "cities" try to find a path that visits every city and ends back up where you start. Each city is connected to some of the other cities with roads. So to start out with your map might look like this:
It's kind of a mess, right? You might be able to tell from looking at it the path that solves the problem but it's one of those things that is easier for a human than a computer. So I wrote this program that as step 1 randomly puts these cities on a circle evenly spaced all around. Like so:
You can see that 7 is not connected to it's immediate neighbors so what my algorithm does is it goes through point by point and tries to move each point towards the other points it's connected to, and away from the ones that it's not connected to. So imagine that these points are going around the circle in different directions trying to get away from the ones they're not connected too and towards the ones that they are connected to. 

It finally reaches equilibrium where it can't seem to do any better and that is this final graphic...
 When the program is finished the points aren't evenly spaced around the circle like above but it was too hard trying to get it to output exactly like the program does. So imagine they are in this order but a little bit randomly spaced around the circle. Anyway the thing to notice is now there is a path all the way through all the points that visits every one and ends up back at the beginning (it's drawn as a circle). You can sort of tell by looking at it that paths all the way across the circle are unfavorable.
The interesting thing is this program does this really fast, it only had to move each point on the circle a certain amount 50 times, which sounds like a lot if you're doing it by hand but it is nothing to the computer. 
 Here is the source code to the program: 

import math
def distance(posa, posb):
    delta = posa-posb
    delta2 = posb + 360-posa
    
    if delta2 < delta:
        delta = -delta2
    if abs(delta) == 180:
        return 0
    if delta <= 0:
        if delta < -180:
            return delta%180
        else:
            return delta
            
    else:
        if delta > 180:
            return delta%180
        else:
            
            return delta

def potential(point, graph, pos):
    sum = 0
    for i in range(0, len(graph[point])):
        sum+= distance(pos[graph[point][i]], pos[point])
    all = set(range(0, len(graph)))
    n = set(graph[point])
    nc = list(all - n)
    for i in range(0, len(nc)):
        d = distance(pos[nc[i]], pos[point])
        if d < 0:
            d = 180+d
        else:
            d = 180-d
        sum-= d
    return sum    
def move(steps, graph, pos):
    for s in range(0, steps):
        for i in range(0, len(graph)):
            p = potential(i, graph, pos)
            
            if p > 0:
                if (pos[i]+int(round(p/10.0))) <360:
                    pos[i] +=int(round(p/10.0))
                else:
                    pos[i] += int(round(p/10.0))
                    pos[i] -= 360
            if p < 0:
                if (pos[i]+int(round(p/10.0))) >= 0:
                    pos[i] +=int(round(p/10.0))
                else:
                    pos[i] += int(round(p/10.0))
                    pos[i] = 360+pos[i]

def main():
    graph = [[1,2,5,8,9],[0,2,7],[0,1,3, 9], [2,4, 5, 6], [3, 6, 7], [0,3, 6, 8], [3, 4, 5, 8], [1,4], [0,5,6,9], [0,2,8]]
    pos = [0, 36, 72, 108, 144, 180, 216, 252, 288, 324]
    move(50, graph, pos)
    print(pos) 
main()



Sunday, April 17, 2011

Combined Sport

If you start comparing crew or rowing with sumo wrestling...
Muscles

  • Crew uses mostly the muscles in the front of the leg, the back, the biceps, and the gripping muscles in the hand...
  • Sumo wrestling uses primarily the back of the leg for momentum, and the abs, pecs, and triceps for pushing as well as an open hand for pushing.
Energy Use
  • Crew is primarily an endurance sport of using the most energy you can over a long period of time with short bursts of more effort
  • Sumo is more about short bursts of intense effort in rounds over a period of time. 
Body Type
  • Crew favors tall athletes about 6'4 with lean muscle mass to avoid sinking the boat
  • Sumo obviously favors not so lean athletes that average about 5'11 for leverage
Use of Force
  • The goal of crew is to keep up top speed in the same direction using a static form 
  • Sumo wrestlers need to rapidly change direction and form to move their opponent a short distance in any direction. 
The Sumo/Crew Bi-athlete (Guess)
  • Only slightly taller than average
  • 260 pounds
  • Maximizing the combination of endurance strength and max power output
  • Maximizing agility and balance
  • Strong in both of the two complementary muscle groups but perhaps in different ways
I think it was fun to imagine taking two entirely different sports both specializing in different kinds of abilities and combining the two and see what kind of athletes might be dominant in the resulting sport. 

Saturday, April 16, 2011

jewelry sculpture

I'm still learning how to use Blender, I made this abstract sculpture to possibly be an earring or a pendent though it could probably be something larger, like a sculpture in a park. I thought jewelry and abstract sculpture were good places to start in learning Blender because of the importance of geometrical form and material properties which are two of the basic concepts in Blender

Wednesday, April 6, 2011

find f(x)

I found this that relates limits as you get closer to f(a) to figure out the actual function f(x)

Tuesday, April 5, 2011

mnemonic for numbers

I found an easy way to remember long numbers, first I made a table with 3 columns that going to the right are less and less common letters...
I arranged them so they spell "Bad cows fmt!" and "ur girly pen" and the last is pretty much random...
so anyway what you do is say you have the first 31 digits of pi:
3.1415926535897932384626433 83279 5
you translate that to letters via the table (I'm only using the first column for this one):

C A O A W T D S W C W M T F T C D C M O S D S O C C M C D F T W

Then find an English sentence that every word starts with these letters.

Could Anyone Own A Wagon That Doesn't Sparkle? Who Could Want Mine That Fails To? Certainly Didn't Cost Much On Sale.  Does Someone Only Care Color? My Cover Doesn't Fit Too Well

And this little want ad and the phrase "Bad Cows FMT!"  (No idea what fmt means maybe a shooing sound?)
will encode 31 digits of pi!

Monday, April 4, 2011

video of the last thing in action

The last blog post I talked about a pair of parabolas that go through the same two points. I made this video of the parabolas as the two points each go around a circle one twice as fast as the other.
I used python to draw the individual graphs for each frame and then a program called ffmpeg to make a movie out of all the individual frames. 

Saturday, April 2, 2011

Second degree functions


So I noticed that for every two points there are two functions with 2 as their highest power that pass through those two points. Actually I thought there was only one at first from something I heard before, but there are two.
*EDIT*
 It turns out there are an infinite number of second degree polynomials that go through 2 particular points, these are just two out of an infinite number of them. 

Friday, April 1, 2011

Approximation with rectangles

Usually when you approximate a function you have to use an increasing number of rectangles to infinity to get arbitrarily closer to the area of f(x). But what I noticed was the pattern of how you get closer as you keep doubling the amount of rectangles.


So for the functions I've tried over the intervals I've tried, this formula in blue lets you approximate the integral over an interval using just 5 carefully chosen points and in just a few additions, subtractions and multiplications to get at what before took an infinite number of them. And it gives an exact answer whereas you could only keep getting closer before. 

*UPDATE*
Using this formula A(1) +(4/3)[A(2)-A(1)]
to evaluate integral(e^x, x=0..1) gives 1.717776531 instead of the true value of 1.718281828 so it's off a little for exponentials . Seems to work for polynomials though. 

*UPDATE2*
It turns out that when it works you only need 3 points' y values to find the integral, over your interval [a,b], you need to know f((b-a)/2), and f of both halfway points between that and the endpoints. Let's say our interval was [2,7] and we measured those 3 points to be f(4.5)=-50.625, f(3.25)=-13.203125, 
f(5.75)=-123.984375 after applying the blue formula:
we get: -4475/12

I hid from the formula but I know that these 3 points correspond to -x^3+2*x^2 the integral over that interval of which is:
-4475/12

Using the formula for x^4 +x^2 was off by 7.46, I get 658.666 instead of 666.1333
Still pretty close but I guess it's only exact up to cubics.
*Note That gives me the idea that if you know n points of a given curve, you can find the nth degree polynomial that runs through those (there's a formula for that) then integrate that over your boundaries, this should still be much faster than using an infinite number of rectangles.