Tuesday, April 29, 2014

SCIENCE! continued

This is a continuation/update from my last post.

First off, as I said in the update to the previous post, the time lapse that we took overnight to try to make a video of the dye progressions, well, it didn't work so well. But I did add a new image to that post which shows off some of the dye showing up on the outside of the unopened blossoms.

The science experiment continues, and has definitely had some interesting aspects to it. My son's enthusiasm has waned a bit, but I think that is to be expected of a 5 year old. Of course, today he proudly proclaimed "I have a hypothesis! I think the leaves are going to turn purple!" (The show Dinosaur Train (warning: sound on that web page) has a character that makes lots of hypotheses).

Figure yes our counter is messy, for Science! (hush)

One of the things that my wife and I found really neat was that the dye seems to be separating out and we can see some blue highlights. The edges look a bit more purple to me today than it had previously, which is pretty neat. Plus, there now seems to be some of the dye showing up on the interior of some of the petals, where previously it had seemed to be confined to the edges. Also, one of the blossoms that had been previously closed has started to open, which was something I wasn't expecting. 

Figure this is my favorite picture from this project so far

Finally, because this flower has just started blooming, I've now set it up with the webcam and ChronoLapse to see if I can get a time lapse video of it opening. I think I may have to add some more water to the vase tomorrow though. It isn't in danger of drying out, but I want to make sure that it won't. I also think we added enough dye the first time that we won't have to add any more even if we double the current volume of water.








Sunday, April 27, 2014

SCIENCE!

I started a science experiment with my older son today.

Let me go back a few days though. One day last week, I was able to get out of work a bit earlier than normal. I decided since I actually had a bit of time before getting home, I would pick up some flowers for my wife, because she's awesome and sometimes I like to get her flowers to let her know she's awesome. They had lilies, which my wife is fond of, so that was the flower of choice.

Today, I remembered, or thought I remembered at least, that if you add food coloring to the water in a vase, then the coloring would eventually end up showing in the flower petals. After asking my wife's permission (they were her lilies after all) I got my older son to help me add some maroon food coloring and a bit of extra water to the vase. I also re-cut the stems, about 1 cm of the end of each, in the possibly mistaken belief that this would help speed up the uptake of the new water.

We also started a table to keep track of our observations, seen below. You can tell that I am a terrible speller without spell checker.

Figure teaching my son bad science habits like using pencil instead of pen

As you can see from our second observation, we actually started to see some change around the edges of the flower petals in the form of red "tick" marks. Since I now carry a camera around with me everywhere, just like almost everybody else in this country, I decided to take a picture:

Figure you know you're looking at sex organs, right?

It's hard to see it from the whole picture, so here is a zoom in near the tip of the flower petal on the bottom:

Figure my phone takes better pictures than I thought it could, this was simply a crop

One thing I was really surprised by was the first presence of the dye on the tips of the petals. I was expecting to see "rays" of red emanating from the center of the flower. But then, that is why you do the experiment! :)

Now I am running the program ChronoLapse and have set the lily up in front of my webcam to see if I can get a time lapse video out of it that shows something cool, hopefully the pigment either getting darker or spreading out more. If the video turns out well I'll probably post it. however, my web cam is hard to focus well, and has a resolution of 640 x 480, so cropping won't give me the zoom in effect like it does on my phone. However, if dramatic changes do occur, it should be a pretty cool video.

There is also always the possibility that Big Foot will break into our house to smell the color changing Lilies. Or the two-year old could become involved.

The best part of all of this? My son is super excited to make observations and see how it changes. Yay science!

UPDATE: The time lapse video didn't show much in the way of color spread. It did, however, show what happens during the sunrise which was pretty cool. The "ticks" on the petal edges are now darker, and we saw some red splotches on the outside of the closed flowers as well.

Figure I'm even less witty in the morning

Thursday, January 23, 2014

An Intersection of Politics and Optimization

I had a thought a few weeks ago, that something today jogged my memory about, and that is that one of the problems that most people agree on with regards to politics is gerrymandering. I've seen a few ways to try to combat it, from getting an independent (if you can find one) panel to divvy up a state, to just creating square blocks within a state and calling that good.

I have my own idea, but first I need to set it up so that it makes sense. As I see it, there are a number of competing, and possibly mutually exclusive, objectives when creating districts, and that is before even thinking about the political persuasion of the constituents. These objectives include:
  • Equal population in each district
  • District lines fall on county boundaries
  • Non-gerrymandered
  • Human Input into final decision (nobody likes to be told what to do by a computer)
