Thursday, October 16, 2008

I'd better just change the subject

I should qualify this by saying that my field is physics, not economics, but I think there's a strong argument you can make about the financial crisis that is not at all an indictment of the free market. My understanding of the financial crisis is that there's three primary culprits: 1) a systematic underestimation of credit risk, 2) excessive subprime lending, 3) mortgage derivatives linked to the excessive subprime lending (credit default swaps, CDOs that apparently no one knew how to quantify).

(1) seems to me the underlying factor. One interpretation of this is that bankers just used the wrong probability distribution to estimate risk (a normal instead of a Lorentz distribution, and a gaussian decays much faster than a Lorentz function, which follows a power law). Alright, but why? One answer, I guess, is that bankers (to paraphrase the unlamented Rumsfeld) didn't know what they didn't know. If you're modeling a chaotic system containing lots of recursive feedback loops, and things seem to be following a roughly bell-shaped curve, to start with, shouldn't you examine the function's asymptotic behavior carefully to make sure it's actually a bell curve, and not, for example, a Lorentz function, which has a completely different scaling form? Another, possibly more convincing answer, is that bankers just assumed that even though their mathematical model was incorrect, it wouldn't matter, because they could just use (in my opinion, absurdly complicated) derivatives to push the risk off onto the big investment banks, by way of Fannie Mae and Freddie Mac. Which are, of course, government-sponsored enterprises, which had, as I understand it, fairly explicit instructions from Congress to encourage subprime lending. At least some of the complex credit derivatives, and the special legal classifications built around them, were created by Fannie and Freddie, as well.

So, as a political football (and it's nothing if not that), there's plenty of blame to go around. From what I've read, there was plenty of bona fide stupidity involved. (Anecdotally, the guys I knew in college who went into banking didn't seem like the brightest folks around, but they were geniuses compared to the people who wanted to go into politics.) My understanding is that both John McCain and Barack Obama were complicit, although they're both dissembling ferociously and scrambling for the moral high ground. Not having Rick Davis blathering on his behalf has probably helped Obama in this regard. Congressional Democrats have firmly exonerated themselves, which makes no sense, but the Republicans see the whole economic mess as such electoral poison (economic issues tend to favor the Democrats, etc.) that they're not making an issue of it. This is reasonable short-term (read: electoral) but disastrous long-term politics, to say nothing of policy. The worst part is that the argument is so simple: the Republicans could really drive home the point that 1) the housing and financial markets were actually heavily regulated, 2) these regulations were a big part of the problem, so 3) in reality it wasn't anything like a free market, so this isn't an indictment of free market economics.

This doesn't mean the bailout is good or bad, and I really have no idea what ought to be done at this point. But I think the near-universal consensus that this was caused by an unregulated market run amok is wrong, and while I do think the bailout itself has to be very carefully regulated, I don't think a blind charge into more regulations on this or other markets is necessarily going to help. Obama's been quite vocal about McCain's history of deregulation, but unfortunately, McCain's response to this has been to recklessly invent schemes to out-regulate the Democrats. But hey, who needs principles when you can change the subject?

Sigh.

Further thoughts: I guess I should append to this that the actual unregulated markets were the secondary markets (credit default swaps and collateralized debt obligations), and it's the fact that each default had a huge number of derivatives attached to it that allowed the subprime crisis to amplify to the point where it could sink these huge investment banks. This is, of course, what everyone's focusing on, and why the Republicans are so leery about confronting the issue: the deregulation of the secondary markets was, I think, pushed through by Republicans. But the key point that often gets missed is that this only became an issue because of the heavily (but poorly) regulated mortgage market. To draw the analogy out a bit, everyone's up in arms trying to figure out how the signal got amplified (which is important), and completely ignoring the faulty wiring that produced the signal in the first place.

Tuesday, October 14, 2008

A cure for cancer

I thought of a way to cure cancer, using gold, light, and a genetic circuit. I'll update this later; I'm going to flesh this out for a fellowship proposal!

Monday, October 13, 2008

Thought of the day

Is the life of a graduate student much different from that of a monk? I guess I don't know that much about how monks live, but I spend most of my waking hours isolated, thinking. It's possible for me to go entire days in total silence. It's sometimes jarring for me to return to normal conversation, since the thought patterns accompanying it are so different. I tend to eat sparingly and simply because I can't really afford anything better. I haven't been in a real relationship for...I don't even want to think how long. A year and a half now, I guess.

Not sure how I ought to feel about this...

Saturday, October 04, 2008

What happens when you poke a red blood cell?

First of all, I've got to ask...why call it an erythrocyte? Red blood cell is so much better, just rolls off the tongue. Almost seems like something you'd want to know more about, just based on how great the name is! Almost. But! If you couple that great name with its simplicity - and the fact that they're damn important, and red blood cell structural deficiencies are implicated in a whole host of diseases, the most famous of which is probably sickle-cell anemia - then you've got something worth looking at, I'd say.

You can use an experimental technique called optical trapping to analyze the mechanical properties of red blood cells, and this can get you force-displacement data all the way down to the piconewton level. (For reference, the force exerted by the Earth's gravity on the typical person is between 600 and 700 newtons. A piconewton is 10-12 newtons, or 1 trillionth of a newton. Impressively precise information, in other words!) Optical trapping works on the principle that when a laser is passed through a high-refractive index dielectric (in this case, a tiny silica bead), its photons lose momentum, which causes the bead to move towards the laser's focal point. Attaching these microbeads onto red blood cells can be used to extract information about how much force is required to stretch the cell a certain amount (the resulting plot of this information is called a force-displacement or force-extension curve). The question is, can you use this information to build a model that accurately describes red blood cell deformation?

Well, you can try, and it turns out some pretty sharp folks have been trying for a while, since red blood cells are unusually tractable for eukaryotic cells because they're so simple. There's no nucleus. No mitochondria, no insulin receptors, no organelles at all. They're just small, not-quite-donut shaped bags of hemoglobin. This is nice, because it lets you focus just on that bag, and ask, What's its structure?

That simple question turns out to be fairly complicated, though. The RBC cell wall (composed of a phospholipid bilayer, membrane proteins, and cholesterol molecules), sits atop a flexible grid of a structural protein called spectrin, which looks like a ropy mesh joined together in a network of interlinked triangles, with a complex of other structural proteins at each vertex. Think of a fat man lying on a hammock, and you've got the right basic idea (fat and cholesterol sitting on top, and a concave grid beneath...it's a better analogy than I realized, actually!). Each of these spectrin links is like a rope, composed of two long, flexible rods (called polypeptides), very similar to one another, which are twisted together, running antiparallel between the junction vertices.



So it turns out materials scientists have already done the hard work of developing mathematical frameworks for different sorts of polymers, including the aptly-named worm-like-chain (WLC) model. This is pretty much what it sounds like: it's just a way of modeling a polymer that is a continuously flexible rod, and has been used to model things as disparate as strands of DNA and strands of cooked spaghetti. By using this model to describe the force-displacement behavior of the individual spectrin molecules, we can extract three key pieces of information about it: its length at equilibrium, the maximum extension length of the link, and its persistence length. Considering the polymer as a parametric curve described by a single path variable, the persistence length is defined as the value of this variable at which there's no longer a correlation between the unit vector tangent to the curve at 0 and that at the current value. Less formally, the persistence length tells you how stiff your polymer is: if you poke one end of a piece of uncooked spaghetti, that affects the whole strand, but if you do the same thing to a piece of cooked spaghetti, only the end and a little length near it will move. It turns out this 'little length' is about 10 centimeters; that's the persistence length value. In contrast, a DNA double-helix has a persistence length of around 50 nanometers: it's about 2 million times floppier!

What the WLC model gives you, mathematically, is the force exerted on each spectrin chain as a function of the chain's length. This is useful because you can integrate over the chain's length to derive the Helmholtz free energy (which is a thermodynamic state function that tells you, basically, how much work you can get out of an isochoric, isothermal process) contribution from each spectrin chain. Do this for every chain in your system, and add them up, and add that whole sum to the total hydrostatic elastic energy stored in the membrane and assorted proteins, and you've got an expression for the free energy in the entire plane defined by your spectrin network. This in-plane free energy can, in turn, be summed together with the bending free energy, as well as the surface area and volume free energy constraints on the system. The upshot of all this is that you've now got a way to mathematically describe how a red blood cell responds to mechanical stress, by calculating how the total free energy of the system changes.

This model is very high-resolution: it gives you a description of the network all the way down to the individual junction complexes. However, the computational cost of these simulations is steep: since each junction complex is a degree of freedom in this model, this results in about 30,000 degrees of freedom! A useful adjunct to this model, then, would be a way of systematically coarse-graining this model in order to reduce these degrees of freedom and the corresponding computational cost. Coupling this with a coarse-grained flow model, it would be possible to model large numbers of RBCs in the bloodstream.

And, that's the punchline, of course...there was a nifty paper, published last month in Physical Review Letters, that outlined how you'd go about doing this.

So, how can you coarse-grain this model? Basically, you just need to decrease the number of vertices you're considering, but how do you do this without losing accuracy, since the original model was set up so that the number of vertices approximated the number of junction complexes in an actual red blood cell? One simple way is to consider coarse-grained versions of the parameters in the finer-grained model: that is, estimating the effective parameters (equilibrium length, persistence length, hydrostatic elastic energy, and spontaneous angle) based on geometric arguments. The effective equilibrium length (and maximum length, which is taken to be around triple the equilibrium length) can then be estimated as the actual equilibrium length in the finer-grained model multiplied by the square root of the ratio of the number of particles in the finer to the coarser model. A similar argument can be made for the spontaneous angle between adjacent triangles: the effective angle is the original angle multiplied by the ratio of the coarse to the finer equilibrium length.

