So, under the suggestion of a database admin for the Green Mountain Coffee Roasters, I made myself a website. It's not the greatest thing and definitely still needs work. But within the projects page there are links to read the papers that I've written on a couple of the projects that I've talked about here.
I'm also thinking about redoing my Python Obstacle Avoidance program, either in python with cleaner code and a nice paper alongside of it to walk through the reasoning in the code itself, or to redo it in Matlab because I feel that Matlab's plotting functions could be of great use. Especially because I could make demo code that would show the algorithm working in real time and could animate a graph on screen to show what it is doing. I really like this idea, and despite moving away from Python, I feel like it will be really good. I'll either have to look up how to do lambda expressions in Matlab, or just throw away their use all together. (If you recall, I used lambda expressions to create functions that would return the value of y given an x, using an equation of a line that was the instance of the class itself.) They weren't necessary in the implementation and were mainly just me trying out something new.
The Smartboard is still coming along, and a paper is in the works for that one. I'm also going to probably be doing some small program in MIPS assembly pretty soon and will have to present it to a class I'm enrolled in, so that may make itself onto my website as well, and quite possibly this blog.
I'm also contemplating redoing the Budget Buddy in C# due to it's Visual Studio capabilities and how easy file IO is in C#, not to mention packaging into an exe. These are all things for the future, and hopefully I'll have time to do them!
Heres the URL to my website:
http://www.uvm.edu/~ejeldrid
Hope you all enjoy.
Wednesday, November 23, 2011
Tuesday, November 22, 2011
Lambda Expressions in Python
Below is just a sample piece of code that I was playing with the other day, it was fun to mess with and interesting to see how the scope of the variables declared for the lambda expressions behaved. Mainly, that sometimes it seemed that variables declared within lambda expressions were accessible outside of what I thought their scope should be. This happened with the lambda expressions containing lambda expressions both expressions taking variables. It was a fun case study that got me away from all this serious project stuff I'm working on. And I figured I would share, so without further ado, here is the code: throw it into your favorite python IDE (command line, IDLE, eclipse) and run the show function and then play with it yourself. :)
#LAMBDA EXPRESSION TESTING
#Can you horribly abuse lambda expressions such that
#you dont have to actually create functions in a class?
class LamClass1:
def __init__(self,x,y,z):
self.x = x
self.y = y
self.z = z
self.getX = lambda: self.x
self.getY = lambda: self.y
self.getZ = lambda: self.z
self.norm = lambda a: a/(self.x+self.y+self.z)
self.xyLine = lambda m: (lambda n: n*m*self.x+self.y)
self.xzLine = lambda m: m*self.x+self.z
#nesting functions to return functions
self.makeLine = lambda m: lambda b: lambda x: (m*x+b)
#nesting arguments!
self.nesting = lambda m,b,x: (((self.makeLine(m))(b))(x))
#tupling it up
self.listF = lambda a,b,n: a+b,a*b,a-b,b-a,n
#This is a tuple you access to access a function how cool!
self.listT = lambda a,b: lambda n: (a+b)**n,lambda a,b: lambda n: (a-b)**n
self.shallowCopy = lambda: self
self.deepCopy = lambda: LamClass1(self.x,self.y,self.z)
self.tupleReturn = lambda a,b: (a,b)
self.funcList = lambda: (self.getX,self.getY,self.getZ,self.xyLine)
#you cant do multiple statements inside a lambda
#but you could nest everyline of code as a lambda being called and such
def show():
l = LamClass1(2,3,4)
#Standard gets but with lambda
l.getX()
l.getY()
l.getZ()
#An example of argument passing
f=l.xyLine(2)(3)
#Multi Function Computation:
f=l.listF[0](2,2,3)
#Example of how Scope Changes
f=l.listF[1]
print 'Global Scope of lambda variables'
print a,b,n
#you could write a =1 and then another print and watch it be strange
#Lambda Expression Variables are global, this could be bad
#Example of tupled functions
f=l.listT[0](1,2)(2) #(a+b)^n
f=l.listT[1](2,3)(3) #(a-b)^n
print a,b,n
#Notice how I have never declared a,b,n
#an example of shallowCopying and mutability
print 'Shallow Copy'
L2 = l.shallowCopy()
print 'l.x=',l.getX()
print 'L2.x=',L2.getX()
l.x = 3
print 'l.x = 3'
print 'L2.x=',L2.getX()
#an example of deep copy
L3 = l.deepCopy()
print 'Deep Copy'
print 'l.x=',l.getX()
print 'L3.x=',L3.getX()
l.x = 5
print 'l.x =',l.x
print 'L3.x=',L3.getX()
print 'Function List'
print 'l.funcList()[0]() -> getX()'
print l.funcList()[0]()
print 'l.funcList()[1]() -> getY()'
print l.funcList()[1]()
print 'l.funcList()[2]() -> getZ()'
print l.funcList()[2]()
print 'l.funcList()[3](2)(3) -> xyLine(2)(3)'
print l.funcList()[3](2)(3)
Monday, November 21, 2011
Wii Smartboard
The WiiSmartBoard that I'm working on with CS Crew is really coming along, we started working on it 2 days a week every week since early September. We're writing it in C# and using an open source library for interfacing with the Wiimote through bluetooth. When we first started working on it I went and looked through all the documentation for the WiiMote and found out which bits and bytes were returned from the wiimote and was ready to write my own assembly level parsing code. But then we were lucky enough to find the library that we did and I could focus on the actual concepts instead of the nitty gritty detail.
The cool thing is that we're going to attempt to implement a 2 and a half D flicking system to switch between "slides". I suppose I should talk a little bit more about the details.
We're using the Wiimote as a receiver for an infrared pen we built. We're drawing onto bitmaps on our GUI, but we also have buttons that will be able to be clicked. Each bitmap is a slide, stored inside of a lecture class my friend Scott and I created, when we save, we save a .lecture file that holds the information of the order of the slides to load, and saves the images into a subdirectory. It works really well because we're using two stacks to contain the bitmaps, so saving is as easy as popping and pushing them from one slide to the next and saving each one. And then when we load, we just load them in reverse order which is really the right way to do it because of the FILO structure of the stack.
I'm also writing up documentation on it and I'll definitely publish that onto my website.
The cool thing is that we're going to attempt to implement a 2 and a half D flicking system to switch between "slides". I suppose I should talk a little bit more about the details.
We're using the Wiimote as a receiver for an infrared pen we built. We're drawing onto bitmaps on our GUI, but we also have buttons that will be able to be clicked. Each bitmap is a slide, stored inside of a lecture class my friend Scott and I created, when we save, we save a .lecture file that holds the information of the order of the slides to load, and saves the images into a subdirectory. It works really well because we're using two stacks to contain the bitmaps, so saving is as easy as popping and pushing them from one slide to the next and saving each one. And then when we load, we just load them in reverse order which is really the right way to do it because of the FILO structure of the stack.
I'm also writing up documentation on it and I'll definitely publish that onto my website.
Tuesday, October 11, 2011
Proportions of a schema at time step t+1 with respect to mutation.
Firstly, I'd like to say that this is in no way linked to the Budget Project that has been on hold since my semester started again, this little gem comes from my own musings during a homework assignment for my evolutionary computation class.
Background knowledge for this piece of work:
Read up on Holland's Schema Theorem: Wikipedia Page on it
Understand how to multiply vectors, or at least take their dot product.
Moving on,
For a given population, at time step t, the number of schema's represented in the population is given by a vector of values between 0 and 1. We can compute the expected number of individuals from extending Holland's schema theorem with our own intuitive (and correct) terms. Doing this now, for a 2 bit problem:
(meaning that each schema in the population is only 2 bits long, and when I say schema here, I do not mean templates, I mean the actual members of the population of say, schema 00 or schema 11, NO wildcards.)
The probability of a schema surviving is the probability of both it's bits not being mutated. If we were mutating with probability Pm, then we can determine this survival rate as (1-Pm) squared.
The probability of a schema's complement (Think a standard not gate applied to all the bits, aka inverting, or flipping the bits, like twos complement but without the plus 1...) mutating into the given schema is the probability that it gets both bits flipped, or Pm squared.
The probability of terms representing half or partial complements being mutated is the probability of the bits matching the schema to not be mutated multiplied by the probability of the schema's non matching bits to be mutated into them. In short, (1-Pm)(Pm) and each term is raised by whatever bits match, and not match respectfully. (If this makes no sense, for a 2 bit problem, this would be (1-Pm)(Pm) or (Pm)(1-Pm) for the schema 01 and 10 if the desired schema was 00)
Now that we have those probabilities, we recognize that those probabilities multiplied by the number of the matching schema (not desired in most cases), and then summed, will give us the expected number of schema in the next generation at time t.
Now, my 'theorem' I suppose.
Let (1-Pm) = A, and (Pm)= B, o=number of bits, P= proportions of population
number of expected schema H at time t+1 = V((A+B)^n) dot P
Where V is a vector where each element i is the i-th term in the binomial expansion of (A+B)
We use the dot product to multiply the corresponding schema with the right probabilities and then tada, we're done. doing this for each schema in the population results in 2^n equations being calculated and the proportions of a generation at the next time step has been calculated.
Because this might not be very clear, due to my lack of knowledge if blogger supports latex or not, heres a bit more elaboration.
Expansions of a binomial are usually simplified, and then their coefficients make what is known as pascals triangle, however, in this theorem, the vector is composed of the UN-simplified version of the expansion, why? Because the proportions of the population can be different from one another, so you can't simply factor out the expansion, get the coefficients and multiply by the population now can you?
Also, the population vector goes from the desired schema up to the one previous to it. How? modulo arithmatic and mathematical trickery of course.
if we want schema 00, then our vector would be [00 01 10 11 ]. if we wanted 01? [01 00 11 10], what about 10? [10 11 00 01]
The goal of course of any population vector is to have the desired on the left, and the complement on the right, any bits between must correspond to their proper probability. This is the difficult part of any implementation, However consider this
000 A^3
001 A^2B
010 A^2B
011 AB^2
100 A^2B
101 AB^2
110 AB^2
111 B^3
Take the first, 000 as the desired bit string, and the other column as the probabilities assigned to it by the theorem, well we can notice that the number of complementary bits in the schema indicate how many times we should apply B, and the number of bits matching the schema apply to how many times A is multiplied by itself. Extrapolating from this, we could produce an implentation if we wanted to.
That is all.
Background knowledge for this piece of work:
Read up on Holland's Schema Theorem: Wikipedia Page on it
Understand how to multiply vectors, or at least take their dot product.
Moving on,
For a given population, at time step t, the number of schema's represented in the population is given by a vector of values between 0 and 1. We can compute the expected number of individuals from extending Holland's schema theorem with our own intuitive (and correct) terms. Doing this now, for a 2 bit problem:
(meaning that each schema in the population is only 2 bits long, and when I say schema here, I do not mean templates, I mean the actual members of the population of say, schema 00 or schema 11, NO wildcards.)
The probability of a schema surviving is the probability of both it's bits not being mutated. If we were mutating with probability Pm, then we can determine this survival rate as (1-Pm) squared.
The probability of a schema's complement (Think a standard not gate applied to all the bits, aka inverting, or flipping the bits, like twos complement but without the plus 1...) mutating into the given schema is the probability that it gets both bits flipped, or Pm squared.
The probability of terms representing half or partial complements being mutated is the probability of the bits matching the schema to not be mutated multiplied by the probability of the schema's non matching bits to be mutated into them. In short, (1-Pm)(Pm) and each term is raised by whatever bits match, and not match respectfully. (If this makes no sense, for a 2 bit problem, this would be (1-Pm)(Pm) or (Pm)(1-Pm) for the schema 01 and 10 if the desired schema was 00)
Now that we have those probabilities, we recognize that those probabilities multiplied by the number of the matching schema (not desired in most cases), and then summed, will give us the expected number of schema in the next generation at time t.
Now, my 'theorem' I suppose.
Let (1-Pm) = A, and (Pm)= B, o=number of bits, P= proportions of population
number of expected schema H at time t+1 = V((A+B)^n) dot P
Where V is a vector where each element i is the i-th term in the binomial expansion of (A+B)
We use the dot product to multiply the corresponding schema with the right probabilities and then tada, we're done. doing this for each schema in the population results in 2^n equations being calculated and the proportions of a generation at the next time step has been calculated.
Because this might not be very clear, due to my lack of knowledge if blogger supports latex or not, heres a bit more elaboration.
Expansions of a binomial are usually simplified, and then their coefficients make what is known as pascals triangle, however, in this theorem, the vector is composed of the UN-simplified version of the expansion, why? Because the proportions of the population can be different from one another, so you can't simply factor out the expansion, get the coefficients and multiply by the population now can you?
Also, the population vector goes from the desired schema up to the one previous to it. How? modulo arithmatic and mathematical trickery of course.
if we want schema 00, then our vector would be [00 01 10 11 ]. if we wanted 01? [01 00 11 10], what about 10? [10 11 00 01]
The goal of course of any population vector is to have the desired on the left, and the complement on the right, any bits between must correspond to their proper probability. This is the difficult part of any implementation, However consider this
000 A^3
001 A^2B
010 A^2B
011 AB^2
100 A^2B
101 AB^2
110 AB^2
111 B^3
Take the first, 000 as the desired bit string, and the other column as the probabilities assigned to it by the theorem, well we can notice that the number of complementary bits in the schema indicate how many times we should apply B, and the number of bits matching the schema apply to how many times A is multiplied by itself. Extrapolating from this, we could produce an implentation if we wanted to.
That is all.
Tuesday, August 23, 2011
Budget Buddy Progress!
This is the current progress of my budgeting program, the code and classes are made up for the accounts, checks, months, everything. The GUI and interlacing it with the underlying modules is all thats left. I've already started doing that, right now the 5 buttons at the top are the only things not working, as well as a few of the menu items.
On the to do list is:
The add items buttons and the other buttons associated with items and the main scroll pane that will hold the items that go into the budgeting for checks.
After thats done, making the GUI change when you select a different month and check and updating the panes that show information.
After that, the menu items such as saving and loading need to be done. After all of the main stuff, I just need to create the other panes such as the graphics and other things.
It will probably be another week or so before it's done.
Thursday, August 11, 2011
Budgeter
Hello Everyone!
I've decided on a project to do before I have to go back to school. I'm making a program that is effectively a smart checkbook. Only, right now I'm not making it to keep track of finances, but to budget them effectively.
Basically, When I get my checks from work, I open notepad and a calculator, enter my check amount into it, then slowly subtract out items as I enter them into the notepad document. So, basically I'm wrapping my setup into a program, and it seems like it's a good idea, mainly because 4 of my friends have taken an interest and have already asked to test my program once it's done. (As done as any program can get, aka release version that gets patches)
Right now I'm fighting between the urge to continue working on it, and the urge to go to bed, it is midnight, and I do have to get up at 7 tomorrow.... but when the mood takes one to code, you do not simply ignore it.
I've decided on a project to do before I have to go back to school. I'm making a program that is effectively a smart checkbook. Only, right now I'm not making it to keep track of finances, but to budget them effectively.
Basically, When I get my checks from work, I open notepad and a calculator, enter my check amount into it, then slowly subtract out items as I enter them into the notepad document. So, basically I'm wrapping my setup into a program, and it seems like it's a good idea, mainly because 4 of my friends have taken an interest and have already asked to test my program once it's done. (As done as any program can get, aka release version that gets patches)
Right now I'm fighting between the urge to continue working on it, and the urge to go to bed, it is midnight, and I do have to get up at 7 tomorrow.... but when the mood takes one to code, you do not simply ignore it.
Monday, August 8, 2011
Cluster is Done, next project
I made it about halfway through Cluster Swarm before getting to overwhelmed by work, friends, and readings. So I took a break from it, and never really got back to it. All the pieces are there, all the ideas, it's just a matter of putting the pieces together. However, I feel like my time would be better spent on other projects.
A few things I've considered, a Budgeting program that I could use to do my budgeting, (I do it in notepad right now), I could make it entirely in Java to make it transportable, I could make it customizable, and also include plenty of features that would be useful. I could model the Towers of Hanoi, and perhaps use what I've learned about genetic algorithms and evolutionary programming to evolve strategies and solutions to the towers. Although I'd probably restrict it to n <= 4 disks for the sake of managing bits. One way I thought about doing it was to use 30 bits to represent a solution to n=4 disks, each bit being able to be one of the three towers. I could initialize random bits to a few, then run it through a validity checker, essentially my fitness function, to see how well it does and to make sure it doesnt place a larger disk on a smaller disk. and then could add in how close to the optimal solution it was to determine it's fitness.
I also thought about representing the towers and their moves as a Grammar.
S -> aC | bC
A -> aB | aC
B -> bA | bC
C -> cA | cB | cƛ
ƛ -> null (end of moves)
You could simply build up possible moves, their validity would be checked by running them through a simulation of the towers, and then calculate how well they did. From their you could breed good solutions with other ones using crossover and mutation, or possibly use some type of neural net to 'train' a program to have tendancies to lean towards one change from one move to another. I'm not entirely sure on if I'm going to do this project yet or not. It's still up in the air.
A few things I've considered, a Budgeting program that I could use to do my budgeting, (I do it in notepad right now), I could make it entirely in Java to make it transportable, I could make it customizable, and also include plenty of features that would be useful. I could model the Towers of Hanoi, and perhaps use what I've learned about genetic algorithms and evolutionary programming to evolve strategies and solutions to the towers. Although I'd probably restrict it to n <= 4 disks for the sake of managing bits. One way I thought about doing it was to use 30 bits to represent a solution to n=4 disks, each bit being able to be one of the three towers. I could initialize random bits to a few, then run it through a validity checker, essentially my fitness function, to see how well it does and to make sure it doesnt place a larger disk on a smaller disk. and then could add in how close to the optimal solution it was to determine it's fitness.
I also thought about representing the towers and their moves as a Grammar.
S -> aC | bC
A -> aB | aC
B -> bA | bC
C -> cA | cB | cƛ
ƛ -> null (end of moves)
You could simply build up possible moves, their validity would be checked by running them through a simulation of the towers, and then calculate how well they did. From their you could breed good solutions with other ones using crossover and mutation, or possibly use some type of neural net to 'train' a program to have tendancies to lean towards one change from one move to another. I'm not entirely sure on if I'm going to do this project yet or not. It's still up in the air.
Subscribe to:
Posts (Atom)