Archive for March, 2010
Brief Hints: C# Nullable Types and Arrays, Special Double Values
Brief Hints: I wanted to show you three things in C# that I’ve been using a lot lately.
Nullable Types are a convenient language construction in C# that allows one to assign a primitive type with null…
double? someval = null; // declares a nullable double called 'someval'.
The question mark suffixing the keyword double makes the variable someval nullable. This was originally designed so that one can retrieve values from LINQ to SQL without checking for nulls (SQL inherently makes this distinction). This could be thought of as yet another construct to make autoboxing primitives more intuitive and more entrenched in the language.
I use nullable types when I need a special ‘unassigned’ value for “find the greatest” or “find the least” kinds of loops.
When we apply Nullable Types to Arrays, we get an array of nullable primitives (arrays are already nullable, being first class objects).
double?[] somevals = new double?[10]; // declares an array called 'somevals' of ten nullable doubles.
An array of primitives is initialized with all values 0.0; whereas an array of primitve?s is initialized with nulls.
Special Double Values are also something that I’ve started using a lot. There are many algorithms I’ve been coming across that use “magic numbers” corresponding to arbitrarily high and arbitrarily low numbers. Instead of using evil magical quantities, I’ve been using Double.PositiveInfinity and Double.NegativeInfinity. C# makes it easy to assign three more special quantities: Double.NaN, Double.MinValue and Double.MaxValue.
Edit: I forgot to mention why I kept italicizing the word primitive. C# doesn’t really have primitives that are exposed to the developer– everything actually IS an object, and the illusion of boxing or not isn’t really relevant. This just makes nullable types all the more logical.
An Old Physiology Project — Operation Spinny Chair :D
I discovered this ancient report in my repository about three months ago– I’ve finally decided to put it up because it made my day reading the abstract again. This is definitely one of my prouder albeit sillier projects from the days of my undergrad.
Independent Research Project Acute centripetal acceleration is correlated with increased heart rate and R-wave amplitude
Matthew Boyle, Bryan Chung, Eddie Ma
Abstract
In the present study, we set out to discover the correlation between the exposure of acute centripetal acceleration in human subjects and cardiovascular function across the following three dimensions: Heart rate, R-wave amplitude and QRS interval. This was accomplished by measuring the above properties via Lead II Bipolar ECG trace, after having spun the subject at 0.8 revolutions per second in an office chair for successively, 30, 60 and 90 seconds. It was determined that heart rate showed strong positive correlation (n = 3, average increase between trials of increasing duration, 3.2 beats per minute, s = 1.8). R-wave amplitude showed positive correlation in all subjects up until and including the 60 second trial. There was no systemic correlation between duration of spin and the length of the QRS interval in any of the subjects. The heart is therefore an important effector in response to centripetal acceleration in the human model.
Key Words: electrocardiogram, QRS interval, centripetal force, R-wave amplitude, spinning office chair.
[ Download this | PDF ].
Thumbnails of pages 5, 7 and 11.



