Central Limit Theorem Part 2: Retaliation

Discrete population, with different probabilities associated with different numbers
Sampling distribution of means from the discrete parent population, with a sample size of n=30





In the last post, we left the central limit theorem defined as a normally-distributed sampling distribution of means reflecting the shape of the normally-distributed parent population, but with a smaller spread and less variance. However, what happens when we sample from a non-normal distribution, such as an exponential distribution or a discrete distribution?

As it turns out, the sampling distribution of means is also normal, regardless of the shape of the parent population. This holds for sample sizes of about 30 or more, which is why the central limit theorem is also sometimes referred to as the law of large numbers.

This is shown in the following video, and can be modified with this R script.



The Central Limit Theorem: Part 1

Random sample of numbers from a normal distribution, N ~ (100, 10). Actual normal distribution is superimposed in red.


One fundamental concept for hypothesis testing is something called the Central Limit Theorem. This theorem states that, for large enough sample sizes and for enough samples, we begin to build a sampling distribution that is approximately normal. More importantly, when we build sampling distributions of the means selected from a population, the average mean is identical to the mean of the parent population.

To illustrate this in R, from the parent population we can take random samples of several different sizes - 10, 50, 300 - and plot those samples as a histogram. These samples will roughly follow the shape of the population they were drawn from - in this case, the normal distribution with a mean of 100 and a standard deviation of 10 - and the more observations we have in our sample, the more closely it reflects the actual parent population. Theoretically, if our sample were large enough, it would in essence sample the entire population and therefore be the same as the population.

However, for smaller sample sizes, we can calculate the mean of each sample and then plot that value in a histogram. If we do this enough times, the mean of the sampling distribution has less spread and more tightly clusters around the mean of the parent population. Increasing the sample size does the same thing.

The demo script can be downloaded here; I have basically copied the code from this website, but distilled it into an R script that can be used and modified by anybody.


Brief Overview of Standard Error

As I begin teaching a statistics course next semester, I've been spending the past couple of weeks hitting the books and refreshing my statistical knowledge; however, to my dismay, I remember virtually nothing of what was taught during my salad days of college, when my greatest concern was how fast I could run eight kilometers, and whether there would be enough ice cream left over in the Burton Dining Hall after a late workout. You laugh now, but during certain eras of one's lifetime, there are specific things that take on especial significance, only to be later ridiculed or belittled; as what is important to an adult may seem insignificant to a child, whereas what is a matter of life and death for the child may seem silly to the adult, even though there is, deep down, recognition of the same hopes and fears, the child the father of the man.

In any case, imagine my sphincter-tightening (and subsequent releasing) horror when I realized how little I actually knew, and with what haste I began to relearn the fundamentals; not only in statistics, but in several other related fields, such as biology, physics, eschatology, chemistry, and astrology, which are needed to have any sense about what one is doing when analyzing neuroimaging data. It is one thing to bandy about the usual formulas and fill them in as needed; it is completely another to learn enough jargon so that, even if you still do not understand it, you can use enough impressive-sounding words to allay any fears that you are hopelessly, utterly ignorant. And this, I maintain, is the end of all good education.

I leave you with one of the most famous quotes about the value of education, from George Washington's second inaugural address:

Power flows to the one who knows how. Desire alone is not enough.

More details about standard error can be found in the following video, which features a legit, squeaking chalkboard.

AFNI Command of the Week: 3dcopy

Nothing earth-shattering here: Just a straightforward conversion command to let AFNI import data from different file types, such as .nii or .img/.hdr extensions. However, when I first started out doing FMRI analysis it took me quite a while to realize that this command was out there; so if you're in the same boat, here it is.

For conversion to AFNI's BRIK/HEAD format, simply type in the name of the dataset to be converted, followed by an output name, e.g.:

3dcopy r01.nii r01
----> r01+orig.HEAD r01+orig.BRIK

Datasets can also be converted the other way around, using something like 3dAFNItoNIFTI, 3dAFNItoANALYZE, etc. Using 3dcopy on a dataset already in .BRIK/.HEAD format will simply rename the dataset without affecting the extension, similar to 3drename.

Note that virtually all of AFNI's commands will output data in BRIK/HEAD format no matter what the input dataset, so you probably will not use this command that often. However, if you absolutely, positively, need to have a dataset in AFNI format - and you need it NOW - then 3dcopy is your new best friend. Move over, thirty pack of Keystone Light!



Resting State Functional Connectivity Database



