Sunday, January 30, 2011

Tennis tips that worked for me

I've been playing tennis for years, and received coaching at various times from various coaches. Tennis coaching can be like a series of tips aimed at a particular stroke. For example, when I serve, the coach says "move your toss a bit to the right," or when I hit a forehand, he says "make contact with the ball farther out in front." Naturally I forget all this coaching when I'm playing recreationally, but occasionally, when I get particularly frustrated with a stroke that's not working (usually my backhand), I go through my mental checklist of tips and try to remind myself to take all that coaching advice. Here's what has given me results in the past.

General Ground Strokes

  • Your first move should be to turn your shoulders and bring your racket back. That should be automatic. Then think about getting to the ball and swinging through it.
  • Hit through three balls. Stand in the ground stroke position and place a ball on the court approximately where you would make contact. But instead of hitting just that one ball, think about hitting through three balls stacked closely together. This will make you hit through the one ball and hit out in front, and provides power and depth.
  • Open your hips to the ball before you make contact. The rotation should come first from your hips, then your should turn, then your arm, in that order.
  • Point the racket head behind you. When your racket is coiled behind you, it should be parallel to the sidelines, not the net. The butt of the racket handle should be pointed at the ball, and should stay that way as long as possible. That will keep the racket head way behind your fists. If you keep that position, it will force you hit the ball way out in front, which is what you want to do anyway. The alternative--what you should not do--is allow the racket to snap around, and roll over your wrists. Keep your wrists in front of the racket. They lead. 