There may be others, but I think these are a good start. It is almost guaranteed that optimizing for one will necessarily not be optimized for the others. As it is, we are currently optimized only on the last point, which we really can't assign an optimization function to anyway.

The first three, however, I think we can assign optimization values to. The first one is pretty easy, for a state of population P with N districts, where the ith district has a population pi then minimize the value of Sum(abs(pi - P/N)). You can use a squared value instead of abs if you want, that's just using the L2 norm instead of the L1 norm. Anyway, minimize that sum, and populations in each district will be equalized. For population data, use census data by precinct, assume that the population is uniform across the precinct (inaccurate, I know, but a good first guess).

The second one is a bit harder, but I think one way to express it mathematically is to minimize the the area which can be drawn between a district boundary and a county line. For a county that is split in such a way, count only the smaller area (otherwise the county could be cut any way you like). I'm sure others could come up with a way to optimize this as well that might make a bit more sense.

The third one could be mathematically imposed by minimizing the sum of the differences between the convex hull for a district and the district itself. If all of the districts are convex, then this sum will be 0. You will also have a non-gerrymandered state. For states such as Maryland, with its jagged southern border, it would probably be impossible to get this sum to 0, but that's still OK, we just want to minimize it for any given state.

Now, as I said before, these three cannot be complete optimized at the same time, and different people will put different weights on each of the objectives. Some people might believe that the population equality is most important, while others might believe that districts following county lines is paramount. This is almost where the human element comes in. See, even though people might disagree on what is most important, what can be done before assigning weights is to try to optimize over all of them. What will result is something called a Pareto frontier. Each point on the Pareto frontier represents a different weighting scheme. Some reasonable limits might also want to be enforced, maybe that every pi has to fall within 0.75 * P/N to 1.25 * P/N.

What would then happen is that a multiple objective optimization program can find a bunch of points on the Pareto frontier, in this case, each point is actually a specific map of the state in question. A set of these can then be handed off to a state legislature, or some other deciding body, and then they can select the one they like the most, bringing the human element back into it. They can then select the most optimal map for them if they like.

So there it is, a possible way to reduce gerrymandering while still leaving the final decision in the hands of people, possibly even state legislatures. I even think that this is a non-partisan idea. Also, I'd be happy to hear other (non-partisan) objectives that such a program might want to optimize for. It would be interesting if multiple states did this to see what the relative weights each state chose for it's given district mapping.

Thursday, January 2, 2014

Goals

So yeah, this thing that I never update.

Interesting thing about last year's posts, besides the fact that I didn't make very many of them. The most popular one was Building gcc 4.8. Mostly because it actually got linked in a Stack Overflow answer about the same thing. That was a point of pride for me :).

Looking forward to the future though, I have a few goals. Posting more on here is not one of them. I may post more, I may not. Last year I kind of stopped posting because I moved in July, and then I moved again in November. Between packing, unpacking, and unpacking again (movers did the packing for the second move), this kind of got left by the wayside. Anyway, on to some of my actual goals for 2014:

Fitness:

  • Do 2000 pushups, this actually seems pretty low. But if I hit it, I can always up the count next year
  • Spend 2000 minutes on exercise machines probably elipticals, though I think I'll count an actual bicycle toward this as well
  • Run a 5K, no walking. My eventual goal is a half-marathon (and maybe a full marathon someday, but we'll start with the half). But I want achievable goals for 2014, and I'm not sure the half-marathon is achievable for me

Household:

  • Build a 6 foot tall bookshelf. I built a solid pine 4' x 4' bookshelf a couple years ago. It is the strongest, and best looking bookshelf we own. It costs a lot more than the cheapo particle board ones, but the end result, and the experience, are worth it.
  • Play 36 board games during the year with my son. It is a way for me to spend quality time with my child as well as building his love for a hobby I love.
Technology/Professional:
  • Get a MySQL certification, I have to do more and more with databases, getting a certification is probably a good idea, at least from a resume perspective.
  • Submit at least one conference or journal paper where I am the lead author. I've got one in mind, but I'm not sure it is publication worthy
  • Complete at least 1 online course and get the certificate, I'm signed up for Convex Optimization through Stanford online, you can join me there if you'd like.
Well, there they are. They should be achievable. I'll start on them tomorrow, or this weekend at the latest :)