For those of you not in the know, there is a gimundo FMRI database comprising resting state datasets from research laboratories all over the world. (Meaning the United States, Belgium, Ireland, and the Netherlands.) Scanning parameters and sample features are included with each dataset, making it straightforward to download and analyze entire datasets with relative ease. This is my first time doing resting state functional connectivity analysis, as I have never before collected a dataset using this technique, and I will be sure to document my progress as I go along.


Thanks to Omar Maximo, who can dunk a basketball literally AND figuratively.

2012: Year In Review

To manage my day-to-day affairs, dealings, connections, and errands, I keep a planner - an honest-to-god, pen-and-paper planner. Nothing digital. I began keeping one two years ago to the day, in the hopes of better managing my time, and in the hopes of feeling more accomplished at the end of the day as I reviewed what I had finished. It is rather bulky, to be sure, too large to fit in my coat or my pocket; and, sometimes, it appears to be more trouble than it's worth. There are times where I see my colleagues with their Blackberries and PDAs, and I wonder how it would be to have one of those; to be able to sit on the bus next to someone who is supposedly your girlfriend, and idly hold their hand while you surf the web with the other hand, searching for slick deals on the next issue of Humungo Garbanzo BOLD Responses, while your distracted odalisque does the same with her unheld hand, the limp connection of flesh between you serving as a kind of dull wire carrying a weak current.

Not that I criticize; this is an efficient use of available resources, as what else is a man to do with his free hand? The impulse to hold a neighboring limb should be thought of as the fulfillment of some nameless urge, such as Edmund Hillary's reason for scaling Mount Everest - because it was there. The only danger is that this most basic form of human contact should divert your attention from browsing  Humungo Garbanzo; after all, there is the distinct possibility that concentrating on the held hand would lead to an unnecessary focus on details one would otherwise ignore, such as lightly caressing the ensheathed tendons - strong as hawsers, yet soft and yielding; or maybe the almost imperceptible beads of sweat budding along her palm and absorbed into yours; or perhaps even the faint buzz of excitement as you wrap the sensitive tips of your digits around the heel of her hand, feeling the delicately cambered hills of her knuckles.

But I digress; the important point is that I use a paper planner, if for no other reason than that there is nothing like the satisfaction of placing a nice fat checkmark next to a recently completed errand, or being able to go back, flipping through the pages, and seeing what has been done, what has been left undone, and what has simply been scotched and crossed out, either due to negligence or in favor or something more important. In honor of the end of the year, from my planner I have chosen one entry per week for the year of 2012; I hope it is illuminating as to how I spend my time and my thoughts.


  1. Friday, January 6th: Test E-Prime 2.0 drivers
  2. Tuesday, January 10th: Write Attitudes paper (scratched out; I dropped the class that week)
  3. Thursday, January 19th: Read Chpt. 4 Clinical Neuroanatomy
  4. Friday, January 27th: Return Beethoven sonatas
  5. Saturday, February 4th: Grade remaining P433 papers; celebrate with some Keystone Light. Make sure it is flat and warm, just how you like it.
  6. Wednesday, February 8th: Put in E-bay bid for whiskey decanter shaped liked human skull
  7. Tuesday, February 14th: Do taxes. Get at that money.
  8. Wednesday, February 23rd: Work on CNS poster; replace 'S' in name with dollar sign
  9. Monday, February 27th: 11:15am, proctor P433 class. Note to self: check whether the words "Proctor" and "Proctologist" are related.
  10. Friday, March 9th: Do atanh (?) on new params. (Looking back on this, I'm still not sure what it means.)
  11. Monday, March 12th: Surface maps of MO2. Try to let people know you are cool and connected.
  12. Thursday, March 22nd: Psych yourself up enough to put a nine-volt battery on your tongue. Do NOT faint like you did the last time.
  13. Tuesday, March 27th: AFNI bootcamp; schmooze with the AFNI crew. Laugh at their jokes.
  14. Thursday, April 6th: You coward. Try the battery thing again.
  15. Saturday, April 14th: Get up the nerve to ask out the cute waitress who works at Smokin' Jack's Rib Shack.
  16. Thursday, April 19th: Coward!
  17. Wednesday, April 25th: Carpet-bomb friends with emails begging them to do your study.
  18. Thursday, May 3rd: Begin writing quals exams
  19. Sunday, May 13th: Call mom; ask for more money. Also, wish her a happy Mother's Day
  20. Saturday, May 19th: Order The Magic Mountain / Lolita
  21. Wednesday, May 23rd: Send FIR results to A-Team
  22. Saturday, June 2nd: Call Carl's Carpet Cleaning (motto: A carpet stain, ain't no thang)
  23. Saturday, June 9th: Go to wedding; share hotel room with girl who has ambiguous relationship status. Also, find a store that sells salad spinners.
  24. Saturday, June 16th: Run Grandma's Marathon
  25. Wednesday, June 20th: Work on quals
  26. Thursday, June 28th: Work on quals
  27. Friday, July 6th: Work on quals
  28. Wednesday, July 11th: Work on quals
  29. Tuesday, July 17th: Pick up plant (aka, Chick Magnet) for living room. Also, work on quals.
  30. Friday, July 27th: Work on quals
  31. Friday, August 3rd: Quals defense. Remember to make flattering comment about Josh's new haircut. Squeezy peasy lemon easy.
  32. Wednesday, August 8th: Visit grandparents
  33. Friday, August 17th: Prepare for semester 
  34. Saturday, August 25th: (Only one word here: "Subscribe". Probably will remain a mystery for the rest of my life.)
  35. Wednesday, August 29th: Purchase Barry Manilow tix
  36. Friday, September 7th: Pick up whiskey skull decanter
  37. Thursday, September 13th: Make potato battery
  38. Friday, September 21st: Attend performance of Don Giovanni
  39. Wednesday, September 26th: Memorize Porphyria's Lover
  40. Sunday, October 7th: Milwaukee Marathon. (Remember not to run the first half too fast, lest you blow up and look like a fool for the last hour)
  41. Saturday, October 13th: Review student papers
  42. Wednesday, October 17th: Send birthday wishes to the Grandpas
  43. Friday, October 26th: Contact that really smart Iranian kid for help with computational neuroscience homework
  44. Monday, October 29th: Send Debussy fingerings to piano student
  45. Tuesday, November 6th: Vote for the right person
  46. Friday, November 16th: JAGS
  47. Saturday, November 24th: Buy eyedrops
  48. Saturday, December 1st: Accompany for Ryan's senior recital; play at John Cage Centenary
  49. Sunday, December 9th: Write Carleton Reunion Committee
  50. Thursday, December 13th: Lunch with Ale. Be a man and demand that she pay.
  51. Thursday, December 20th: Observe old lady back van into train station and obliterate it. (This actually happened)
  52. Sunday, December 30th: Reflect on life