Coarse-graining the parameters in the in-plane energy equation is more complicated. One way to accomplish this is using a mean-field argument, which is a way of estimating the properties of the network by ignoring the correlations between vertices. That is, estimate the physics of the whole network from that of a single vertex! Using this approach, you can derive expressions for the shear modulus (the ratio of shear stress to shear strain) and the bulk modulus (the resistance of the membrane to compression). This method provides a handy way to coarse-grain the persistence length, as well, since in this mean-field argument the shear and bulk moduli are unchanged from their fine-grained values if the ratio of the equilibrium to the maximum length is fixed. The persistence length can then be systematically adjusted as the product of the original persistence length with the ratio of the fine to the coarse grained equilibrium lengths.

Taken together, this gives us a framework for extracting a complete set of parameters for the model at any level of coarse-graining. Of course, although you can extract effective parameters for an arbitrary level of coarseness, this approach won't be useful if you pick a vertex number of, say, 3. So how far can you take this approach, exactly, before you lose the ability to describe the cell deformation meaningfully? The most straightforward way to answer this, as well as to assess how useful this procedure is in general, is to just brute-force the question (AKA heave a big pile of simulations at your hapless cluster and spend a week drunk and high with a giddy pack of scantily-clad valley girl strippers in Vegas as your data collects itself, not that I would ever do that of course). So, cheap suits and bowls of cocaine at the ready, the authors run a bunch of simulations and discover...the lower limit is about 100 vertices. Below that, the simulated deviations in the cell's axial and transverse diameters become more pronounced. Here's a snapshot of their data:



The plot shows both axial and transverse force-displacement curves. The black diamonds are experimental data points, whereas the solid colored lines represent simulation results at different levels of coarseness (blue line: 23867 points, red: 5000, green: 500, magenta: 100). Except for the magenta axial (lower) curve, the simulated curves are in relatively good agreement with the experimental results. The inset gives an idea of how sensitive their model is to the way they adjusted the persistence length. All the curves except the magenta curve use the adjustment procedure described by the authors; the magenta curve retains the fine-grained value for the persistence length, and as you can see, the results are nothing like the desired linear relation!

So, this is interesting because it shows that their coarse-graining procedure produces results that are comparable to the much more computationally intensive fine-grained model, and fast is always good, of course, because faster = more time to tweak = less power used = less money used, etc. But the real value here is in using the coarse-grained model to do flow simulations of RBCs in circulation. They do this using the dissipative particle dynamics (DPD) method, which is a way of describing clusters of molecules moving together in a flow. The RBC and surrounding fluid are both modeled as DPD particles, and their interactions are modeled using soft quadratic potentials. The flow domain (the simulated capillary) is a tube 10 microns in diameter. The RBC starts out immersed in the fluid, at rest, in the middle of the tube, and then they watch the flow simulation develop. The deformation sequence for 500 vertices is shown below:



The 'parachute' shape observed in (c) is consistent with experimental observations, as well as is the ultimate restoration of the RBC's biconcave shape. They also simulated the behavior of the RBC in a shear flow, and confirmed that their simulations seemed to match experimental evidence.

Pretty neat, all in all. I still need to look into how DPD works (I have only the most general sense of the technique), as well as exactly how you do an optical tweezers experiment, since that data is kind of at the heart of all this!

Thursday, September 25, 2008

I hate it when that happens

My bank just died.

Crud.

Thursday, September 18, 2008

Huh?

What kind of insanity is this? McCain's not willing to meet with Spain's prime minister? I mean...what?

Tuesday, September 16, 2008

Brisbane

My new place:




As the saying goes, it's not much, but I call it home.

Good news

I found this to be oddly heartening: both Obama and McCain seem to have their heads screwed on pretty straight with regard to a wide variety of science-related issues.

Friday, September 12, 2008

Politics ad nauseam

There's one thing to be said for this year's election circus: it's a much more interesting spectacle than any I've seen before. What's also interesting about it is that the candidates are not reaching for the middle: Obama and Biden are both pretty far left, both economically and socially, and McCain's pretty much the personification of national greatness conservatism. The media's made a lot of hay out of McCain's policy shifts (and correctly so, in my view), but his real core's always been about America's awesome, our military is ridiculously powerful and we should use it like a battering ram whenever possible, and also have you heard that I was a prisoner of war because it's not like I mention it six times a day prior to shaving. I'm still trying to figure out exactly what Palin's all about. She certainly seems to lie a lot. You'd think if you were going to introduce yourself to the nation by telling lies, they'd be about things that were not easily verifiable.

GOV. SARAH PALIN: [repeat forcefully 25x] I hate earmarks, America! I told the federal government Thanks but no thanks on the Bridge to Nowhere!

CHARLIE GIBSON: That's actually not true. In fact here's a picture of you literally wearing a T-shirt saying you support it.

GOV. SARAH PALIN: Uh, well, I-

SEN. JOHN MCCAIN: [raging] BARACK OBAMA WANTS TO SHOW YOUR KINDERGARTENER PICTURES OF HIS BLACK COCK, I SWEAR TO GOD! LOOK HOW CREEPY AND BLACK HE LOOKS IN THIS PICTURE AS HE HOVERS OVER VARIOUS YOUNG WHITE CHILDREN! DID I MENTION I WAS A PRISONER OF WAR BY THE WAY BECAUSE I THOUGHT YOU MIGHT NOT HAVE HEARD SINCE YOU'VE BEEN LIVING IN A CAVE, VERY SIMILAR TO THE PRISON WHERE I WAS ONCE BRUTALLY TORTURED BY THE VIET CONG!

...which is more or less what the past week has seemed like to me. Entertaining, in sort of an idiotic, surreal way, and kind of depressing for the same reason. This is our politics, huh. How about debating policy, guys? Anyone? Mention a policy? Joe Biden had some policy tidbits, too bad he fell down an open manhole cover and died, which is what must have happened because why haven't we heard from him in like a week?

That said, what's interesting about the race is that it makes you review your political leanings, since it isn't permeated with the odd feeling that all the candidates are actually the same guy (the guy being the bastard love child of Ronald Reagan and John F. Kennedy, actually a robot controlled by Karl Rove, who is actually a robot owned by Halliburton). When people ask, I tell them I'm 'basically a libertarian.' Kinda. I like the idea of small government, anyway. Or, more precisely:

Economically, I'm in favor of free markets. They're efficient, they're responsive, they're Adam Smith's cold dead invisible hands crushing our lives into meaningless dust. Just kidding. But in general, I think if a job can be reasonably done by private industry, it should be done that way and the government should leave them alone to do it. There are areas that are not handled adequately by private industry, in which case I'm fine with the government doing it. Environmental protection is one really obvious example of this, and one where I differ sharply from orthodox libertarianism. Yes, you can imagine hypothetical scenarios where a private company would want to protect the environment. But there are enough cases where profit and conservation part ways that the free market, left to its own devices, will give the environment a nice firm rogering. The solution isn't to nationalize these industries, as some of the more fringe leftists would suggest, but to regulate them. This is already being done. Tweaking the level at which this is done is fine and probably a good idea, proposing to either massively deregulate everything or nationalize everything is not fine.

Socially, I'm about as liberal as you can get. While I've got a relatively boring personal life, I fully support your right to use all manner of wild and crazy drugs, have sex with and marry whoever suits your fancy, believe in whatever the hell you want to believe in, and so on. I've got mixed feelings about abortion, but I certainly don't think it's the federal government's business to say you can't have one.

