02 - Christmas

An anticipation before unconciousness, abrupt awakening awareness, undignified scampering, tearing of presents, hefty portions of food, and the end of a day well spent with family. Being together in a special time of thanks and wonder; this is the magic of Christmas.

When did we lose that magic?

We’re all grown up, now, adults or nearly so, having long ago shed our hallucinations of a jolly old man that delivered presents to the good and punished the bad (or only some of the hallucinations, but that post is for another day). Now this modern day approximation of a winter solstice celebration is almost just another day, bracketed by shopping sprees and frosted with religious trappings. Cherry picking the worst, outside of my family is worse: people dreading meeting their semi-estranged relatives, or trying to force some good cheer in an empty apartment.

This is is different from what we want: there is a culture-wide agreement that Christmas is best kept magical, that everyone could do with some good cheer once in a while (even if it is derived from a holiday co-opted into a capitalistic enterprise). In the tradition of only penning antagonistic opinions, I agree with the sentiment: Newtonmas should be kept magical. However, the way I propose doing it is by destroying Christmas (and not replacing it with Newtonmas: again, that post is for another day, and really, Newton isn’t that important).

Before I start, what is magic? Is it an alias for utils? An alias for hedons? Maybe: I like to think that this highly subjective and ill-defined term is shorthand for the amount of blowing-someone’s-mind-in-a-positive-way that happens (it seems like this sort of thing might be a discrete measure, but the amount by which you can blow someone’s mind is continuous. Blowing someone’s mind by showing them a youtube video of people base jumping is probably less of an impact of showing them the internet for the first time). Blowing their minds with kindness, blowing their minds with an invisible jolly obese elf that delivers presents to the children of the world, blowing their minds with good food: I know trying to tamp down a general definition on these words is a futile effort, but I think this will do.

So back to destroying Christmas: do I wish to kill the magic of Christmas? Wrong! I want to learn the secrets of infusing Christmas with magic so I can sustain it forever![1]

(That line might show up in future posts too. Sorry)

Another way of putting it: let’s explicitly optimize for magic while it’s Christmas, and then never stop.

Maybe I’m naive, that this can’t happen easily and that it’s in fact hard, but then I look around inside a church and see people passively accepting of the gospel that seems inane to me, and I think that maybe it isn’t so hard. We’re just swept up in the narrative of our lives, too busy to optimize, not knowing how we can optimize, or ignorant of the fact that we can (ignoring Mazlow’s heirarchy for now).

One way to think about this is through random rewards: research indicates that randomly timed rewards are better for reinforcement than regularly timed rewards. Now, our friends aren’t rats under the will of our carrot-stick methodologies, but it seems to indicate that a random gift is more impactful than one agreed upon beforehand, and also removes the awkward gift giving that happens because it has to happen, because, you know, it’s the holidays.

Or something longer term: people might object, claiming that people are built on cyclical natures. Boom and bust, hard work and relaxation, it all follows the deeper rhythms of life. But we’re on the edge of changing ourselves to not be constrained by such things: while people may object about infeasibility or short-term intractability, we can look to where we’re not constrained by crippled wetware, remind ourselves where we could be.


By the way, this is probably a bunch of bullshit. Actually, it is definitely a bunch of bullshit, with a small probability of being right. You will survive.

Optimization of a Color Cycler

One of my projects in progress depends on the generation of different colored objects (Trust me, once I actually get a release pushed out, it will make sense (actually, I also need to push out a new iteration of my LaTeX editor. Note that I’m putting the name up for reconsideration)). First, I’ll define HSV space for y’all: assuming that you are familiar with RGB space… or, RGB space is the definition of colors by red, green, and blue components (hence the acronym RGB). Usually, computers will use 8 bits to define each channel, for a total of 24 bits to define a pixel. But I digress. HSV uses hue, saturation, and value for it’s definition, hue being the color (say, orange versus blue), saturation the presence of that color (ex. 0 saturation is white, total saturation a bloody red), and value the brightness (ex. 0 value is black, high value something not-black). In this particular case, I’m using HSV since I can set the saturation low, value high, and change the hue for a rainbow of easy-on-the-eye colors. However, it is problematic if one can’t distinguish between two objects that are supposed to be different.

One strategy that comes to mind is using some sort of binary division (for illustrative purposes, I’ll take hue 360 = hue 0): Take the first value to be 0, then 180, then 270, then 90, etc. However, it isn’t dead easy to code, and another programming scheme that could work is merely adding a constant to each iteration and modulating it by 360 (ex. 0+105->105+105->210+105->(315+105)%360->60 (where % is the modulus, otherwise known as the remainder)), which is dead easy to code. However, adding a constant could result in trouble: if you choose 90, you’ll start getting duplicate colors after 4 steps. 91 isn’t much better, because while the colors are not exactly the same, they are pretty close, perhaps nigh indistinguishable. How do you choose the constant that will put off disaster for the longest time?

Guess and check is a time-honored method, and it yields okay reults: I made up a constant and used to to almost no ill-effect. However, one could do better. Checking each constant by hand is tedious, but only by hand: if you brew up a script, then its turns out to be a bit simpler.

For a naive script, we do iterations until we get a duplicate of a previous iteration: the number of iterations before termination is a measure of quality, where higher numbers are better. Note, as a curiosity, that if the bound were some prime number, rather than 360, then many constants will turn out to be the maximum number of iterations with this method. However, we still need to take into account how close the subsequent hues are (for instance, 1,2,…365 works, but it really doesn’t).

To work around this, I used a sort of logistic function to decrease the amount of influence later numbers have, since the application doesn’t expect someone to be using 50+ objects at once. To do this, I weighted the hue-distance between the nearest colors (for each color added: I didn’t go back and recalculate all the distances for each iterations, although that might give us a different answer) by the reverse logistic function translated so that the first 20 colors had a pretty big say relative to everything else. Ah, well, here, have some code.

[python] #colorlen.py import math

n = 360

def modlen(a,b,limit): nominal = abs(b-a) h = (limit-b)+a L = (limit-a)+b return min([nominal,h,L])

def fitness(i,prev): return sum([1.0/(1.0*modlen(x,i,n)**1.0) for x in prev])

def total_fitness(m): i=m f=0.0 steps=0 prev = [0] while not(i in prev) and steps<50: f += fitness(i,prev)1.0/(1+math.exp(0.01(steps-10))) prev.append(i) i = (i+m)%n steps +=1 return f-steps

def main(): lst = [total_fitness(m+1) for m in range(n-2)] best = lst.index(min(lst)) return best+1

print main() [/python]

While writing this up, I’ve realized that I could do some more work on this and have some pretty graphics to show to everyone. Hmm, I’ll have to fit this in somewhere…

Oh, and hope this was helpful to someone. Dunno, go and write code fruitfully?