Well, that about does it; as you can see, I have a full life. And this by no means captures everything that goes on; for example, last week I drank sixty beers, finished a novel I began back in July, and had my flu shot. I walked to a grocery store three miles from my apartment, and skipped two miles on the way back home. I made a payment on my student loans, pounded a jar of Nutella within forty-eight hours, and read the preamble of the U.S. Constitution. One day I actually put on sunscreen, and didn't even directly look at the sun. I washed the dishes - twice - and organized the clothes in my closet according to color. I used a high-tech machine to analyze the chemical composition of the sticky stuff they put on lint rollers, and read a Wikipedia entry on Hector Berlioz. And to top it off, I accidentally got high sniffing a box of Clorox wipes and recorded my vision into a screenplay which, I am told by a reliable source, has a good chance of success at the box office. And my parents always told me that I would turn out to be a good-for-nothing bum. Well, look at me now!

Andy's Brain Blog Advice Column: Should You Date In Graduate School?

Dear Andy's Brain Blog,

I am midway through the second year of my graduate program, and over the past couple of months I have gotten to know a girl in my cohort very well. At first we started just by hanging out a lot, but one night we both got pretty jacked on some Nutella spiked with Smirnoff Ice and before I knew it things got out of control. It quickly escalated into kissing, necking, holding hands, and heavy petting, although we kept it PG (-13). Although I had the time of my life that night, and although I have had this same scenario happen with several girls before, something feels different about this one; it doesn't feel like just another fling, but possibly the prelude to a full-on relationship. 

However, I am conflicted: How much should a man dedicate himself to a relationship, if at all, when there are the pressing concerns of classes, teaching, writing, and research? Would it be best to break it off before it becomes too serious? Or, if it is to be pursued, how should it be approached?

Sincerely,

Brad


Dear Brad,

Let me begin by stating it is perfectly normal, and not weird at all, for a manboy of your age to begin experimenting with odd cocktails of sugary products. But first let me address an unasked question: Why should you trust me with relationship advice? Well, not to brag or anything, but I have run a (half) marathon, I have no major diseases, and I have read over a dozen novels, including the complete oeuvre of Laura Ingalls Wilder and Beverly Cleary. The depth and breadth of my reading, combined with extensive travels throughout the upper American Midwest and two provinces of Canada, has granted me unique insight into prepubescent sororal relationships, the finer points of horse trading, and how to recover from crop damage following a hail storm. Most important, I have become an observant scholar of relationships between the sexes - as Tolstoy would put it, the tragedy of the bedroom - and this endeavor has granted me an eagle-eye view over the landscape of your squalid desires.