Two-Handed Backhand

  • Keep your feet planted, and hit off your back foot. Sometimes I fall back into a bad habit of allowing one or both feet to stutter right as I'm hitting the shot. Sometimes this takes the form of one of my feet actually going back. Instead, keep your feet planted (if you can get to the ball in time), and concentrate on leaning into the shot with your weight on your back foot. This will stabilize your lower body and allow you to hit smoothly through the shot.
  • Keep the racket head up like a baseball bat as you move from ready position to the fully rotated position. This will cause the racket head to move in a large arc.
  • Drop the racket head toward the ground on the back-swing instead of keeping it cocked upright like a baseball bat.
  • Bend your knees. Your body is a tennis-ball hitting machine, but you have to position it at the proper height. So if the ball is low, lower the hitting machine appropriately. And by the way, the ball is almost always low.
  • Make contact out in front. This will straighten your non-dominant arm. Try hitting a super simple two-handed backhand: Hold the racket out in front of your body, use a very very short back swing, watch the ball all the way into the racket, make contact, and swing to a follow-through over the shoulder. When you're comfortable doing this, gradually increase the back swing.
  • Swing from inside to outside. Your racket should move not only from next to you to out in front of you (back to front), but from close to you to farther from you (right to left if you're left-handed). Imagine hitting a ball suspended over the center mark of the baseline, and painted on that center mark is an X with the two strokes pointing toward the net posts. As you hit through the ball, your racket should follow the stroke away from your body and out towards the net post--inside to outside.
  • Use the replacement step if needed. When pulled out wide, first plant your outside/back(/left) foot before taking the swing. Then swing through the ball, and as you follow through hop over so your right foot lands where your planted left foot was. E.g., step on the sideline with your left foot, take the swing, and on the follow through your right foot lands on the sideline.
  • Don't use an overly extreme grip. The racket face should be somewhat open when you strike the ball, and the contact point should not be extended too far out in front. Make contact closer to the body.

One-Handed Slice Backhand

  • Start with the racket head cocked behind your neck. Your upper arm, lower arm, and racket should form three sides of a box, with your head in the middle. 
  • When you chop into the ball, your racket arm moves forward into the court. Your other arm should be moving in the opposite direction, so you're spreading out your arms as you make the shot.
  • Don't necessarily try for a lot of backspin. Instead, you can also hit a low slice backhand with side spin, which is usually called "inside out." Backspin is not necessarily the goal; inside-out is okay too.
  • Keep your non-dominant hand on the racket as long as possible. This stabilizes the racket head before making contact.

Serve

  • Watch the ball as you toss it; keep your eyes on it as long as possible. That will keep your arm up longer, and it will keep your head up longer (keep your chin up too). You don't want to drop your arm or your head too soon. That will just rob you of power.
  • Keep your feet planted. I serve like Sampras (uh huh) in that I start with my feet shoulder width apart, and I don't move them. This is in contrast to the perhaps more popular "pivot" technique of moving the back foot up next to the front during the service motion. For me, the Sampras/Federer style is simple, and less can go wrong. (Fewer moving parts, I suppose.) But when I do this, I have to remember to keep my feet absolutely planted. I have a tendency to make a stutter step with my first foot, which robs all power from the shot. Instead of the power coming upwards from the legs as it should, it instead must come from the arm. This is a great way to strain your shoulder, which I did.
  • Hit the second serve out in front too. Some people think the first serve toss should go out in front for power, and the second serve toss should go behind you for maximum top spin. Not so; both tosses should be out in front. If your second serve toss goes behind your head, you'll get no penetration from the shot.  Update: Tony Delario says this is wrong. The second serve toss should not be out in front, but should land on the back of your neck.
  • Hit the second serve at the 7 o'clock position. By striking the ball profile at the 7 o'clock position on the second serve, you get under it and provide the needed top spin.
  • Strive for the Power X. The X is formed when your tossing arm gets pulled down and your racket arm crosses in front of it on the follow through.
  • Don't over-rotate. Your hips and shoulders should not rotate fully into the court after the serve. Kicking your back foot up and holding it there after the serve will prevent this over-rotation from occurring.

Return of Serve

  • Don't take a big back swing. If the ball is coming in fast and you take the racket back far, you're probably going to miss your shot. Instead, think about taking a very short backswing and punching the ball back with a simple stroke.
  • Watch the ball toss during your opponent's service motion. This is a good way to make sure you track the ball all the way into your racket--start watching the ball even as your opponent is tossing it.

Forehand

  • Keep your feet planted. This is just like the serve point, above. During my forehand, I would sometimes allow my front feet to take a quick extra step as I was hitting the ball. If instead I keep that foot planted, then my body properly coils and I get a smoother, more powerful and more controlled shot. Don't let your feet dance around while you're in the middle of the stroke. Get to the ball, plant, and hit. This doesn't mean you can't be running while hitting. It just means that you hit while your foot is planted and your body is steady and moving in towards the net.

Volley

  • Watch the ball until it hits your racket strings. Makes a world of difference. This goes for all shots. Watch the ball. Make it your whole world.
  • Your first move should be to lay your racket head backward. This allows you to get under the ball and provides the backspin.

Overhead

  • Run, don't shuffle. When in the overhead position, I found myself with a tendency to shuffle backwards. That's unnecessary. Just cross your feet and run like a man.

Sunday, January 16, 2011

How to install and use SyntaxHighlighter in Blogger

This post explains how to install and use Alex Gorbatchev's SyntaxHighlighter in Blogger to format computer code in your posts. Here's an example of unformatted code:

class Product < ActiveRecord::Base
  belongs_to :rulemaking
  belongs_to :sector
end


And here's an example of some Ruby code formatted by SyntaxHighlighter.
class Product < ActiveRecord::Base
  belongs_to :rulemaking
  belongs_to :sector
end
Much better.

Install SyntaxHighlighter

To install SyntaxHighlighter, copy the following lines into the template file of your blogger blog; insert them immediately before the closing </head> tag, as in the following example (all other code has been removed):
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html>
<html ... >
  .
  .
  .
  <head ... >
    .
    .
    .

    <link href='http://alexgorbatchev.com/pub/sh/current/styles/shCore.css' rel='stylesheet' type='text/css'/>
    <link href='http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css' rel='stylesheet' type='text/css'/>
    <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js' type='text/javascript'/>
    <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCpp.js' type='text/javascript'/>
    <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushBash.js' type='text/javascript'/>
    <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushCss.js' type='text/javascript'/>
    <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPlain.js' type='text/javascript'/>
    <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJScript.js' type='text/javascript'/>
    <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPhp.js' type='text/javascript'/>
    <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPython.js' type='text/javascript'/>
    <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushRuby.js' type='text/javascript'/>
    <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushSql.js' type='text/javascript'/>
    <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushVb.js' type='text/javascript'/>
    <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js' type='text/javascript'/>
    <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPerl.js' type='text/javascript'/>
    <script language='javascript'>
    SyntaxHighlighter.config.bloggerMode = true;
    SyntaxHighlighter.config.clipboardSwf = &#39;http://alexgorbatchev.com/pub/sh/current/scripts/clipboard.swf&#39;;
    SyntaxHighlighter.all();
    </script>
  </head>
  <body>
    .
    .
    . 
</body>
  .
  .
  .
Save the file. That's it for installation.

Use SyntaxHighlighter

To use SyntaxHighlighter, simply wrap your code in <pre> tags as follows:
class Product < ActiveRecord::Base
  belongs_to :rulemaking
  belongs_to :sector
end

In this example, I'm rendering Ruby code; but you can replace the word "ruby" with any of the languages described by the file names of the source code above. That's it. I don't know how, but it works for me.

Paste plain text code into the "Compose" window

One gotcha: When pasting in code from an application, make sure you're pasting in plain text, and make sure you're pasting it into the "compose" window (as opposed to the "Edit HTML" window). Why? Because when you paste text into the compose window, Blogger escapes the HTML. For example, the symbol "<" is escaped to become "&lt;". We want that; after pasting code, if you switch over to the "Edit HTML" window, you'll see all the escaped characters. Those are just fine the way they are.

Why paste plain text? Because Blogger will grab all sorts of formatting from any code you copy, such as colors, indentation, and the like. This will fill your code example with spans and result in a mess. How do you make sure you're pasting plain text? First copy the code into a text editor (e.g. Windows Notepad), then recopy that same code from the text editor. Now it's plain text.

Summary: Paste plain text code into the "Compose" window, not the "Edit HTML" window.

One word of caution: If you ever switch templates through Blogger's "Design" tab, you'll have to paste the template code back in because it will be overwritten.

Thanks to Alex Gorbatchev for a great tool. Think about making a donation for his work.

The Magpie List

My sister Eve started a new site at www.TheMagpieList.com. It holds lists of inspiring things that individuals submit directly to  the site, either through a form on the site or via email. For example, University of Oregon freshman Bridget Egan recently submitted the following list:
  1. Toy Story
  2. The O.C.
  3. The Great Gatsby, F. Scott Fitzgerald
  4. Titanic
  5. The Strokes
  6. The Catcher in the Rye, J.D. Salinger
  7. Mean Girls
  8. Superbad
  9. Who’s Lovin’ You,” Jackson 5
  10. Moulin Rouge!
Her list includes movies, a TV show, books, a band, and an individual song. So what makes the site interesting? While a reader could reasonably guess at the demographic of the person who submitted this list based on its contents, probably no one else in the world has exactly the same list, in exactly the same order. I might have the same band and the same books, and even match up exactly on the TV shows and movies, but to have that list and the individual track "Who's Lovin' You" by the Jackson 5? Unlikely.

And that's the beauty of the site. Each person will submit a list, and it will be unique, probably forever. The lists will reflect perhaps the culture, time period, income level, age, and other demographic attributes of the submitters, but even two people who share all those attributes will have different lists.

Case in point: Bridget Egan's roommate, who submitted a list at the same time. They're the same age and grew up culturally close enough to find themselves in the same dorm room at the University of Oregon, but Kate Robinson's list appears to be from another universe:
  1. The Fall
  2. The Tell-Tale Heart,” Edgar Allan Poe
  3. La Condition Humaine, René Magritte
  4. Black Coffee,” Ella Fitzgerald
  5. PomegranateW
  6. Knife,” Grizzly Bear
  7. Slaughterhouse-Five, Kurt Vonnegut
  8. Delivery
  9. Moleskine
  10. Synecdoche, Byron Kim
While the inclusion of "The Tell-Tale Heart" and Slaughterhouse-Five might suggest someone who recently finished an American high school English curriculum, the rest defies guessing about who Kate is. She's got an obscure tune by old jazz singer, an animated short film, a notebook, an abstract painting, and a fruit. This begs the question, "why?"

Luckily for us, the site's founder is well-connected in Hollywood, and occasionally gives a list the full film treatment, as long as the submitter includes a digital video file with her list. You can see the result--and why these two girls love pomegranite and that particular song by the Jackson 5--in episode 3 of MagpieTV.

Conclusion: Read some lists. Get inspired. Then: Submit a list! Submit an un-edited, raw video along with it, and see what the Magpie List does with it. Good luck.

Saturday, January 15, 2011

Stats paper: George P. Box: "Science and Statistics." 1976

The following are my notes and outline corresponding to a paper by George Box on the role of statistics in science.

Science and Statistics
Author(s): George E. P. Box
Source: Journal of the American Statistical Association, Vol. 71, No. 356 (Dec., 1976), pp. 791-799
Published by: American Statistical Association Stable
URL: http://www.jstor.org/stable/2286841.

Notes on Box: Science and Statistics


1 Introduction


Fisher was not just a great statistician, but a great scientist.

2 Aspects of Scientific Method


2.1 Iteration Between Theory and Practice

Learning is achieved by an iteration between theory and practice. Facts lead to the formation of a theory. The theory is used to predict outcomes. Discrepancy between prediction and experimentally known facts lead to a modified theory. The process repeats.

2.2 Flexibility

The iteration between theory and practice produces an “error signal,” the difference between what the theory predicts and what is known to be true. This is the feedback loop, and it what produces learning. Do not fall in love with the model; seek out error signals.

2.3 Parsimony

Seek to create simple models. Over-elaboration can be the mark of mediocrity.

2.4 Worrying Selectively

"Since all models are wrong the scientist must be alert to what is importantly wrong. It is inappropriate to be concerned about mice when there are tigers abroad."

2.5 Role of Mathematics in Science

"[We] cannot know that any statistical technique we develop is useful unless we use it. Major advances in science and in the science of statistics in particular, usually occur, therefore, as the result of the theory-practice iteration." The statistician must practice in the field and set himself up to be directly involved in real-life theory-practice iterations.

3 Fisher--A Scientist


This part explains how Fisher is a scientist, using for illustration his accomplishments at Rothamsted Experimental Station.

3.1 Rothamsted

At age 29 in 1919, Fisher took a temporary job at a small agricultural research station at Rothamsted. The director quickly saw that Fisher was a genius, and created a permanent post for him.

3.2 Weighing the Baby

Although he made astounding theoretical discoveries, Fisher had great interest in practical matters. In the textbook he wrote, Fisher used data he acquired by carefully weighing his own children to motivate a discussion of how best to plot data.

3.3 Find the Lady

In discussing the design of experiments, he uses another real-world example: At a scientific gathering, a lady declares that tea tastes different depending on whether the milk is poured into hot tea, or whether hot tea is poured into milk. On the spot, Fisher designs and executes an experiment to determine whether she can really taste the difference. It is said that this is a true story, and that the lady got nearly every test right.

3.4 From Soil Bacteria to Nonlinear Design

Many scientists visited Fisher for tea, and he became involved in their varied scientific pursuits, “often with dramatic consequences.” One such incidence of interest in another scientist's work lead to Fisher's pioneering work in nonlinear design.

3.5 From Cotton to Extreme Values

Another visitor to Rothamsted was concerned with cotton strength, which is limited by its weakest link. Work on this problem lead to a theory which has many different applications, and is considered its own field of study.

The rest of this section deals with work that Fisher did at Rothamsted and published in five volumes called “Studies in Crop Variation.”

3.6 From Dung to Orthogonal Polynomials and Residual Analysis

In “Studies in Crop Variation I” Fisher discusses the effect of different kinds of manure on crop yields. “In particular, he concludes that there is really nothing like plain dung.” Next, Fisher goes into the mathematical background which lead to his conclusions, wherein he introduces orthogonal polynomials and what we know call the analysis of variance or ANOVA. Box points out his discussion of residuals y-y(hat) as most interesting of all.

Box summarizes:
In the inferential stage, the analyst acts as a sponsor for the model. Conditional on the assumption of its truth he selects the best statistical procedures for analysis of the data. Having completed the analysis, however, he must switch his role from sponsor to critic.3 Conditional now on the contrary assumption that the model may be seriously faulty in one or more suspected or unsuspected ways he applies appropriate diagnostic checks, involving various kinds of residual analysis. (794)
Fisher then demonstrates mathematically that in order to maintain a small variance, one should use polynomials of smaller degree, an example of the value of parsimony. He also notes that extreme terms of the polynomial are greatly affected, which he calls “a weakness of the polynomial form” (794).

3.7 Weeds and the Education Acts

In the period of 1870--1880, wheat yields in all 13 fields were low, and not because of weather. These fields were weeded by young boys from a nearby school. Fisher implies an explanation of this low yield: "The Education Acts of 1876 and 1880 made attendance at school compulsory," (794) thus leaving the 13 fields choked with weeds and reducing yields. Note, however, that this wouldn't explain the low yields in the years prior to the first Education Act of 1876.

3.8 From Rainfall and Wheat Yield to Distributed Lags

In attempting to quantify the effect of rainfall on the 13 Broadbalk plots, Fisher was faced with too many regression factors (sunshine, soil nitrates, manure, weeding, etc) to produce a meaningful result. To get around this, he undertook a series of heavy calculations which we now call "distributed lag." Box points out Fisher's love of "parsimony" and notes that it may have been necessitated by Fisher's doing all this work by hand.

3.9 From Fertilizer and Potatoes to the Analysis of Variance

Fisher asks in “Studies in Crop Variation” whether there is an interaction between plant variety and fertilizer? Fisher does an analysis of variance (ANOVA). This may be Fisher's introduction of ANOVA. Fisher does the analysis of the plots incorrectly, but it gets corrected in the first edition of Statistical Methods.

3.10 Mice, Tigers, and Randomization

There's no mention of mice or tigers here, but it probably has to do with the earlier quote along the lines of “why bother with mice when there tigers about?” Box discusses (Fisher's?) table of a t-tests and Mann-Whitney tests on the same set of two samples of n=10 from a population of 1,000. The t-test is based on distributions and parameters, and the Mann-Whitney test is non-parametric. The point:

As is to be expected the significance level of the t-test is affected remarkably little by the drastic changes made in the marginal parent distribution-changes for which the distribution-free test provides insurance. Unfortunately, of course, both tests are equally impaired by error dependence unless randomization is introduced when they do about equally well. The point is, of course, that it is the act of randomization that is of major importance here not the introduction of the distribution-free test function.

The mice and tigers title suggests that one should worry about randomization (the tiger), not the type of test (the mouse).

3.11 From Muck Racking to Group Theory

Fisher had to apply special techniques to deal with a badly designed crop experiment. His friend William Gosset (of Student's t-test) suggested that he give them a hand in designing the next experiment, which Fisher did. Box uses this to illustrate the process of gathering existing data and using to create a preliminary experiment, then using data from that experiment to design a more statistically significant experiment to be carried out. This points out the shifting role of the statistician into a designer of experiments.

3.12 Evolution of the New Methods

Fisher came up with at least three tenets of good experimental design: “The need for randomization to achieve validity; for replication to provide a valid estimate of error; for blocking extraneous sources of disturbance to achieve accuracy.” This small section goes on to discuss something about blocking and Latin square. Box concludes: “However, while the efficiency of factorial designs could be increased by packing in more factors, larger factorial designs required bigger blocks and hence produced greater in-homogeneity in the experimental material, giving larger experimental errors. The answer which quickly followed was confounding.”

3.13 Persuading Practitioners

By 1924, Fisher had finally convinced those at Rothamsted to implement his ideas about how to improve experiment design. By 1929, “data were being collected from designs of great accuracy and beauty which included all of Fisher's ideas.” However, in 1926 the director of Rothamsted, Sir John Russell, published a paper about agricultural experimentation which ignored nearly all of Fisher's ideas about experiment design. Fisher responded by publishing a paper in the next issue of the same journal outlining his own ideas.

3.14 A New Heritage for Statisticians

Rothamsted hired Fisher to see if anything more could be learned from years of existing data. But Fisher redesigned his role to begin not after experiments were run, but before they were designed. The statistician's “responsibility to the scientific team was that of the architect with the crucial job of ensuring that the investigational structure of a brand new experiment was sound and economical” (797).

4 Perils of the Open Loop


Extraordinary progress can be made when theory turns to practice, and practice returns to theory. One must not remain for too long in either the realm of theory or the realm of practice.

4.1 Cookbookery and Mathematistry

“Cookbookery” is to fall into using routines, or recipies, by rote, without giving too much thought to their implementation or interpretation or analysis. The other end of the spectrum is “mathematistry,” when a mathematician takes practical ideas to too far into theory, losing practical relevance and scientific usefulness. Fisher was highly critical of mathematistry. Mathematistry may be harmless, except that it wastes the talents of those who might otherwise contribute to actual scientific progress. Or it may be harmful: Those who do not understand statistics may be overawed by mathematistry and may take its concepts too seriously, to the detriment of their experiments. A final danger of mathematistry is that too many statisticians will aspire to teach instead of practice. There should not be successive generations of statisticians without practical knowledge.

4.2 Meeting the Challenge

There will be an increasing need for competent statisticians.

4.3 Training of Statisticians

“A proper balance of theory and practice is needed and, most important, statisticians must learn how to be good scientists; a talent which has to be acquired by experience and example.” Fisher warns sternly against directing the most talented statisticians towards theory and away from practice.

5 Conclusion

Box concludes:

We may ask of Fisher: Was he an applied statistician? Was he a mathematical statistician? Was he a data analyst? Was he a designer of investigations?

It is surely because he was all of these that he was much more than the sum of the parts. He provides an example we can seek to follow.