YES. This easily trumps the mathematical study on zombie propogation as my favorite esoteric paper.
You’re too kind Matthew
— Incidentally, I’ll come bother you for the link to the zombie paper mentioned.
Idea: Delaunay Simplex Graph Grammar
The Structural Bioinformatics course I’m auditing comes with an independent project for graduate students. I’ve decided to see how feasible and meaningful it is to create a graph rewriting grammar for proteins that have been re-expressed as a Delauney Tessellation.
I was first introduced to the Delauney Tessellation about half a year ago. Such a tessellation is composed of irregular three dimensional tetrahedrons where each vertex corresponds to an amino acid. A hypothetical sphere that is defined by the four points of such a tetrahedron cannot be crossed by a line segment that does not belong to said tetrahedron.
An alphabet in formal languages is a finite set of arbitrarily irreducible tokens that composes the inputs of a language. In this project, I want to see if I can discover a grammar for the language of Delauney protein simplex graphs. Graph rewriting is likened to the collapse of neighbouring tetrahedrons. The tetrahedrons selected are either functionally important, stability important or have a strangely high probability of occurrence. This definition is recursively applied so that previously collapsed points are subject to further collapse in future passes of the algorithm.
When a subgraph is rewritten, two things happen. Some meaning is lost from the original representation of the protein, but that same meaning is captured on a stack of the changes made to the representation. In this way, the protein graph is iteratively simplified, while a stack that records the simplifications indicates all of the salient grammatical productions that have been used.
This stack is what my project is really after. Can a stack based on grammatical production rules for frequency of occurrence render any real information, or is it just noise? I can’t even create a solid angle to drive my hypothesis at this point. … “Yes … ?” …
I’ve seen a lot of weird machine learning algorithms in my line of work… and I attest that it’s hard for a novice to look at a description and decide whether or not it derives anything useful. Keep in mind that the literature is chuck full of things that DO work, and none of the things that didn’t make it. I conjecture that this representation has made me optimistically biased.
This method however IS feasible to deploy on short notice in the scope of an independent project
This sounds really neat. I want to make sure I have your idea straight:
a) a Delaunay tessellation of a protein defines/is equivalent to a simplex graph
b) such simplex graphs are the tokens of your language
c) collapsing tetrahedra in the Delaunay tessellation/performing the equivalent operation on the simplex graph are your grammatical production rules
d) you generate a sequence of tessellations/graphs (each of which is, by definition, a token) by using your grammatical production rules
d.1) as a restriction on your production rules, you only allow collapsing of tetrahedra that meet certain criteria (functionality, stability, or frequency)
e) such a sequence forms a “word” in your language
f) you capture this word via the stack of operations performed on the simplex graph
g) Ultimately you want to be able to look at the stack (“word”) produced by your grammar and have it tell you something about the protein
Wow, this post turned out to be far longer than I meant it to be
.
That was very succinct. I probably should have written it in the form you gave me to start. I’m currently dissecting a few proteins using a tessellation script Dr. Burkowski put together– apparently, work has already been done compatible with Chimera which cuts short my work. The present dissection actually sees evaluation of two things: which combinations of contact surfaces have potential for reduction; and which tetrahedron labels (as four-tuples) occur most frequently as tokens. To be honest, it swings between more daunting and less daunting as I progress. I’ll update this post when I have some nice pictures
Arclite Theme – Invisible Text in Submenu Fix
Brief: The Arclite WordPress Theme is great, but the default CSS for the submenu causes the text to be almost completely invisible when moused over. The fix is an easy edit in style.css.
ul#nav ul a:hover, ul#nav ul a:hover span,
ul#nav a.active ul a:hover span,
ul#nav li.current_page_item ul a:hover span,
ul#nav li.current_page_ancestor ul a:hover span,
ul#nav ul li.current_page_parent a:hover span,
ul#nav ul li.current_page_item a:hover span,
ul#nav ul li.current_page_parent li.current_page_item a:hover span{
//color: #fff;
color: #2d83d5;
background: #CCCCFF;
}
To make the text look like a deep blue on light blue, I changed the default white colour for a:hover in the sub-menus section to match the text colour of the blue in the rest of the theme plus a lighter blue as its background.
Ed's Big Plans
1) The PositiveInfinity and friends are available in pretty much every language I’ve seen.
2) Why do Java and C# insist that all non-primitive types must be nullable? That is, why can’t I declare an object that must be non-null. There are many situations where this would be convenient.
3) The above generalises quite nicely to array then. I should be able to specify whether the array itself is non-null or the array can be null but the contents cannot (default).
Null gets very special treatment in object-oriented land and I find this increasingly annoying. [end of mini-rant]
I was thinking of (2) today… I suppose that some syntactic sugar would be used to specify that some variable should NOT be nullable– maybe a suffix that does exactly the opposite of what I’ve discussed above.
An ad hoc solution would inevitably take the form of some terrible factory design pattern. Eww.
I can’t immediately think of a useful application for (2) to be honest– I’m actually happier when everything is nullable. It sits better with me… I bet that this is more than slightly influenced by how much I take advantage of the ridiculously late binding in Python where you can just catch NameErrors for not having declared everything you need beforehand. Yes, it’s evil.
I think your conclusion above actually isn’t really about “null” at all, but the treatment of first-class objects vs. the treatment of (emulated) primitives.