To illustrate the deleterious effects of falling in love, a peculiar phenomenon of which you seem to be at risk, I share with you a letter - ladies and gentlemen, an honest-to-god, handwritten letter! As though you need any more evidence of the madness wrought by such primitive emotions - recently received from one of my colleagues at a neighboring university which described his sinking into the turbid ocean of his own lust, the unfortunate result of a series of trysts and resulting hanky-panky with a post-doctoral student working in another lab, which, instead of draining the cisterns of his lust, whipped him into a frenzied passion. Besides the irritation provoked by the omission of any question as to how I was doing - the letter was, in a sense, one prolonged, histrionic soliloquy directed toward an uninterested audience - I was shocked to hear of the level of absorption and mindless passion to which he had fallen (he would have said risen). He enumerated, in painstaking detail, the features and mien of his lover; the slender, supple, opalescent skin of her bare arm; those vermilion, pillowy, textured lips rising to meet his upon awakening from a fitful, sleepless night; and above all, serving as two bright nodes in a trinity of passion, a pair of milky peaks bedighted with brilliant orbs; incarnadine, inexhaustible wellsprings of his bliss, the very thought of which was enough to send a rill of excitement down his spine and terminate in a limpid jet of love.

Exhibit two has no ocular evidence, but rather rests on a memory; old, but still intolerably vivid. An acquaintance of mine in college, living in an adjacent room, once let down his guard and fell completely, hopelessly, stupidly in love with one of the first girls that he met. He once had the gall to stop me on my way out the door to a morning class merely to tell me of his first kiss shared with the object of his desire; he described how, as they talked one night, he had gradually pulled her closer to him, as if by the force of God, and how she began to talk more rapidly and at a higher pitch the closer they were drawn together, before a brief and pregnant silence; and then - a thousand comparisons between the expectation and the reality, a bubble of ecstasy bursting in slow motion - their lips met.

After that, he was a changed man; his grades went to pot, he claimed to see the world in a different light, and he began to go so far as to read and write poetry under her intoxicating influence. It was, from my perspective, a silly and infantile episode in his life; and lest the reader think that this was some innocent, puppy-love affair, let him know that I was, on several occasions, rudely awakened early in the morning by the sounds of strenuous intercourse. After they broke up - as inevitably happens under the demands and expectations of such powerful emotions - he was a wreck for months. His personal hygiene fell into desuetude, his appearance became slovenly and repulsive, and one could see, at a glance, that where he was once brimming with untamed eros, he was now spiritually detumescent. I hardly talked to him since that catastrophic episode, although one time he did manage to corner me and, still under the influence of a fevered mind, tell me that what had transpired - kiss, relationship, breakup, all - was one of the best things that happened to him. To this day, I cannot help reflecting on that puerile outpouring without a feeling of contempt.

As has been shown, love can lead to such dangerous feelings as inklings of the Eternal or the Infinite, along with all of their concomitant inspirations to do simultaneously heroic and stupid things; feelings that there might be, in fact, a deeper and greater reality beyond the pale of the daily grey. All of this, of course, is pernicious nonsense, and should be avoided accordingly. And, lest anyone forget, falling in love also leads to a pathological form of self-forgetfulness, spawning powerful and conflicting emotions such as a deep concern for someone other than the self, painful feelings of both tenderness and possessiveness, and the stirrings of insensate jealousy. How is it, I ask, that any serious student is supposed to concentrate on their work with all of these inchoate feelings spurring them to blind insanity?

However, if you have already crossed the Rubicon and find yourself increasingly enthralled to another, there is still hope to break the emotional ties before they become so entwined with your own being that to sever them would be, in effect, an amputation of the soul. After all, what the composers and poets and painters seldom mention is that, in the beginning at least, one can fall out of love as quickly as they fall into it; and I therefore recommend that, during one of your more lucid moments of reasoning - perhaps when the clouds of your mind have been dispelled after a particularly vigorous congress - it would be both fitting and proper to bring up a sensitive topic likely to introduce divisions between you and your lover; politics and religion being the two examples that most readily come to mind, although I am sure you can find others. It is best to exploit these divisions early on, as I have observed several miscarriages of the natural order of relationships in which two individuals, having known and cared for each other for several years, no longer find these differences to be grounds for breaking up, nor do they even find these differences to be of much importance at all; instead, these differences are seen petty and trivial compared to the emotional and physical well-being of their partner.