Pet hot button issues of mine: science (more funding for all the natural sciences, please, both basic and applied), space (more space development and exploration, not just lip service, and support commercial space initiatives, please), free speech (book banning, censoring, and excessive political correctness are all pretty horrible things, and yes 'speech' on the internet and in video games still qualifies as speech), guns (don't own one myself, but it's really not ok to say that people shouldn't be able to defend themselves, and yes the second amendment really does guarantee that right, so stop pissing on it).

Where does this odd melange of ideas leave me with regard to this year's elections? If you just look at policy details, it's actually kind of a toss-up. The elephant in the room (pun intended) is that John McCain is older than the big bang and has a temper hotter than dirt (OOPS, DID I FLUB THAT LINE? MAYBE IT'S BECAUSE I'M 72 YEARS OLD AND SENILE AND HAVE NO BUSINESS RUNNING FOR PRESIDENT BECAUSE I HAVE ONE FOOT IN THE GRAVE AND THE OTHER IN MY MOUTH BECAUSE I'M SENILE AS HELL), and regardless of his particular policy stances, really isn't temperamentally suited to be President. Frankly, I'm not sure Sarah Palin is, either, although in her case I'm willing to chalk it up to ignorance. Not that that's much better. Perhaps we should go to war with Russia? Not even the most diehard supporters of the Bush doctrine think that. Not that Mrs. Palin would know.

So, damning him with faint praise, I'm supporting Obama. I do like his idea of changing the tone of politics in Washington. Too bad the McCain camp ruined that by burying him and his change of tone underneath a giant stinking mound of political feces. Thanks for nothing, assholes.

Tuesday, September 09, 2008

Training, redux

After an epic amount of debugging, I have my logistic-function neural network working! Because I'm going to be using it to process a lot of large training sets, speed was a priority, so rather than using Python, I wrote it in C++ (a language with which I was marginally familiar...i.e., a lot of the 'debugging' time ended up being devoted to learning C++). Coding in C++ makes me realize just what a joy Python really is. If you're used to Python's wonderful lists, doing anything that involves passing arrays in C++ will feel like absolute hell. (Strict data-typing alone is at least a minor stint in purgatory...)

This algorithm is nice because it's scalable (can easily set the number of layers, and number of neurons per layer, to be any size). The listing is below; here the network is just learning an XOR logic. Since I built this from the ground up, it shouldn't be too hard to hook the program up to the genetic-circuit transfer function predictor I wrote this summer, and use it to optimize the predictor's input parameters for a particular target. I need to translate the predictor's Matlab script into C++, as well, and bundle that with my implementation of the Runge-Kutta ODE solver, which should be fairly straightforward.

/*********************************************************************
* neuralnet.cpp *
* Logistic function neural network (compile with Mersenne-Twister *
* random number generator: mtrand.cpp) *
* (c) Pericles v. 2.0, 9/9/2008 *
*********************************************************************/

#include <iostream>
#include <cmath>
#include <vector>
#include "mtrand.h"

using namespace std;

const int MAX_CYCLES = 100000;
const int NUMBER_OF_LAYERS = 3;
const int NEURONS_PER_LAYER = 4;
const double GOAL[4] = {0.0, 1.0, 1.0, 0.0};
double INPUT_LIST[4][2] = {{0.0, 0.0},
{1.0, 0.0},
{0.0, 1.0},
{1.0, 1.0}};

// Seed random number generator with system time
MTRand_open mt((unsigned)time(0));

class Neuron
{
private:
vector<vector<double> > input;
double * output, * grad, * weight;
double lRate;
int numInputs, numSets, layer;
public:
Neuron() { }
// Empty constructor: use initializer for neuron construction
void initialize(int L, int N, double R)
{
layer = L;
numInputs = N + 1;
numSets = 4;
lRate = R;
// Initialize a numSets x numInputs vector of zeros for input
vector<double> numPerSet(numInputs);
output = new double[numSets];
grad = new double[numSets];
for(int i = 0; i < numSets; i++)
{
output[i] = 0.0;
grad[i] = 0.0;
input.push_back(numPerSet);
// Insert static threshold (bias) of -1.0
input[i][numInputs - 1] = -1.0;
}
// Initialize weight to random values on (-1, 1)
weight = new double[numInputs];
cout << "++ Layer " << layer << " neuron: [ ";
for(int i = 0; i < numInputs; i++)
{
weight[i] = (2 * (mt() - 0.5));
cout << weight[i] << " ";
}
cout << "] ++\n";
}
void forward(int);
void updateDeltas(int);
void updateWeights(int);
double sigmoid(double x) { return 1.0 / (1.0 + exp(-x)); }
// Functions to access and return member data
int getNumInputs() { return numInputs; }
int getNumSets() { return numSets; }
double getOutput(int i) { return output[i]; }
double getGrad(int i) { return grad[i]; }
double getWeight(int i) { return weight[i]; }
};

///////////////// Network declaration and sizing /////////////////

vector<Neuron> layers(NUMBER_OF_LAYERS);
vector<vector<Neuron> > network(NEURONS_PER_LAYER + 1, layers);

//////////////////////////////////////////////////////////////////

void Neuron::forward(int inputSet)
{
switch(layer)
{
case 0:
{
double (* pTemp)[2];
pTemp = INPUT_LIST;
for(int i = 0; i < numInputs - 1; i++)
input[inputSet][i] = pTemp[inputSet][i];
break;
}
default:
{
// Use the previous layer's output as this layer's input
for(int i = 0; i < numInputs - 1; i++)
input[inputSet][i] = network[i][layer - 1].getOutput(inputSet);
break;
}
}
// Calculate the neuron's output from the weighted inputs
double product = 0.0;
for(int i = 0; i < numInputs; i++)
product += weight[i] * input[inputSet][i];
output[inputSet] = sigmoid(product);
}

void Neuron::updateDeltas(int inputSet)
{
double error;
switch(layer)
{
case NUMBER_OF_LAYERS - 1:
{
// Calculate how far off the output is from the goal, and
// adjust the hidden-to-output weights
error = GOAL[inputSet] - output[inputSet];
grad[inputSet] = error * output[inputSet] * (1 - output[inputSet]);
break;
}
default:
{
// Backpropagate the error and adjust the previous-to-current
// layer weights based on the gradients of the next layer
error = 0.0;
for(int i = 0; i < network[0][layer + 1].getNumInputs(); i++)
error += network[i][layer + 1].getWeight(i) * network[i][layer + 1].getGrad(inputSet);
grad[inputSet] = error * output[inputSet] * (1 - output[inputSet]);
break;
}
}
}

void Neuron::updateWeights(int inputSet)
{
for(int i = 0; i < numInputs; i++)
weight[i] += lRate * grad[inputSet] * input[inputSet][i];
}

bool complete()
{
// Check if the network output is sufficiently close to the goal
for(int i = 0; i < 4; i++)
{
if(fabs(GOAL[i] - network[0][NUMBER_OF_LAYERS - 1].getOutput(i)) > 0.01)
return false;
}
return true;
}

int main()
{
bool result = false;
// Initialize the network
for(int i = 0; i < NUMBER_OF_LAYERS; i++)
{
for(int j = 0; j <= NEURONS_PER_LAYER; j++)
network[j][i].initialize(i, NEURONS_PER_LAYER, 0.25);
}
cout << "\n";
// Train the network
cout << "Goal: [ ";
for(int j = 0; j < 4; j++)
cout << GOAL[j] << " ";
cout << "]\nLayer " << NUMBER_OF_LAYERS - 1 << " output:\n";
for(int i = 0; i < MAX_CYCLES; i++)
{
// Forward pass: layer 0 -> (NUMBER_OF_LAYERS - 1)
for(int j = 0; j < 4; j++)
{
for(int l = 0; l < NUMBER_OF_LAYERS; l++)
{
for(int m = 0; m <= NEURONS_PER_LAYER; m++)
network[m][l].forward(j);
}
}
// Reverse pass: layer (NUMBER_OF_LAYERS - 1) -> 0
for(int j = 0; j < 4; j++)
{
for(int l = NUMBER_OF_LAYERS - 1; l >= 0; l--)
{
for(int m = NEURONS_PER_LAYER; m >= 0; m--)
network[m][l].updateDeltas(j);
}
}
for(int j = 0; j < 4; j++)
{
for(int l = NUMBER_OF_LAYERS - 1; l >= 0; l--)
{
for(int m = NEURONS_PER_LAYER; m >= 0; m--)
network[m][l].updateWeights(j);
}
}
// Display the network's output, and check if it is complete
cout << "[ ";
for(int j = 0; j < 4; j++)
cout << network[0][NUMBER_OF_LAYERS - 1].getOutput(j) << " ";
result = complete();
cout << "]\n";
if(result)
{
cout << "\n**** Training successful after " << i << " cycles! ****\n";
i = MAX_CYCLES;
}
}
if(!result)
cout << "\n**** Training failed. ****\n";
cout << "Goal: [ ";
for(int j = 0; j < 4; j++)
cout << GOAL[j] << " ";
cout << "]\n";
cout << "Final network weights:\n";
for(int j = 0; j < NUMBER_OF_LAYERS; j++)
{
for(int k = 0; k < NEURONS_PER_LAYER; k++)
{
cout << "Layer " << j << ": [ ";
for(int l = 0; l < network[k][j].getNumInputs(); l++)
cout << network[k][j].getWeight(l) << " ";
cout << "]\n";
}
}
cout << "\n";
return 0;
}

Sunday, September 07, 2008

So all these roads go to Damascus...

Having done a little digging, I have mixed feelings about Sarah Palin. To the extent she's got a libertarian streak, I like and respect her. She's a bit of a rebel, which I also respect, particularly from the bunch of hooligans that dominate the Republican party in Alaska. But the Christian dominionist stuff really, really turns me off, particularly the wildly irresponsible talk about the Iraq war being a mission from God:

http://www.youtube.com/watch?v=QG1vPYbRB7k
http://www.youtube.com/watch?v=k84m2orSOaM
http://www.politico.com/news/stories/0908/13098.html

Get your heart right with God, guys, or we'll never get that pipeline up! You know, John McCain used to be famous for speaking out against this stuff. It's cringe-inducing, watching a guy I used to admire (I would have probably voted for him in 2000, in fact) abandon his principles for power. In McCain's defense, I doubt he knew about this prior to selecting her. Although that's not much of a defense, when you consider what it implies about his decision-making process.

Political considerations aside, how does this stack up against my reservations about the Obama/Biden ticket's collectivist-minded economic policies? Obama's stated support for a Windfall Profits Tax on the oil industry reeks of collectivism, but it's gimmicky and probably just a lame pander when you get right down to it; things like his support for the Fair Pay Act of 2007 are much more ominous, in my opinion. It's hard to say whether this is more or less alarming than a candidate who believes she's on a mission from God. It's all enough to make me seriously think about voting for Bob Barr, to be perfectly honest. I'm not sure how sincere his little road-to-Damascus moment regarding the Drug War was, either, but you'd have to be a damn fool to sell your soul for the LP nomination, so him I'll give the benefit of the doubt. But John McCain's at the top of the ticket, not Sarah Palin, so I'll probably be voting for Obama this year. (Although, since I live in California, it matters very little who I vote for in any case.)

Friday, August 29, 2008

He's mad as hell and he's not gonna take it any more!

Watching John Kerry's speech at the DNC, I've got to ask, Where the hell was this guy in 2004?

His bit about Senator McCain versus Candidate McCain was spot-on. I've got to add to that, if Candidate Kerry had had even 1/10th the fire that Senator Kerry is currently showing, he would have crushed the hell out of George Bush four years ago. What is it with Democratic ex-Presidential candidates? Al Gore suddenly transformed into a fiery, passionate, excellent candidate as well...after the election was over. Bill Clinton had a really solid speech, too. (One thing about the giant clusterfuck of the past 8 years is how much it drives home the point that Bill Clinton was a pretty fucking good President. Watching him speak, I've got to wonder, if it wasn't for the 22nd amendment, would this guy still be in office today?)

Anyway, the point is: don't blow it this year, Mr. Obama.

On a somewhat related note, although she seems like a wildly inappropriate Vice Presidential pick, I kind of like Sarah Palin. From the tiny bit I know about her, I understand she's of the way-out-west live-and-let-live school of Republicanism, which sounds appealing. She's supposed to be sort of a rebel. (Although who knows what that means, given that her party seems to be literally run by a group of corrupt, psychotic, belligerent, secretive, warmongering plutocrats.) She voted against the infamous Bridge To Nowhere, and much respect to her for that. I'm going to look into her a bit...what she believes is crucial, since McCain's older than dirt and let's face it, being tortured for years has to make him effectively even older than that. I wonder how well McCain even knows what she believes. Evidently he met her once (!) prior to picking her for his VP.

Tuesday, August 19, 2008

Bit the bullet

Finally made a choice. It was a tough call, but in the end, I decided on the synthetic biology lab. I've heard that the PI here can be a jerk, but he's been pretty cool so far. Fingers crossed that things don't get worse now that I'm here for good...

Also, how the heck do you tell people that you changed your last name? I didn't think about this aspect of it, when I decided to change it. The couple people I've mentioned it to reacted very strangely to it. Not sure why anyone besides my family would care (pretty sure I wouldn't care if someone I knew had their last name changed...). One woman, who I barely know, told me that she thinks I'm a sellout, and just trying to fit in. What a bunch of crap! Not only is that not at all my motivation, if you think about it, changing your name is a really unusual thing to do. The last thing you'd want to do if you just wanted to 'fit in' is change your name.

It's also sort of irritating having to update all my records and stuff. You forget how much crap has your name on it, until you have to go through and change it on everything...

Tuesday, August 05, 2008

Welcome to Nowhere



It was flat, and bone-dry. I rode across the endless, featureless plain, Drifter leaving a long, straight gash in the surface of the cracked sand. I was doing about sixty, but it could've been any speed; didn't seem to matter. There were mountains far behind and mountains far ahead, but all around me was wind-scorched sand. There were small rough patches, and once a salt crust, but otherwise there was nothing.

The sun was falling behind the Calico Mountains to the west when I killed the motorcycle's engine and dismounted, pulled off my helmet. A steady wind whistled across the Black Rock Playa, a thousand square miles of desert lakebed. The wind was warm, but cooling as twilight settled in. I laid out a tarp and a sleeping bag, drinking a beer as I watched the last light fade from the playa. One nice thing about a thousand square miles of nothing is that you don't have to think too hard about where you want to camp; one barren patch of sand is pretty much as good as another.

I stayed awake for a long while, watching the stars come out. Out here in the desert the night sky is endless, layers and layers of stars; the bright ones you can make out even through the haze of light in the city, and the dimmer ones that you can't, and out here there was more and more and more, even past those. I live and work in San Francisco, blanketed in lights and fog. There's a lot to love about the city, but you can't see the stars there.

The wind was sharper now, strong and cold, howling as it twisted through Drifter's metal frame. I lay silently in my sleeping bag. I felt very small, alone with the empty plain and the full black sky. The guy who'd told me about this place said you could find yourself out here. I thought about that, and my mind wandered across why I'd traveled west in the first place. I guess I'd come for the same reason restless, maybe a little bit reckless young men had been coming west for hundreds of years: seeking fortune and a challenge, probably in truth looking for adventure more than anything else. I think some of it was just simple pride; people always told me how stupid I was growing up, and I guess part of me figured there's no better way to prove those assholes wrong then to go to one of the best schools in the world in a difficult, technical subject most people've never even heard of.

When I really reflect on it, though, that isn't most of it. Mostly, I'd come because I really believed I could create something amazing if I did. It's a deep-down belief, kept down where I think quietly, genuinely spiritual people hold their faith tight, rolled up hard so you don't talk about it, and all the cynicism of the world can't touch it. I'm a cynic myself, about most things. I guess I'm sort of a professional skeptic; scientific training's like that. But I'd traveled west because I believed I could build a fountain of youth, that would make all other things possible. Because if you're determined enough, all you really need is time, right?



It was still bitter cold when dawn broke. I roused slowly, ate a couple pop tarts and drank some water as I packed away my tarp and bag, tying everything onto the cycle with a motley assortment of bungee cords. I put on my dirt-streaked boots and gloves, an extra shirt and a scarf, then strapped on my helmet and roared off towards the sun.

Thirty miles later, I pulled the cycle down into a lower gear and drifted across the sand. I was way the hell out in this thousand-mile wasteland. The clerk back in the tiny desert town of Empire had warned me that cell phones didn't work out on the playa; I'd done my research about this place before coming, and I knew that already. I'd also read about how common it was for people to get stuck in a patch of wet sand, or boiled alive in the hot springs dotting the playa, run out of gas or puncture their radiator or just plain get lost, out here on the endless empty flat. I told a few people that I was coming out here, and I got this sort of, "You nuts?" reaction from them. From those that know me well enough to know that I am a little nuts, instead I got a little bit of resigned, hope-you-don't-die-out-there worry. What people never seem to get, though, is that it's precisely the risk that makes this worthwhile, but you've got to distinguish between stupid risk and necessary risk. I'm careful as I can be with Drifter, maintaining as well as I can and checking fluid levels every time I mount up. I don't race on the freeways or try and pull stupid stunts in the dirt. I carry spare plugs, a patch kit, a tool set, a multimeter, quick-set epoxy, a tire gauge and foot pump, and all the rest that you're supposed to haul around with you. I get rid of the stupid risk as much as I can, but the necessary risk of riding a motorcycle alone into the blank remains. And I think a lot of the reason a journey like this can mean something is because of this risk. I've got everything at stake; there's no safety net. Here, it's just me and my motorcycle and the wasteland.

The sand gets deeper as I drift closer to the eastern edge of the playa, and the thumping growl of Drifter's big single cylinder shifts into a sharp whine as I open up the throttle in low gear. Traction's still good, but the sand dune is just too damn deep, and Drifter's too heavy and there's too much pressure in her tires for real dune riding. I'm switching between second and first gear, and then suddenly the cycle's stuck, and I'm halfway to toppling over. The rear wheel's lost traction, buried a good ten inches into the loose sand, and the front's looking shaky. Realizing there's a real chance of getting stranded out here in these dunes, I pull the transmission down into first and twist the throttle hard. Drifter drags herself through the sand trap by inches, the engine screaming, and then with a triumphant roar she's free, I'm free, and in second gear, then third, racing across the playa again, away from the dunes.



Across the old train tracks on the playa's east border, where the sandy barrens turn to arid scrubland, I park the cycle. The early morning air's lost some of its bite, but it's still chilly. There's a tall, lone hill to the side of the road, too steep and rocky for riding. By the time I've climbed to the top, I'm sweating through my scarf, and I stop at the summit to get my bearings, take a few pictures. Up here, the wasteland is beautiful, and you can see forever. There's a dirt track I can see, wandering out away from the playa, through the sagebrush and out to the horizon...



The track's hard-packed dirt and sand, with two ruts carved in it by four-wheelers, and I make great time at first. There's plenty of twists and bumps on the trail, but Drifter's got a solid grip on the hard-pack, and I hardly need to use my boots to guide her at all. I'm getting close to fifty miles out, now, and I start to think about heading back. I have a 50/50 rule for regular riding, when I know for sure where I'm going and where the roads lead, and a thirds rule for when I'm exploring like this: third of my gas going out, a third coming back, and a third for getting lost. It's worked well so far. Drifter's got more than a 150-mile range in ideal conditions, but sand riding drains gas quickly. The trail below me's going a bit soft, and I'm finding I've got to fight to keep the cycle level. The front wheel jerks alarmingly from side to side as the traction gets weaker in the looser sand, and I pull up through the sagebrush to keep from falling. There's a long green patch maybe five miles ahead that I'd really like to check out, so I keep pushing forward, but eventually I realize that the sand's just too loose and I'm making no progress, and in danger of laying the bike down. I turned around, and had barely started back, when I hit a particularly soft patch of the trail, and jerked my handlebars helplessly as I lost all traction. Drifter toppled over gracelessly, planting me on my side. I lay stunned in the sand for a moment, listening to the engine putter to a halt, then quit. I felt a hard pressure on my left ankle, wedged between the cycle's frame and the ground. After a couple false starts, I yanked my leg free of the bike, and wrestled her back upright. I caught my breath for a moment, took a long drink of water, then hit the ignition.

Nothing happened.

I grit my teeth, setting Drifter on her side stand. I stared down the empty dirt track, breathing hard, swallowing. The starter had lit up just fine, but the engine hadn't caught. I remembered this sort of bullshit all too well from my days of struggling with the old Nighthawk's electrical system. I gave the frame a cursory examination; no obvious damage. The sand was soft, after all: that's what had caused the problem in the first place. Cursing, I hit the ignition again, and experienced a flood of elation when she sputtered to life. I twisted the throttle, giddy with relief, and had only gone about five miles down the road when I hit another super-soft sand drift and promptly ate shit again. This time the cycle slammed down onto my right ankle, and I hastily scrambled to my feet before the engine could cut out again, pulled her upright, and roared down the dirt road, back towards the playa.

Forty-something miles later found me back on the paved county road. I rode slowly into Gerlach and parked outside the local diner/motel/saloon, Bruno's. I walked in, and felt everyone in the place staring at me. I guess I probably looked a little strange. My leather jacket, boots, and jeans were crusted with pale dirt and sand, and I was sticky with sweat and dried sweat, hair all matted and spiked from the helmet. Every wrinkle in my hands was filled with the pale sand or dark grease from my cycle's engine. My heavy riding boots clunked loudly as I tried not to stare back, and walked calmly to a seat at the bar. I held back a laugh when I saw it was only 10:30 in the morning; no wonder these people were looking at me so odd. I had orange juice and eggs.



Afterward, I talked to a couple of younger folks outside, a couple from Indiana who were helping get Black Rock City set up for the annual Burning Man festival held out on the playa. The guy shook his head at me when I told him I'd been camping and dirt biking out on the playa. "You should ride with someone else, man," he said. "This place, this weather's just crazy...you could really get in trouble out there in the desert by yourself."

"Lay off, Kevin," the woman, Nicole, told him, laughing. "I think this guy knows what he's doing."

Kevin shrugged. "Yeah, I'm a safety Nazi, I guess."

I grinned at him. "No worries. You're right; I ought to ride with a buddy. Thanks for looking out."

They invited me to a picnic the Burning Man people were holding by the water tower. I thanked them, and said if I was still in town at 5, I'd be glad to come. "I may have to head back to San Francisco before then, though," I added. "Bit of a ride."

"Yeah," Kevin agreed. I shook hands with them both, and we said a few more pleasantries, I think all aware that we weren't going to be seeing each other again.

After fueling up and draining out a bit of excess oil from the engine, I headed back out. This time I kept riding up the county road, out to where it heads off into the hills and Soldier Meadows Road branches off from it, stays right along the playa's edge. The road was dirt and gravel, but fast. I wasn't sure where I was going, exactly, but I figured I'd just keep following this road until I found something interesting or started getting worried about gas. As it turned out, I found something interesting right as I started getting worried about gas: there was a sign on the side of the road for Wagner Springs. I hadn't gotten any good pictures of a hot spring yet, so I figured I'd check this one out. A short while later, I heard the sound of a dog barking and pulled up to a barbed-wire fence. An old woman stood on the other side, giving me a look that was frank, but not hostile. I killed the motor to quiet the dog down, and dismounted.



"Hi," I greeted her, setting my helmet on the cycle's seat. I offered my hand. "I'm Jack."

She smiled back, shook my hand. She was old, but spry enough, with skin like old leather, and her eyes were bright. "I'm Josie."

Turns out she's a surveyor, and lives out here three months of the year. Her little trailer's in a patch of green supported by the several warm springs, and the artesian well, in the area. Most of the rest of this land's public BLM land, but she's on a patch of private property she rents from the Soldier Meadows Ranch. We sit in the shade and talk for a while. She's real sharp, though her hearing's a bit bad, and she whistles when she talks. She talks about the land and the ranchers, the hunters and the Burning Man people and the environmentalists, for whom she reserves a special brand of scorn. Apparently the BLM's closed off a lot of the land she used to love to travel on, turned it into a conservation area.

She sighs. "What good is that? I can't walk that far. They've shut out everyone but the young and healthy."

I hadn't thought about it that way. She goes on about the environmentalists, and thinks its insane that the gray wolf has been reintroduced to the West. "Hunters spent hundreds of years killing off the wolves, and they've gone and reimported them from Mexico," she grumbles, shaking her head. "Where's the sense in that?"

I've got no answer for her. I don't know much about it; I suppose it's got something to do with the health of the ecosystems, but I don't really know.



After a while, I fill up my water supplies with the clean artesian water she's got around back of her trailer, and I'm off again, back down to Soldier Meadows Road, then highway 34, then all the way back through the Sierra Nevada to San Francisco. I arrive around midnight, and stumble up the stairs to my apartment, exhausted. My roommate Kyle's still up.

"Figured you were dead," he comments.

"No," I say, too tired for wit. "No, I made it."

Monday, July 28, 2008

Drifting to Idria



A stone's throw from the abandoned mining town of Idria, the baking, cracked asphalt of the narrow country road abruptly gave way to rocks and hard-packed, deeply rutted clay. I downshifted through my motorcycle's gears and stood up on the pegs, letting the bike's long shocks ride out the roughness. I veered around a half-fallen tree that blocked most of what remained of New Idria Road, riding at a slow clip into the shade of the old trees interspersed with the empty buildings. The Harley guys back at the Panoche Bar said Idria was deserted, and maybe it was, but the hostility of its former residents remained. "Fuck the Sierra Club!" one hand-made sign declared. The run-down country houses and barns were decorated with unreasonably hostile "KEEP THE FUCK OUT" signs.

Nice place, I thought, pulling up to a large sign at the end of town that informed me that the road past the cattle barn had undergone an emergency closure as of May 2008. I wasn't sure exactly what was closed, since I hadn't seen a cattle barn (and wasn't sure I'd recognize one if I had), so I figured I'd just keep going until I saw something more explicit. I found that halfway up the ridge, where a metal gate completely blocked the road, adorned with one of those lovely KEEP OUT NO TRESPASSING THIS IS PRIVATE PROPERTY signs that seemed to be Idria's primary output. Looked like the road to Clear Creek was gone for good.

I turned my bike around, disappointed, and picked my way back down the ridge. I stopped at the bottom. There was a crossroads there, if you can even call it that -- branching off of Clear Creek Road, a narrow rocky track climbed steeply into the mountains. I wasn't sure whether the road closure applied to this switchback as well, but there was no gate blocking the way, and anyway, I figured, who the hell was going to stop me?

The trail got narrower and steeper as I ascended. My motorcycle's a DR650 -- it's not a dirt bike, but it's pretty much as close as you can get to a dirt bike while remaining reasonably street-worthy. The suspension handled the ruts and rocks with aplomb, but the stock Trailwing tires weren't quite everything I dreamed they would be. The relatively smooth tires, combined with the bike's weight (heavy only in comparison to a dirt bike, but still heavy) gave me a disconcerting drift on the loose rocks and gravel that made up the track. I happily thundered along the top of a high ridge, enjoying the view of a mountain lake at the bottom of the sixty- or seventy-foot cliff to my left. Two rough-looking men were standing by the lakeside, fishing; I couldn't say whether the looks they gave me were hostile or just curious. I eventually made my way down to a crossroads, which featured a sign declaring the entire area closed, and told me that if I was caught there, I faced a $1000 fine or 12 months in prison.

Faced with a little more than half a tank of gas and the pugnacious sign, I turned around and rode back down the ridge. The loose rocky trail was considerably less fun on the way back down, as the amount of sliding, combined with my bike's unfortunate propensity to drift, made my brakes essentially useless. I pulled the engine down into first gear and held on tight, weaving my way through the loose rocks and the deep ruts. Sliding through the gravel and coming at an awkward angle on a particularly unforgiving series of ruts, the bike jerked suddenly to one side. I jammed my right boot onto the ground, pulling the bike level again just in time to crash through a low bush on the side of the track. One of its branches stuck into my bike's frame. The trail was clear but steeper now, and veered sharply to the left, switchbacking around a rocky outcrop, and I barreled down the side of the mountain, branch in tow. The engine braking wasn't quite cutting it, and, realizing I wasn't going to be able to make the turn, I squeezed the brakes, hard, spinning out into a 90-degree turn as I skidded to a halt on the edge of the track. I glanced at the cliff to my right, breathing hard.

Well, that wasn't so bad, I reassured myself, removing the various pieces of plant life lodged in my bike. Had a solid yard-and-a-half to spare!

The ride back to Panoche Pass was hot and fast. After a while, I sputtered the motorcycle to a halt. The dusty road baked in the dry, blazing sun, and the still air shimmered around the engine. I dismounted and released the strap on my helmet, peering into the barren scrubland through my dust-streaked glasses. It was silent. I drank half a liter of water, then mounted back up. I guess my bike had a name now: Drifter.



It was late afternoon by the time I reached the twisties north of Pinnacles. I turned off onto Old Gloria, a rough dirt road that wound through the mountains and down to highway 101, south of Salinas. Drifter lived up to its name, and I used my boots to manage even the slightest twists in the road. After a while of meandering through sun-dappled ranchlands, Old Gloria crested a hill and I found myself looking out over a valley. The sun was setting over the high hills to my right, and the dirt road dropped sharply off to my left, winding its way down to the valley floor. Straight ahead, there was a layer of low clouds, blanketing the green valley, and the mountains bordering the valley to the west soared above the cloud layer. It was breathtaking. It was breathtaking enough, in fact, that I'd say it more than made up for the freezing-cold-for-no-good-reason-and-why-the-hell-is-it-raining-this-time-of-year-anyway ride back to San Francisco.

Friday, July 04, 2008

My own two wheels



I bought a 2003 Suzuki DR650, in near-pristine condition, as far as I can tell, with a little over 2000 miles on it. It's got the bigger fuel tank and a nice Corbin seat, and a supertrapp exhaust that gives it a throaty roar. It's not smooth and fast like a sport bike, but it's light, agile, and torquey. It's tall but not too tall - I'm 5'10" and it fits me perfect. One of this bike's selling points is that it's a 50/50 on/off road bike, and it definitely feels dirt-capable to me. I'm looking forward to taking it east over the mountains sometime for some real breaking-in!

I'm happy I bought it. I'm damn near broke now, but you know, even given the expense and the inherent risk involved in it, I guess riding's one of those things you can almost forget how much you love until you're in the saddle again. It's my own two wheels that make me free in a way that a car's metal shell never will - I don't know if there's anything worth more than that, to me, except maybe the chance to fly. And once I sell my Civic, I should be comfortably in the black again, with enough to spare to finish my pilot's license!

Sunday, June 29, 2008

Into summer

I moved into a new apartment, with my old roommate Bob and his best friend Kyle. It seems like a good setup so far. It's a really nice place in the Richmond district - all hardwood floors, a fireplace, lots of space, half a block from Golden Gate Park and a little over a mile from the ocean. I've been running outside again, on trails! I'd forgotten how much I miss that. We got a good deal on the place, too. (God bless rent control...)

I took a week off (which was not really relaxing at all, due to the move and to several other factors), and picked my summer lab rotation: I'll be working in a synthetic biology lab that does work on 4th-generation biofuel production. The PI outlined my project description with me on Thursday. I had explained to him that I had a background in physics, and that was where my real technical interests lay, so he proposed I work on building a dynamic model connecting the current guess-and-check transfer functions of the quorum-sensing bacterial NOR logic gates with the statistical physics-based RBS (ribosome binding site) calculator. Both the logic gates and the RBS calculator are already developed; my job is to connect the two with a kinetic mathematical model. I'm doing some reading on signal processing at the moment, trying to come up with a general strategy. I'm excited about this, though; this is the sort of work I consider myself good at, so I'm hopeful that I can create something genuinely useful here. The big picture of this is that if I can assemble a good kinetic framework for transfer function prediction that goes back to the statistical mechanics of ribosome-DNA binding, this will allow more efficient, logical genetic circuit design, which will help streamline the biofuel production work.

I've decided to sell my car and buy a motorcycle. (Right now I am negotiating with a guy down in the south bay for an almost-new Suzuki DR650, which is pretty much my ideal on-road/off-road bike.) I miss my old Nighthawk S from college, and owning a car in San Francisco just isn't practical. Plus, with gas prices the way they are, I think I can get a good deal for my Civic. With any luck, I should have a significant chunk of money left over, too, which, along with my savings, should give me enough to complete my private pilot's license and still have some money set aside for a rainy day. I looked into pilot training, and as far as I can tell, it looks like it'll either my San Mateo or (more likely) San Carlos airport. I'm really looking forward to starting. Feels like I've been saving up for this forever, and I'm excited about finally getting to work on it!

Thursday, June 12, 2008

Training

I'm attempting to teach myself some Python. As a (particularly useless) exercise, I thought I'd try to write a perceptron neural net. I think I've got it working! As far as I can tell this program works for any linearly separable goal. I'm sort of proud of it, so I thought I'd post the listing here:
# perceptron.py: single-neuron perceptron neural network
# (c) Pericles v. 2.0, 6/12/2008

import sys
import random

input = [[0, 0], [0, 1], [1, 0], [1, 1]]
# randomize on (0, 1] both state vector elements
state = [random.random(), random.random()]
# randomize on (0, 1] bias value
bias = random.random()
# initial output list
output = [0, 0, 0, 0]
# desired output list: simple OR (this program can learn any
# linearly separable set)
goal = [0, 1, 1, 1]

# hard limit evaluation function: if dot product of the state and input
# vectors is greater than or equal to the bias, then neuron fires
def eval(row, col, bias):
product = 0
for i in range(len(row)):
product += row[i] * col[i]
if product >= bias:
fire = 1
else:
fire = 0
return fire

# transition function: compare the binary values of the current output
# element to the goal element, and adjust the state vector if different
def transition(state, input, output, goal, bias):
b = bias
s = state
# for every output element that is not equal to its corresponding goal
# element, adjust the state vector and the bias
if output != goal:
for i in range(len(s)):
s[i] += (goal - output) * input[i]
b -= goal - output
return s, b

# main
print "Simple OR:", goal
print "----------------------------"
print "Output State Bias"
print "----------------------------"
for j in range(100):
# iterate the 4 input vectors through the evaluation function
for i in range(len(input)):
output[i] = eval(state, input[i], bias)
# if the output vector has reached the goal vector, then quit
if output == goal:
print output, " ", state, " ", bias
print "Training complete!"
sys.exit()
# iterate the output values through the transition function, and
# retrieve the adjusted values for the state vector and the bias
for i in range(len(output)):
state, bias = transition(state, input[i], output[i], goal[i], bias)
print output, " ", state, " ", bias

Tuesday, June 10, 2008

Epoch

Spring quarter has drawn to a close: my rotation ends this Friday, and my classes are done. I have a take-home final to complete, and then my first year in graduate school has concluded.

I think I will do a 4th rotation this summer, in a lab that does work related to biofuels. I've always been interested in the aging process, but I think so long as there is an important big picture behind my work, I will be satisfied with my research. Aging is certainly a relevant and important problem, but so is the energy problem, after all.

I'm planning on taking a couple of weeks of downtime before I start, however, to rest, and to teach myself a few things that have come up over and over again this year that I have little to no background in. First up: statistics! I'm armed with a fairly rigorous mathematical statistics/data analysis book, and I'm going to bull through this thing before I take another step scientifically. I'm also hip-deep into learning Python, the other thing I'm dead set on becoming competent with before I jump into my next (and possibly final?) lab.

Also, I've made up my mind about the whole last name thing -- I think I'm really going to do it! I talked to my folks about it, and everybody was super cool with it, surprisingly. Dad said that he liked having a unique last name, but the whole unpronounceable-ness aspect of it kinda bugged him, too. Anyway, I decided that Peterson would be a pretty good choice. I like the sound of it, and it's easy to pronounce. Dad liked it, too. You know, I've never liked the naming convention in our culture, because our names don't mean anything. If you think about common names like Smith or Carpenter or whatever, people took on those names because they were descriptive -- they actually were blacksmiths and carpenters. So the name Peterson appeals to me on this level, because it's at least descriptive -- I'm Peter's son. It's not Greek, but I figure, I'm a quarter Greek, and a quarter mixed northern European, so I don't feel like I'm misrepresenting my ancestry. The only downside is that it is sort of common, which isn't the greatest thing, I guess, but then, I figure, if my uniqueness as a person is tied to having a super hard to pronounce last name, I probably fail at life anyway!

Sunday, May 25, 2008

Regarding my lack of common sense...

I'm considering rotating into a lab that mostly does mathematical modeling of complex systems this summer. This is not exactly the direction I would have predicted my graduate research would take, but as I consider my options more and more, the appeal of this option grows.

Bioinformatics/data analysis is not really my thing. Experiments are fine, but ultimately, I believe, would be a poor use of the math/physics skillset I went to such great lengths to acquire, and have painstakingly developed over the past four years. As the youngest member of my current lab, a half-Korean 14-year-old mathematics prodigy, dryly observed, "A monkey could do this work."

I suppose that's not too far off.

I was not a mathematics prodigy at 14 (in fact, my math teachers probably considered me to be a bit of a moron), and didn't become interested in the subject at all, really, until I studied calculus in college. Higher math, oddly, comes naturally to me, in a way that the elementary math never did. (To this day, I'm still remarkably bad at arithmetic.) I hesitate to make this claim, but I've noticed that the 'harder' the math gets, the cleaner and more simple everything seems to me. I've thought about this a lot recently, and I think this odd result may stem from my notable lack of intuition. I was a poor student when I was young, and I remember I really struggled with very basic things, like percentages and decimals. I was horrendous at solving word problems. I've concluded that the reason I was so stupid is that I lacked intuition: elementary mathematics is very common-sense. The converse of this seems to be that the more abstract things become, the easier they are for me to grasp.

I think, for most subjects, this would be a fairly useless characteristic. Certainly, biology is fraught with phenomenology and reams of facts with only the barest theoretical framework holding them together, and it is for this reason, I think, that I'm an indifferent biology student, at best. Just how poorly I do in this sort of common-sense realm was not always apparent to me; I'm a hard worker, and that's often enough to overcome a deficit in learning ability. It propelled me through a degree in genetics, after all, with decent grades at the end of it. UCSF, though, is a far cry from a middling state school like UGA, and I took a pure biology course this quarter, with students from the biology program here, who naturally have an extremely strong aptitude for this sort of thing. This really drove home for me that this is not one of my strengths.

I've been wondering, if maybe I should have opted to study theoretical physics or even pure mathematics, rather than an interdisciplinary subject like biophysics. Certainly, I'm coming to realize I have a stronger aptitude for those subjects. But I think there must be ways to make use of my skillset, even within the field I've chosen. I think mathematical modeling may be one of them.

Tuesday, May 20, 2008

Fun with last names!

Here's a random topic: I'm thinking of having my last name changed. This is something I've actually been planning to do for a long time, but I always figured it would be a huge hassle and/or huge expense, so I never did. But, it turns out that, in California, at least, it's really straightforward to have your name changed: you just fill out a couple forms, bring them to the courthouse, then come back when they tell you to, and the judge changes your name, just like that. Apparently there's a 'court petitioning fee,' but all you have to do is declare yourself to be poor (yeah, there's a form for that, too), and they waive it more-or-less automatically. Also, my first scientific paper is going to be published soon, so I guess it's pretty much now or never!

I remember when I was a kid, my dad was sort of into genealogy, and he'd go on Biblical-style about our ancestors ("George, son of Peter, son of George, son of whoever, etc. etc."). It was kind of funny, actually. Dad's dad's ancestors were all evidently Greek peasants, and mom's descended mostly from Chinese soldiers (well, Taiwanese, now, since her family was exiled to Taiwan because they fought against the Communists in the civil war...). But get this: on my dad's mom's side, it turns out I'm the direct descendant of Sir Francis Drake! And I'm John Adams' great-great-great-great grandnephew or something. Grandma's a big mix of northern European blood -- German, Scots-Irish, English, some Norwegian and Swiss. I remember dad saying if we followed the old Norse naming convention, my last name would be Peterson (as in, 'Peter's son'). I thought that would be sort of a cool way to change my last name to something pronounceable, while still respecting my dad and our ancestry and all that, because it's not like I'm not proud of where we came from... Or, maybe I could change it to something shorter, but still Greek. Being (one quarter) Greek rules; I'm just not crazy about the mile-long, non-phonetic surname that comes with it. My last name doesn't shorten in any real obvious way, though. Maybe I'll ask James what he thinks...

On an unrelated note, if there's a prize for 'most tedious and uninteresting subject' out there, I'd like to award it to developmental biology. My god how I hate this class.

Wednesday, May 07, 2008

Round and round I go...

I've concluded two things from my rotations: first, that I'm honestly not sure I like any one aspect of research (computation, theory, experiment) so well that I want to do just that, and second, that I don't want to do my PhD in any of these labs. They've all had their upsides, but in every case, the downsides of the lab far outweighs what I liked about it. In my first rotation,I realized that computational data analysis is really, really tedious, and also, that I was not too good at it. I did what I was asked to do, after considerable effort, but it was not something that came to me naturally. This was a disappointment, since I enjoy working with computers in general, and I liked my advisor a great deal.

My second rotation placed me with an advisor who was rarely around, and who gave me an entirely theoretical project that I worked on in isolation for the quarter. I enjoyed the work. I love mathematics, and learning the new math this work required was something I really liked. It's crossed my mind more than once that maybe I should've gone to graduate school for math instead of science. I was decent at physics, but I was much better at the purely mathematical aspect of physics than I was at transforming the physical problem into the math to begin with. And for this rotation, I taught myself abstract algebra, and then solved my problem. After consistently struggling to piece together the biophysics techniques, chemistry, and miscellaneous biological facts from my classes, it was striking to me to remember how clean and simple pure mathematics is. But I can't imagine joining that lab, particularly since the PI is apparently about to move to a different school (something I didn't know prior to agreeing to the rotation), and I had such little interaction with him I have no sense of what the lab is like.

My third and current rotation has me doing experiments again. It's alright. Working at the bench can be tedious, but you get to work with your hands, and its rewarding to know that you're generating your own data. People in this lab, however, are almost uniformly miserable and all caution me against joining for a variety of reasons. The uniformity of their bitterness (with one notable exception) gives me pause. And I think that, if I did join a purely experimental lab, I would be shelving my physics and mathematics background, probably for good. There's not room for that sort of approach in a pure biology lab, as I've slowly come to realize.

So, I'm not sure where this places me. I've decided to definitely do a summer rotation, but I don't think I can choose to do a 5th. It's really important that I choose the right lab for my next rotation. I don't know what I'll do if I don't like my summer rotation. I feel more and more certain that I could not work for the next five years in any of the labs I've been in so far. I suppose, if it comes down to it, I can always leave graduate school... Hopefully, it will not come to that. And it would seem a terrible waste, after all the work I've put into it so far.

Saturday, May 03, 2008

Mind blank

I've got a bad habit of rationalizing things, and passing them off as real reasons. It's intention drift, or at least a reasonable approximation of it. The truth of the matter is that I set out not knowing what the hell I'm doing, and still don't. My reasons for coming here in the first place were an odd, muddied mixture of vindication, vanity, and an intense desire to understand our universal affliction: why we age. It was a powerful elixir, and still is. I suppose it propelled me through my first two insane quarters here, where I learned the vast difference between an education at a middling southern public school and here, at one of the top graduate programs in the world. The transition was painful, but I believe I've learned more in the past six months than I did in the six years before that, and now that I am in high gear and keeping pace, I find the intensity exhilarating. Things click. My research is interesting, but it is brick-by-brick, a slow crawl towards incremental progress, a small bit of data in support of a supporting idea; but I am absorbing new mathematics and physics at an accelerating rate. After my work with the pipettes and the microscopes, I remain, late into the night, learning. I am staring into the chaos, and on the edge of something wonderful.

Tuesday, March 18, 2008

Winter quarter

...is over. I passed my Macro oral exam. Very, very relieved.

Tuesday, February 12, 2008

To-do

The compressed version of my to-do list, which I'm writing down here in an attempt to keep my head above water.
  • BMI lab report due 2/15
  • Read the Sali paper, make presentation with Charlie (due 2/21)
  • Macro proposal draft due 2/22 (GET FEEDBACK)
  • BMI group presentation on 2/28
  • Macro final proposal due Fri. 3/14
  • Macro oral exams 3/17-3/21
  • Rotation (background): canonical matrices, invariant factors, Markov chains
  • Rotation (project): infinite matrices
It's manageable. The BBC presentation and Macro proposals combined are what make winter quarter so insane, and I was fortunate enough to get my BBC talk out of the way early on. Just need to really get cracking on background reading for my proposal, and get it out for feedback ASAP.

Saturday, January 05, 2008

2008!

Resolutions for the new year:
  • Don't stress. I'm going to do my research and classwork to the best of my ability, but I will not worry (excessively) about it.
  • Stop complaining (so much). UCSF is a lot of work. Of course it's a lot of work, it's one of the best schools in the world. Stop bellyaching about it.
  • Don't gossip. I've never been too much of a gossip, but I've discovered a disturbing tendency this past quarter to talk shit about people, and I need to stop. Aside from being professionally counterproductive, it's just a dick thing to do. If I've got to vent about someone, I also resolve to vent to someone not associated with UCSF.
  • Stop feeling guilty about not working 24/7. I resolve to go out and have a beer with my friends when I feel like it, or play video games at night, or watch movies, or play the guitar, etc. etc. without thinking, 'man, I should be working.'
I guess those will do, for now.

Wednesday, December 05, 2007

To-do

First quarter of grad school is finally winding down! I was a pretty busy guy, even as an undergrad, but my workload then does not even begin to compare to the insanity of this past quarter. And supposedly winter quarter is even busier...

Things I still need to do, prior to the beginning of next quarter:

- Do Part 2 of the Macro final (due 12/10)
- Intra-species aging microarray analysis of linear regression slopes (due 12/17)
- Redo microarray analyses with sum-of-median absolute intensity cutoffs
- Continue reliability theory analysis
- Final rotation presentation on 1/7!
- Read through the Bechard manuscript, send feedback
- Learn basic Perl (which, I've been assured, will take me about 2 hours (!))
- Learn basic MySQL
- Start to learn ring theory for winter rotation
- Read the Marshall paper on centriole number

Monday, November 26, 2007

A new GPCR structure

The largest family of cell-surface receptors, the trimeric G-protein coupled receptors (GPCRs), are seven-pass transmembrane proteins that activate intracellular signaling pathways by switching conformations upon binding of an extracellular ligand. Although roughly half of all drugs function by affecting GPCRs, the only high-resolution GPCR crystal structure determined prior to this effort was that of rhodopsin. The primary problems in crystallizing GPCRs were thought to be the flexible, poorly-structured third intracellular loop (ICL3) and C-terminus. In this paper1, the authors were able to crystallize the human β2-adrenergic receptor (β 2AR) by both truncating the C-terminus and removing ICL3, replacing it with T4 lysozyme (T4L), a small, well-structured protein that creates a polar surface similar to ICL3. This paper is important, in my view, because the protein engineering techniques used to crystallize this receptor could likely be used for other GPCRs, allowing expanded use of structure-based drug discovery for this family of proteins.

The first question the authors address is whether the engineered β 2AR (β 2AR-T4L) variant is similar enough to wild type β 2AR (WT β 2AR) for their structure to be meaningful. β 2AR-T4L has a two- to three-fold higher binding affinity for agonists and a partial agonist, and it appears to retain its capacity to switch conformations in response to ligand binding, based on the similarity of agonist-induced changes in fluorescence intensity of the fluorophore monobromobimane. They conclude that, due to the similarities of these properties to those known of GPCR constitutively active mutants, the fusion of T4L results in a constitutively active β 2AR phenotype. The overall structures of both unliganded β 2AR-T4L and β 2AR-T4L bound with the inverse agonist carazolol are also similar to the previously crystallized β 2AR-Fab complex. Replacement of ICL3 with T4L allowed the authors to crystallize β 2AR; however, ICL3 is important for both G protein specificity and activation. As predicted, β 2AR-T4L did not bind to the stimulatory G protein for adenylyl cyclase.

The authors are able to draw several insights into β 2AR function from their structure. First, the close packing of the helices on the cytoplasmic face of the receptor suggests that ligand-induced conformational changes occur through shifting of the side chains that interact between the helices. Second, they are able to map previously described mutations onto their structure: mutations leading to constitutive or impaired activation are located along the transmembrane helices, and none of these form part of the extracellular ligand-binding pocket. The structure shows that these residues are connected to each other and to the binding pocket by packing interactions, such that changes in the pocket due to ligand binding could be propagated through the transmembrane helices to the intracellular loops. Finally, β 2AR and rhodopsin share a set of conserved, loose-packed residues near a water molecule cluster that they propose is important in allowing conformational rearrangements due to low steric hindrance.

Left open by this work are the nature and dynamics of the multi-step GPCR activation. β 2AR, with a molecular weight of 38.9 kilodaltons, is a small enough protein that NMR relaxation dispersion experiments could be used to quantitatively probe the agonist-induced conformational changes. The process of β 2AR activation involves at least two distinct mechanisms2: (1) disruption of the 'ionic lock' interactions in the inactive structure between the cytoplasmic faces of helices II and III and helix VI, and (2) structural shifts around a conserved proline residue in helix VI (called a 'rotamer toggle switch'). Different agonists affect these molecular constraints in different ways: full agonists break the lock and trigger the switch, while partial agonists can alter one constraint but not the other. It should be possible to use β 2AR-T4L, which does not interact with the G protein, in the presence of excess agonist to limit the system to two-state exchange between the bound receptor-agonist complex and the complex after tripping both molecular switches. Likewise, β 2AR-T4L in the presence of excess partial agonist should create two-state conformational exchange between the receptor-ligand complex and the complex after tripping only one of the two switches. A potential complication is that, even at agonist saturation, β 2AR is known to sample several intermediate structures.

This structure also opens the door for the crystallization of other GPCRs by a similar method, and to further investigation of human β 2AR-T4L bound to different ligands. Another logical next step from this paper would be to attempt to co-crystallize the active state of the receptor in complex with an agonist ligand. The authors note, however, that efforts to crystallize β 2AR-T4L bound to catecholamine could be hindered by both the chemical instability of the catecholamine as well as the mutant receptor's lack of interaction with G protein, which results in relatively low agonist affinities.

References:

1. Rosenbaum DM, Cherezov V, Hanson MA, Rasmussen SGF, Thian FS, Kobilka TS, Choi HJ, Yao XJ, Weis WI, Stevens RC, Kobilka BK. GPCR Engineering Yields High-Resolution Structural Insights into β 2-Adrenergic Receptor Function. Science 318: 1266-73 (2007).
2. Yao X, Parnot C, Deupi X, Ratnala VRP, Swaminath G, Farrens D, Kobilka B. Coupling ligand structure to specific conformational switches in the β 2-adrenoceptor. Nature Chemical Biology 2: 417-22 (2006).

Sunday, November 25, 2007

Resveratrol!

Caloric restriction (CR) has been of interest for some time due to its apparent slowing of the aging process. In addition to conferring enhanced longevity, it is known to correlate with the alleviation of a number of biomarkers associated with aging, as well as lowering age-associated disease incidences. In spite of this, its mechanism remains poorly characterized. Resveratrol, a polyphenol with antioxidant and antitumorigenic activity, is intriguing because it seems to mimic many of the affects of CR, and has been shown to provide a variety of palliative and neuroprotective effects in several model organisms. In this work1, the authors show that one function of resveratrol is to stimulate AMP kinase (AMPK) activity in neurons. This is a significant step towards characterizing resveratrol's mechanism, which, in turn, may help provide a better understanding of how CR works.

The authors show that in mouse Neuro2a neuroblastoma as well as mouse dorsal root ganglia (DRG) sensory and cortical neurons, resveratrol correlates with an increase in both phosphorylated AMP and a downstream target of activated AMPK, phosphorylated acetyl-CoA carboxylase (ACC). These increases are comparable to those generated by a well-characterized AMPK activator, AICAR. This AMPK activity is not stimulated indirectly by decreased cellular energy levels (measured by the relative AMP:ATP ratio). Next, they show that resveratrol-mediated AMPK activation halts Neuro2a cell proliferation and induces an increase in neurite outgrowth. This is again similar to the AICAR-mediated AMPK activation effects, and is consistent with AMPK's activity in other cell types. AMPK activation is required and sufficient for this resveratrol-induced neurite growth. AMPK activation is also correlated with mitochondrial biogenesis, as measured by increases in mRNA levels of three markers for mitochondrial biogenesis.

In Neuro2a cells, resveratrol’s activation of AMPK is unaffected by the presence of inhibitors for SIRT1 (associated with stress response and cell cycle regulation, and with polyphenol activities) or CaMKKβ (a kinase upstream of AMPK). This suggested that another activating kinase upstream of AMPK, LKB1, is likely to effect AMPK activation. To test this, DRG sensory and cortical neurons from mouse embryos containing loxP sites flanking the Lkb1 exon were infected with lentivirus expressing a Cre recombinase capable of conditionally knocking out Lkb1 from this engineered site. LKB1 removal reduced AMPK and ACC activation in both cell types. Interestingly, while introduction of a CaMKKβ inhibitor did not affect DRG sensory neurons, it inhibited AMPK and ACC activation in cortical neurons. Finally, the authors demonstrated that directly injecting mice with resveratrol within two hours led to increased levels of AMPK and ACC phosphorylation in the brain.

A major question raised by this work is the difference in resveratrol-mediated AMPK activation in Neuro2a and DRG sensory cells versus activation in cortical neurons. LKB1, which appears to regulate AMPK activation in both cell types, is part of the three-protein AMPK kinase complex, and is known to regulate AMPK response to decreased cellular energy levels (AMP buildup).2 As shown in this work, resveratrol-induced AMPK activation is independent from LKB1’s response to cellular AMP levels. CaMKKβ appears to control AMPK response to Ca2+ levels in the cell, which raises the question of whether this is also the mechanism by which resveratrol induces AMPK activation in cortical neurons. This could be tested by examining CaMKKβ’s resveratrol-effected regulation of AMPK in varying concentrations of Ca2+.

Is there a physical interaction between resveratrol and either of upstream regulators of AMPK examined in this work? One way to test this would be through fluorescence resonance energy transfer (FRET). Attaching a fluorescent protein to LKB1 or CaMKKβ and a small fluorophore, such as Cy3 or Cy5, to resveratrol would result in emission at the small fluorophore peak if resveratrol is in close proximity to the regulatory kinase. Although the specificity of this technique, and the fact that it can be used in vivo, make it well-suited for this, a potential problem is that, due to resveratrol’s small size, attachment of a small fluorophore might alter its interactions significantly. Another possibility would be to label resveratrol, which has three hydroxyl groups, with a radioactive oxygen isotope, then use anti-LKB1 antibodies to immunoprecipitate the complex out of solution. If resveratrol is bound to the complex, Western blotting followed by film exposure of the blot would detect radioactive signal.

Another logical follow-up to this study would be to examine whether resveratrol and CR complement each other. Since resveratrol is predicted to function as a CR mimetic, the expectation is that introducing resveratrol into a system affected by CR would have no effect. There are several assays that could be done to gauge this by comparing CR mice with and without resveratrol to ad libitum fed mice with and without resveratrol. Since CR functions to increase life-span, the most straightforward measurement is mortality. Another, potentially more informative, assay is a comparison between AMPK and ACC activation levels between these four groups. In light of the differences in regulation of AMPK in different mouse neurons, it would make sense to do these assays for a variety of cell types, as it is possible that the CR and resveratrol pathways overlap for some cell types, but not others.

References:

1. Dasgupta B, Milbrandt J. Resveratrol stimulates AMP kinase activity in neurons. Proc. Natl. Acad. Sci. U.S.A. 104: 7217-22 (2007).
2. Shaw RJ, Lamia KA, Vasquez D, Koo SH, Bardeesy N, DePinho RA, Montminy M, Cantley LC. The Kinase LKB1 Mediates Glucose Homeostasis in Liver and Therapeutic Effects of Metformin. Science 310: 1642-46 (2005).

Friday, November 23, 2007

UC Bubble

I live in a bubble in Mission Bay, San Francisco.
Except it's not really San Francisco.
It's not even really Mission Bay.
It's just a bubble.

Tuesday, November 20, 2007

Fun with NAD

I stumbled on this interesting review article a short while ago: Hipkiss, AR. Energy metabolism, altered proteins, sirtuins and ageing: converging mechanisms? http://www.springerlink.com/content/j2332796374m3178/

I thought it led to some interesting predictions -- for example, what happens if you ramp up NAD levels? I've never worked with C. elegans but it strikes me that this might be an easy experiment to do with them, and you'd get results pretty quickly. According to this paper, you're getting this great benefit from increased NAD levels because it's used as a cofactor by an enzyme that converts glyceraldehyde-3-phosphate to 1,3-diphosphoglycerate, which is important because G3P (and its precursor, dihydroxyacetone phosphate) can spontaneously decompose into the toxic glycating agent methylglyoxal. So what happens if you add more NAD into a system? Or, for that matter, increase levels and/or activity of the relevant enzyme (GAPDH)?