By all means, do not let this happen to you. Reader, I have seen men and women worked up into a passion - literally, a sensuous passion, far more intense than that effected by the most possessive jealousy or the most animal lust - over differences such as those described above. For maximum effect, of course, it is helpful to have an entire group of people, and instead of a difference per se, have them all hold more or less the same opinion in solidarity against an invisible opponent; as I have observed such groups, with their perceived moral superiority and righteous indignation serving as a highly volatile fuel, require only the faintest of sparks to overthrow their vaunted reason and ignite a general conflagration of directionless emotion. I once read somewhere a dull intellectual describe such events, in which each individual has a similar opinion, lightly adopted but firmly held, as arising from a combination of ignorance, dishonesty, and a pusillanimous desire for social acceptance; but in any case, the point here is to tap into that same atavistic, tribal mentality, in order to alienate and distance yourself from another, lest you find yourself so emotionally involved with this person that you are unable to easily assign them to a category.

In all, best to nip this in the bud straightaway, and immerse yourself in your readings, research, and teaching, lest you lose sight of what is really important. Relationships, love, marriage, et al. is for saps, as is self-evident to any reasonable observer; and if any of this is to be engaged in at all, it should only be for health purposes, without any resulting attachment, similar to a day at the spa. One of my friends recently sent me a copy of a book called The Red and the Black, by a man named Stendahl, saying that it would help me understand such trivialities; but in my hands, it was merely a lump of valuable matter. I hear that several young readers entering college are beginning to 'discover' Stendahl; I wish them joy.


AFNI's uber_subject.py



Back in the good old days, we would create our scripts ex nihilo; out of nothingness would we construct gigantic, Babel-esque scripts that nobody - to be honest, not even we - could understand. We would pore over FMRI textbooks and fumble around with commands and tools we thought were germane, only to have everything collapse all around us when it came time for execution. I remember with painful clarity the moment when I finally hit upon the idea of looping over subjects for each iteration of the script; I thought I was a creative genius.

Lawless, ruthless, and terrifying; those days were like the wild west. Nobody knew what the hell was going on; you might come across a block of analysis script posted by some group in Singapore, compare it to your own, and wonder how your two labs could ever come to the same conclusion about anything, given how radically different your scripts were. Your script would call for slice timing correction, followed by coregistration and normalization, while their script would call for a cup of chopped onions and a clove of chopped garlic. Then, slowly, you would realize that what you were looking at was a recipe for chicken cacciatore or something, and you would feel like an idiot. Overall, those days were not good.

Fortunately for us, these days we now have a script called uber_subject.py, which takes care of generating analysis scripts quickly and easily. AFNI script ex machina, as it were. If you have programs and binaries from the past couple of years or so (and there's no reason you shouldn't; if you haven't updated in a while, a quick '@update.afni.binaries -d', without the quotes, should do the trick), you will have uber_subject.py. If you type it from the command line - and your python libraries are current and functional (see here for a message board thread if you have trouble with this) - then a graphical user interface will pop up, prompting you to input parameters such as smoothing kernel size, number of regressors, relationship status, and so forth, until you have a completely idiosyncratic script to fit your needs. Overall it has worked very well for me so far, and word is that it will be integrated with an even higher level script called uber_script.py. I've had some issues getting it to work, so instead of trying to fix it, I have taken the path of least resistance and settled for uber_subject.py. You will be glad that you did as well.


AFNI Command of the Week: 3dinfo

Researchers are always trying to find out more about their data. They examine at it from different angles; place it in their hand and feel its texture and test its heft; and look closely for portents and signs and the apocalypse.

3dinfo, similar to FSL's fslinfo and SPM's spm_vol, returns critical information about an FMRI dataset, such as the number of voxels along the x-, y-, and z-directions, the size of those voxels, and other header essentials, such as the number of volumes and the length of the repetition time (TR). This information is critical when performing steps such as slice timing correction with 3dTshift, when the researcher may want to know more about the number of slices and the acquisition of those slices, or when doing a step like cluster correction, where the voxel dimensions are a critical piece of information.

A few lesser known options include the -VERB option (in all caps), which generates even more information than the typical -verb option, and -echo_edu, which formats the standard output into a clear and easy-to-read table. This and more can be found in the following video:



Super Useful Sampling Distributions Applet


Similar to the applets I used for my P211 research methods class, there is an online program which allows the user to specify a population distribution, and then build a sampling distribution of statistics such as mean, median, and variance. When I was first starting out I had a difficult time grasping what exactly a sampling distribution was, or what it meant, exactly; but tools like this are great for visualizing the process and building an intuition about what's really going on. The result is, I still don't understand it - like, at all - but I sure as hell feel more confident. And that's what is really important.