<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:media="http://search.yahoo.com/mrss"
>

<channel>
	<title>robfelty.org &#187; linguistics</title>
	<atom:link href="http://robfelty.org/category/linguistics/feed" rel="self" type="application/rss+xml" />
	<link>http://robfelty.org</link>
	<description></description>
	<lastBuildDate>Sat, 05 Feb 2011 23:28:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Vim regex-fu for LaTeX</title>
		<link>http://robfelty.org/2009/09/24/vim-regexp-latex</link>
		<comments>http://robfelty.org/2009/09/24/vim-regexp-latex#comments</comments>
		<pubDate>Thu, 24 Sep 2009 16:34:50 +0000</pubDate>
		<dc:creator>robfelty</dc:creator>
				<category><![CDATA[latex]]></category>
		<category><![CDATA[linguistics]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[regular expressions]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://test.robfelty.org/?p=479</guid>
		<description><![CDATA[When writing a beamer presentation with LaTeX, I organize my presentation into sections and subsections. Frequently, the title of the first frame (slide) in a subsection has the same name as the subsection. Let&#8217;s say I start off with the &#8230; <a href="http://robfelty.org/2009/09/24/vim-regexp-latex">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>When writing a beamer presentation with LaTeX, I organize my presentation into sections and subsections. Frequently, the title of the first frame (slide) in a subsection has the same name as the subsection. Let&#8217;s say I start off with the following structure:</p>
<div class="codecolorer-container tex dawn" style="overflow:auto;white-space:nowrap;width:0"><div class="tex codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="re6">\section</span><span class="sy0">[</span><span class="re2">corpora</span><span class="sy0">]{</span><span class="re9">Accessing text corpora</span><span class="sy0">}</span><br />
<span class="re6">\subsection</span><span class="sy0">[</span><span class="re2">gutenberg</span><span class="sy0">]{</span><span class="re9">The Gutenberg Corpus</span><span class="sy0">}</span><br />
<span class="re6">\subsection</span><span class="sy0">[</span><span class="re2">chat</span><span class="sy0">]{</span><span class="re9">The web and chat Corpus</span><span class="sy0">}</span><br />
<span class="re6">\subsection</span><span class="sy0">[</span><span class="re2">brown</span><span class="sy0">]{</span><span class="re9">The Brown Corpus</span><span class="sy0">}</span><br />
<span class="re6">\subsection</span><span class="sy0">[</span><span class="re2">reuters</span><span class="sy0">]{</span><span class="re9">The Reuters Corpus</span><span class="sy0">}</span><br />
<span class="re6">\subsection</span><span class="sy0">[</span><span class="re2">inaugural</span><span class="sy0">]{</span><span class="re9">The Inaugural address Corpus</span><span class="sy0">}</span><br />
<span class="re6">\subsection</span><span class="sy0">[</span><span class="re2">annotated</span><span class="sy0">]{</span><span class="re9">Annotated corpora</span><span class="sy0">}</span><br />
<span class="re6">\subsection</span><span class="sy0">[</span><span class="re2">foreign</span><span class="sy0">]{</span><span class="re9">Corpora in other languages</span><span class="sy0">}</span><br />
<span class="re6">\subsection</span><span class="sy0">[</span><span class="re2">DIY</span><span class="sy0">]{</span><span class="re9">Loading your own corpora</span><span class="sy0">}</span></div></div>
<p>For each subsection, I want to put in one frame, with the name of the subsection being the name of the frame. Regular expressions to the rescue! In vim, all I have to is use <em>V</em> to select each line with <tt>subsection</tt>, then I hit <em>:</em>, which allows me to operate on those lines only.</p>
<div class="codecolorer-container text dawn" style="overflow:auto;white-space:nowrap;width:0"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">'&lt;,'&gt;</div></div>
<p>is automatically inserted after the colon, which stands for &#8220;from the beginning of the highlighted section to the end of it&#8221;. Then I use <em>s</em> to perform my substitution. <tt>\r</tt> inserts a new line.</p>
<div class="codecolorer-container vim dawn" style="overflow:auto;white-space:nowrap;width:0"><div class="vim codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="sy0">:</span><span class="st0">'&lt;,'</span><span class="sy0">&gt;</span>s<span class="sy0">/</span><span class="br0">&#123;</span>\<span class="br0">&#40;</span><span class="sy0">.*</span>\<span class="br0">&#41;</span><span class="br0">&#125;</span><span class="sy0">/</span><span class="br0">&#123;</span>\<span class="nu0">1</span><span class="br0">&#125;</span>\r\\begin<span class="br0">&#123;</span>frame<span class="br0">&#125;</span>\r\\frametitle<span class="sy0">&lt;</span>presentation<span class="sy0">&gt;</span><span class="br0">&#123;</span>\<span class="nu0">1</span><span class="br0">&#125;</span>\r\\<span class="kw1">end</span><span class="br0">&#123;</span>frame<span class="br0">&#125;</span><span class="sy0">/</span></div></div>
<p>The result is:</p>
<div class="codecolorer-container tex dawn" style="overflow:auto;white-space:nowrap;width:0"><div class="tex codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="re6">\section</span><span class="sy0">[</span><span class="re2">corpora</span><span class="sy0">]{</span><span class="re9">Accessing text corpora</span><span class="sy0">}</span><br />
<span class="re8">\begin</span><span class="sy0">{</span><span class="re9"><span class="re7">frame</span></span><span class="sy0">}</span><br />
<span class="re12">\frametitle</span>&lt;presentation&gt;<span class="sy0">{</span><span class="re9">Accessing text corpora</span><span class="sy0">}</span><br />
<span class="re8">\end</span><span class="sy0">{</span><span class="re9"><span class="re7">frame</span></span><span class="sy0">}</span><br />
<span class="re6">\subsection</span><span class="sy0">[</span><span class="re2">gutenberg</span><span class="sy0">]{</span><span class="re9">The Gutenberg Corpus</span><span class="sy0">}</span><br />
<span class="re8">\begin</span><span class="sy0">{</span><span class="re9"><span class="re7">frame</span></span><span class="sy0">}</span><br />
<span class="re12">\frametitle</span>&lt;presentation&gt;<span class="sy0">{</span><span class="re9">The Gutenberg Corpus</span><span class="sy0">}</span><br />
<span class="re8">\end</span><span class="sy0">{</span><span class="re9"><span class="re7">frame</span></span><span class="sy0">}</span><br />
<span class="re6">\subsection</span><span class="sy0">[</span><span class="re2">chat</span><span class="sy0">]{</span><span class="re9">The web and chat Corpus</span><span class="sy0">}</span><br />
<span class="re8">\begin</span><span class="sy0">{</span><span class="re9"><span class="re7">frame</span></span><span class="sy0">}</span><br />
<span class="re12">\frametitle</span>&lt;presentation&gt;<span class="sy0">{</span><span class="re9">The web and chat Corpus</span><span class="sy0">}</span><br />
<span class="re8">\end</span><span class="sy0">{</span><span class="re9"><span class="re7">frame</span></span><span class="sy0">}</span><br />
<span class="re6">\subsection</span><span class="sy0">[</span><span class="re2">brown</span><span class="sy0">]{</span><span class="re9">The Brown Corpus</span><span class="sy0">}</span><br />
<span class="re8">\begin</span><span class="sy0">{</span><span class="re9"><span class="re7">frame</span></span><span class="sy0">}</span><br />
<span class="re12">\frametitle</span>&lt;presentation&gt;<span class="sy0">{</span><span class="re9">The Brown Corpus</span><span class="sy0">}</span><br />
<span class="re8">\end</span><span class="sy0">{</span><span class="re9"><span class="re7">frame</span></span><span class="sy0">}</span><br />
<span class="re6">\subsection</span><span class="sy0">[</span><span class="re2">reuters</span><span class="sy0">]{</span><span class="re9">The Reuters Corpus</span><span class="sy0">}</span><br />
<span class="re8">\begin</span><span class="sy0">{</span><span class="re9"><span class="re7">frame</span></span><span class="sy0">}</span><br />
<span class="re12">\frametitle</span>&lt;presentation&gt;<span class="sy0">{</span><span class="re9">The Reuters Corpus</span><span class="sy0">}</span><br />
<span class="re8">\end</span><span class="sy0">{</span><span class="re9"><span class="re7">frame</span></span><span class="sy0">}</span><br />
<span class="re6">\subsection</span><span class="sy0">[</span><span class="re2">inaugural</span><span class="sy0">]{</span><span class="re9">The Inaugural address Corpus</span><span class="sy0">}</span><br />
<span class="re8">\begin</span><span class="sy0">{</span><span class="re9"><span class="re7">frame</span></span><span class="sy0">}</span><br />
<span class="re12">\frametitle</span>&lt;presentation&gt;<span class="sy0">{</span><span class="re9">The Inaugural address Corpus</span><span class="sy0">}</span><br />
<span class="re8">\end</span><span class="sy0">{</span><span class="re9"><span class="re7">frame</span></span><span class="sy0">}</span><br />
<span class="re6">\subsection</span><span class="sy0">[</span><span class="re2">annotated</span><span class="sy0">]{</span><span class="re9">Annotated corpora</span><span class="sy0">}</span><br />
<span class="re8">\begin</span><span class="sy0">{</span><span class="re9"><span class="re7">frame</span></span><span class="sy0">}</span><br />
<span class="re12">\frametitle</span>&lt;presentation&gt;<span class="sy0">{</span><span class="re9">Annotated corpora</span><span class="sy0">}</span><br />
<span class="re8">\end</span><span class="sy0">{</span><span class="re9"><span class="re7">frame</span></span><span class="sy0">}</span><br />
<span class="re6">\subsection</span><span class="sy0">[</span><span class="re2">foreign</span><span class="sy0">]{</span><span class="re9">Corpora in other languages</span><span class="sy0">}</span><br />
<span class="re8">\begin</span><span class="sy0">{</span><span class="re9"><span class="re7">frame</span></span><span class="sy0">}</span><br />
<span class="re12">\frametitle</span>&lt;presentation&gt;<span class="sy0">{</span><span class="re9">Corpora in other languages</span><span class="sy0">}</span><br />
<span class="re8">\end</span><span class="sy0">{</span><span class="re9"><span class="re7">frame</span></span><span class="sy0">}</span><br />
<span class="re6">\subsection</span><span class="sy0">[</span><span class="re2">DIY</span><span class="sy0">]{</span><span class="re9">Loading your own corpora</span><span class="sy0">}</span><br />
<span class="re8">\begin</span><span class="sy0">{</span><span class="re9"><span class="re7">frame</span></span><span class="sy0">}</span><br />
<span class="re12">\frametitle</span>&lt;presentation&gt;<span class="sy0">{</span><span class="re9">Loading your own corpora</span><span class="sy0">}</span><br />
<span class="re8">\end</span><span class="sy0">{</span><span class="re9"><span class="re7">frame</span></span><span class="sy0">}</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://robfelty.org/2009/09/24/vim-regexp-latex/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Why doesn&#8217;t Mac update standard UNIX utilities?</title>
		<link>http://robfelty.org/2008/09/15/why-doesnt-mac-update-standard-unix-utilities</link>
		<comments>http://robfelty.org/2008/09/15/why-doesnt-mac-update-standard-unix-utilities#comments</comments>
		<pubDate>Mon, 15 Sep 2008 15:49:29 +0000</pubDate>
		<dc:creator>robfelty</dc:creator>
				<category><![CDATA[linguistics]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mac osx]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[sed]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://test.robfelty.org/?p=131</guid>
		<description><![CDATA[I am currently teaching a course on programming for linguists. We are using python, but for the first few classes, I have been going over some standard UNIX utilities like cd, ls and such, plus using regular expressions with grep &#8230; <a href="http://robfelty.org/2008/09/15/why-doesnt-mac-update-standard-unix-utilities">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I am currently teaching a course on programming for linguists. We are using python, but for the first few classes, I have been going over some standard UNIX utilities like <tt>cd</tt>, <tt>ls</tt> and such, plus using regular expressions with <tt>grep</tt> and <tt>sed</tt>. I actually don&#8217;t use sed that much. I tend to reach for perl, since I know it better, and it can do pretty much all the same stuff that sed can plus much more. But sed is simpler than perl, and I basically just wanted to use it for doing substitutions. </p>
<p>Today I got an e-mail from a student asking why the following did not seem to be working:</p>
<div class="codecolorer-container bash dawn" style="overflow:auto;white-space:nowrap;width:0"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw3">echo</span> abcd123 <span class="sy0">|</span> <span class="kw2">sed</span> <span class="st_h">'s/\([a-z]*\).*/\U\1/'</span></div></div>
<p>The student reported the following output: &#8220;Uabcd&#8221;. (The expected output is &#8220;ABCD&#8221;, which is what I get on Linux)</p>
<p>I tried it, and it worked fine for me. Then I thought: maybe this is a Mac/Linux problem. Sure enough, when I look at the man page for my Fedora 7 box, it tells me that my version of sed is GNU 4.1.5, from June 2006. Mac Leopard (10.5) is using BSD sed from July 2004. Leopard came out in 2007, as did Fedora 7. Why is it 2 years behind? Why is it still using python 2.4? Why doesn&#8217;t it come with useful utilities like dos2unix? Mac has done a great job of making a nice GUI, with some pretty cool applications like iLife. It is falling behind when it comes to the command line utilities though. </p>
]]></content:encoded>
			<wfw:commentRss>http://robfelty.org/2008/09/15/why-doesnt-mac-update-standard-unix-utilities/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Bash one-liners to the rescue</title>
		<link>http://robfelty.org/2008/07/15/bash-one-liners-to-the-rescue</link>
		<comments>http://robfelty.org/2008/07/15/bash-one-liners-to-the-rescue#comments</comments>
		<pubDate>Tue, 15 Jul 2008 13:52:14 +0000</pubDate>
		<dc:creator>robfelty</dc:creator>
				<category><![CDATA[general]]></category>
		<category><![CDATA[linguistics]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[sox]]></category>
		<category><![CDATA[wav]]></category>

		<guid isPermaLink="false">http://test.robfelty.org/?p=103</guid>
		<description><![CDATA[I recently find myself using handy bash one-liners more all the time. I think that this is where unix/linux can really start to shine. There are so many little programs that just do one thing, and one thing well. But &#8230; <a href="http://robfelty.org/2008/07/15/bash-one-liners-to-the-rescue">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I recently find myself using handy bash one-liners more all the time. I think that this is where unix/linux can really start to shine. There are so many little programs that just do one thing, and one thing well. But the ability to combine these together through pipes means you have extremely flexible and powerful tools at the ready. </p>
<p>I have been working on a new project at work to come up with some lists for testing speech recognition. We decided to use the TIMIT database, which contains recordings of many different sentences from many different speakers all around America. I first wrote a perl script to generate some basic stats on the sentences, like how many words were in each sentence, and what the word frequency for those words is. Then I wrote a perl script to randomly select some of the sentences, and create several different lists of sentences. Finally, I wrote an R script which took the original .wav files, and mixed in signal-dependent noise in one channel, so that we can vary the signal to noise ratio during presentation of the stimuli by adjusting the balance on our sound system. </p>
<p>Along the way, I ran into a couple problems with the original sound files. It turns out that 446 of the 6300 sound files were clipped, and highly distorted. I noticed this on my own in listening to a few of the files I had generated with R. I could have gone through all 6300 files manually, and removed the distorted ones, but that would have taken a long time. Instead,  I used the program <em>sox</em>, which is a low-level, powerful audio processing program. I first used the find command to find all .wav files in the directory I was interested in (including sub-directories), then I passed each file to sox, and told sox not to play the output , but instead just give me some stats (-n stat). After some testing with a few clipped, and non-clipped files, I realized that for clipped files, the output from sox ended with a line that said either &#8220;Try: blah blah&#8221;, or &#8220;Can&#8217;t determine type&#8221;. I then later discovered that there might still be clipped files, and these would have a maximum amplitude of 1 or minimum or -1. So I knew that any clipped file would produce this output. So I passed the results from sox to grep (notice I had to redirect STDERR to STDOUT 2>&#038;1), and then if the output contained a line starting with  &#8220;Try:&#8221;  or &#8220;Can&#8217;t&#8221;, then I moved that file the $file.clipped.</p>
<div class="codecolorer-container bash dawn" style="overflow:auto;white-space:nowrap;width:0"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw1">for</span> <span class="kw2">file</span> <span class="kw1">in</span> <span class="sy0">`</span><span class="kw2">find</span> . <span class="re5">-name</span> <span class="st0">&quot;*.wav&quot;</span> -print<span class="sy0">`</span>; <span class="kw1">do</span> <br />
&nbsp; <span class="kw1">if</span> <span class="br0">&#91;</span><span class="br0">&#91;</span> <span class="sy0">`</span><span class="kw2">sox</span> <span class="re1">$file</span> <span class="re5">-n</span> <span class="kw2">stat</span> <span class="nu0">2</span><span class="sy0">&gt;&amp;</span><span class="nu0">1</span> <span class="sy0">|</span> <span class="kw2">grep</span> <span class="re5">-E</span> <span class="st0">&quot;^(Try:|Can't|(Minimum|Maximum) amplitude:\s+-?1\.00)&quot;</span><span class="sy0">`</span> <span class="br0">&#93;</span><span class="br0">&#93;</span>; <span class="kw1">then</span><br />
&nbsp; &nbsp; <span class="kw3">echo</span> <span class="st0">&quot;<span class="es2">$file</span> CLIPPED&quot;</span>; <br />
&nbsp; &nbsp; <span class="kw2">mv</span> <span class="re1">$file</span> <span class="re1">$file</span>.clipped; <br />
&nbsp; <span class="kw1">fi</span>; <br />
<span class="kw1">done</span></div></div>
<p>After doing this, I simply amended my perl script which randomly generated lists to make sure that the wav file actually existed. Clipped files now ended in .clipped, instead of .wav.</p>
<p>There was an additional problem I had previously discovered with these sound files. They seemed to have some non-standard headers in them, which meant that the R script I was using to add noise to them couldn&#8217;t read the files. However, passing the files through sox made the files readable by R. (Windows Media Player on a Windows box couldn&#8217;t read the files either.) I only wanted to process the files I was actually going to add noise to, so I used another handy little bash one-liner. This one cuts a column of the file which contains all the sentences I am going to use, and then for each filename, processes the file through sox, and outputs it to the destination directory of my choosing.</p>
<div class="codecolorer-container bash dawn" style="overflow:auto;white-space:nowrap;width:0"><div class="bash codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="kw1">for</span> <span class="kw2">file</span> <span class="kw1">in</span> <span class="sy0">`</span><span class="kw2">cut</span> <span class="re5">-f</span> <span class="nu0">18</span> <span class="re5">-d</span> $<span class="st_h">'\t'</span> timitLists2.txt<span class="sy0">`</span>; <br />
&nbsp; <span class="kw1">do</span> <span class="kw2">sox</span> <span class="re1">$file</span> ~<span class="sy0">/</span>R<span class="sy0">/</span>work<span class="sy0">/</span>timit<span class="sy0">/</span>clean<span class="sy0">/`</span><span class="kw2">basename</span> <span class="re1">$file</span><span class="sy0">`</span>; <br />
<span class="kw1">done</span></div></div>
<p>Note that I have expanded the code into one more line, but pretty much they are one-liners. I think technically a one-liner doesn&#8217;t involve successive commands, which the first example does, but the first command is just an echo, to make sure I know what it is doing. </p>
]]></content:encoded>
			<wfw:commentRss>http://robfelty.org/2008/07/15/bash-one-liners-to-the-rescue/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Working on making fancy graphs with R / fixed versus random babble</title>
		<link>http://robfelty.org/2008/04/03/working-on-making-fancy-graphs-with-r-fixed-versus-random-babble</link>
		<comments>http://robfelty.org/2008/04/03/working-on-making-fancy-graphs-with-r-fixed-versus-random-babble#comments</comments>
		<pubDate>Fri, 04 Apr 2008 02:26:10 +0000</pubDate>
		<dc:creator>robfelty</dc:creator>
				<category><![CDATA[linguistics]]></category>
		<category><![CDATA[babble]]></category>
		<category><![CDATA[bar chart]]></category>
		<category><![CDATA[figures]]></category>
		<category><![CDATA[graphs]]></category>
		<category><![CDATA[noise]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[S-plus]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[speech science]]></category>
		<category><![CDATA[spoken word recognition]]></category>
		<category><![CDATA[statistics]]></category>

		<guid isPermaLink="false">http://test.robfelty.org/?p=87</guid>
		<description><![CDATA[I have been working on learning R for several months now, and continue to get better at it and enjoy it more all the time. I am currently working on a spoken word recognition project at work. The task we &#8230; <a href="http://robfelty.org/2008/04/03/working-on-making-fancy-graphs-with-r-fixed-versus-random-babble">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I have been working on learning R for several months now, and continue to get better at it and enjoy it more all the time. I am currently working on a spoken word recognition project at work. The task we are using is quite simple. Participants listen to words that have been mixed with multi-talker babble (kind of like background conversation at a cocktail party), and type in what they hear. We are analyzing the errors they make to try to discover what sorts of words are activated in the brain, and how people organize the words they know in their brains. </p>
<p>We started running subjects in the summer of 2007, and after running 48 subjects, we made a few methodological changes. One change is that we switched from using the same segment of babble as background noise to using a random segment of babble. We also re-leveled the sound files after adding the babble so that all the words were presented at about the same volume. I recently analyzed the data from these two groups. It turns out the the results from the first 48 subjects performed significantly better than subjects 49-96. However, I realized that these are different subjects, so it could be due to the different subjects, and not the change in methods. Therefore I split each group into 2 subgroups. Now I had 4 groups &#8212; 1-24, 24-48, 49-72, and 73-96. The subgroups did not differ statistically from one another, but the main groups did. This seemed to indicate that listeners were becoming habituated to the noise, and could therefore tune it out a bit better, and thus hear the words better. </p>
<p>I originally displayed this in a table, but it was pretty cumbersome, so I decided to make a bar chart instead. I have seen some people produce bar charts such as these where they indicate which groups are statistically different using brackets to group bars, and an asterisk to mark them as statistically different. I also wanted to add error bars in. Adam Krawitz (another post-doc at IU) gave me some code to get started on the error bars, and I found some code from a post to the R-help list about making brackets. First here is the figure:<br />
<a href='http://test.robfelty.org/wp-content/uploads/2008/04/48v96.png'><img src="http://test.robfelty.org/wp-content/uploads/2008/04/48v96-300x209.png" alt="R plot using the Brack function with error bars and statistics displayed" title="R plot using the Brack function with error bars and statistics displayed" width="300" height="209" class="aligncenter size-medium wp-image-89" /></a><br />
And here is the code:</p>
<div class="codecolorer-container r dawn" style="overflow:auto;white-space:nowrap;width:0"><div class="r codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="co0"># make a nice bar plot</span><br />
<span class="co0"># first we find the mean of each group</span><br />
bardata <span class="sy0">&lt;</span>- c<span class="br0">&#40;</span>mean<span class="br0">&#40;</span>items1to24<span class="re1">$pc</span>,na.rm=T<span class="br0">&#41;</span>,<br />
&nbsp; mean<span class="br0">&#40;</span>items25to48<span class="re1">$pc</span>,na.rm=T<span class="br0">&#41;</span>,<br />
&nbsp; mean<span class="br0">&#40;</span>items49to72<span class="re1">$pc</span>,na.rm=T<span class="br0">&#41;</span>,<br />
&nbsp; mean<span class="br0">&#40;</span>items73to96<span class="re1">$pc</span>,na.rm=T<span class="br0">&#41;</span><br />
<span class="br0">&#41;</span><br />
<br />
<span class="co0">#Then we do t-tests to calculate the 95% confidence intervals for our error bars</span><br />
<span class="re2">items1to24T</span>=t.test<span class="br0">&#40;</span>items1to24<span class="re1">$pc</span><span class="br0">&#41;</span><br />
<span class="re2">items25to48T</span>=t.test<span class="br0">&#40;</span>items25to48<span class="re1">$pc</span><span class="br0">&#41;</span><br />
<span class="re2">items49to72T</span>=t.test<span class="br0">&#40;</span>items49to72<span class="re1">$pc</span><span class="br0">&#41;</span><br />
<span class="re2">items73to96T</span>=t.test<span class="br0">&#40;</span>items73to96<span class="re1">$pc</span><span class="br0">&#41;</span><br />
<span class="re2">lowerConf</span>=c<span class="br0">&#40;</span>items1to24T<span class="re1">$conf</span>.int<span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span>,<br />
&nbsp; items25to48T<span class="re1">$conf</span>.int<span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span>,<br />
&nbsp; items49to72T<span class="re1">$conf</span>.int<span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span>,<br />
&nbsp; items73to96T<span class="re1">$conf</span>.int<span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span><br />
<span class="br0">&#41;</span><br />
<span class="re2">upperConf</span>=c<span class="br0">&#40;</span>items1to24T<span class="re1">$conf</span>.int<span class="br0">&#91;</span><span class="nu0">2</span><span class="br0">&#93;</span>,<br />
&nbsp; items25to48T<span class="re1">$conf</span>.int<span class="br0">&#91;</span><span class="nu0">2</span><span class="br0">&#93;</span>,<br />
&nbsp; items49to72T<span class="re1">$conf</span>.int<span class="br0">&#91;</span><span class="nu0">2</span><span class="br0">&#93;</span>,<br />
&nbsp; items73to96T<span class="re1">$conf</span>.int<span class="br0">&#91;</span><span class="nu0">2</span><span class="br0">&#93;</span><br />
<span class="br0">&#41;</span><br />
<br />
<span class="co0"># we set up some nice colors</span><br />
<span class="re2">barcolors</span>=c<span class="br0">&#40;</span><span class="st_h">'#FF3333'</span>,<span class="st_h">'#FF3333'</span>,<span class="st_h">'#4444FF'</span>,<span class="st_h">'#4444FF'</span><span class="br0">&#41;</span><br />
bar <span class="sy0">&lt;</span>- barplot<span class="br0">&#40;</span>bardata, ylim = c<span class="br0">&#40;</span><span class="nu0">0</span>,<span class="nu0">1</span><span class="br0">&#41;</span>, <span class="re2"><span class="kw2">col</span></span>=barcolors, names.arg=c<span class="br0">&#40;</span><span class="st0">&quot;1-24&quot;</span>,<span class="st0">&quot;25-48&quot;</span>,<span class="st0">&quot;49-72&quot;</span>, <span class="st0">&quot;73-96&quot;</span><span class="br0">&#41;</span>,<span class="re2">ylab</span>=<span class="st_h">'proportion correct'</span>, <span class="re2">xlab</span>=<span class="st_h">'subject group'</span>,<span class="re2">xlim</span>=c<span class="br0">&#40;</span><span class="nu0">0</span>,<span class="nu0">1</span><span class="br0">&#41;</span>, <span class="re2">width</span>=.24,<span class="re2">tck</span>=.04<span class="br0">&#41;</span><br />
<span class="co0">#we use the arrows function to do the error bars</span><br />
arrows<span class="br0">&#40;</span>bar, upperConf, bar, lowerConf,<br />
&nbsp; &nbsp; &nbsp; &nbsp;length = <span class="nu0">0.05</span>, <span class="co0"># width of the arrowhead</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;angle = <span class="nu0">90</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp;code = <span class="nu0">3</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#41;</span><br />
<br />
<br />
<span class="co0"># function to draw curly braces in red</span><br />
<span class="co0"># x1...y2 are the ends of the brace</span><br />
<span class="co0"># for upside down braces, x1 &gt; x2 and y1 &gt; y2</span><br />
<span class="co0"># taken from R help</span><br />
<span class="co0"># http://finzi.psych.upenn.edu/R/Rhelp02a/archive/112010.html</span><br />
library<span class="br0">&#40;</span>grid<span class="br0">&#41;</span> <span class="co0">#requires the grid library</span><br />
Brack <span class="sy0">&lt;</span>- <span class="kw1">function</span><span class="br0">&#40;</span>x1,y1,x2,y2,h<span class="br0">&#41;</span><br />
<span class="br0">&#123;</span><br />
x2 <span class="sy0">&lt;</span>- x2-x1; y2 <span class="sy0">&lt;</span>- y2-y1<br />
v1 <span class="sy0">&lt;</span>- viewport<span class="br0">&#40;</span><span class="re2">x</span>=x1,<span class="re2">y</span>=y1,<span class="re2">width</span>=sqrt<span class="br0">&#40;</span>x2^<span class="nu0">2</span>+y2^<span class="nu0">2</span><span class="br0">&#41;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="re2">height</span>=h,<span class="re2">angle</span>=<span class="nu0">180</span><span class="sy0">*</span>atan2<span class="br0">&#40;</span>y2,x2<span class="br0">&#41;</span><span class="sy0">/</span>pi,<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span class="re2">just</span>=c<span class="br0">&#40;</span><span class="st0">&quot;left&quot;</span>,<span class="st0">&quot;bottom&quot;</span><span class="br0">&#41;</span>,<span class="re2">gp</span>=gpar<span class="br0">&#40;</span><span class="re2"><span class="kw2">col</span></span>=<span class="st0">&quot;black&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><br />
pushViewport<span class="br0">&#40;</span>v1<span class="br0">&#41;</span><br />
grid.curve<span class="br0">&#40;</span><span class="re2">x2</span>=<span class="nu0">0</span>,<span class="re2">y2</span>=<span class="nu0">0</span>,<span class="re2">x1</span>=.125,<span class="re2">y1</span>=.5,<span class="re2">curvature</span>=.5<span class="br0">&#41;</span><br />
grid.move.to<span class="br0">&#40;</span>.125,.5<span class="br0">&#41;</span><br />
grid.line.to<span class="br0">&#40;</span>.375,.5<span class="br0">&#41;</span><br />
grid.curve<span class="br0">&#40;</span><span class="re2">x1</span>=.375,<span class="re2">y1</span>=.5,<span class="re2">x2</span>=.5,<span class="re2">y2</span>=<span class="nu0">1</span>,<span class="re2">curvature</span>=.5<span class="br0">&#41;</span><br />
grid.curve<span class="br0">&#40;</span><span class="re2">x2</span>=<span class="nu0">1</span>,<span class="re2">y2</span>=<span class="nu0">0</span>,<span class="re2">x1</span>=.875,<span class="re2">y1</span>=.5,<span class="re2">curvature</span>=-.5<span class="br0">&#41;</span><br />
grid.move.to<span class="br0">&#40;</span>.875,.5<span class="br0">&#41;</span><br />
grid.line.to<span class="br0">&#40;</span>.625,.5<span class="br0">&#41;</span><br />
grid.curve<span class="br0">&#40;</span><span class="re2">x2</span>=.625,<span class="re2">y2</span>=.5,<span class="re2">x1</span>=.5,<span class="re2">y1</span>=<span class="nu0">1</span>,<span class="re2">curvature</span>=.5<span class="br0">&#41;</span><br />
popViewport<span class="br0">&#40;</span><span class="br0">&#41;</span><br />
<span class="br0">&#125;</span><br />
<br />
<span class="co0"># Now we use the brack function </span><br />
<span class="co0"># brackY1 and brack Y2 determine the y-value for the placement of the brackets. </span><br />
<span class="co0"># I had to fudge this a bit to get it to look right</span><br />
<span class="re2">brackY1</span>=<span class="nu0">1.05</span><span class="sy0">*</span>max<span class="br0">&#40;</span>upperConf<span class="br0">&#91;</span><span class="nu0">1</span>:<span class="nu0">2</span><span class="br0">&#93;</span><span class="br0">&#41;</span><br />
<span class="re2">brackY2</span>=<span class="nu0">1.21</span><span class="sy0">*</span>max<span class="br0">&#40;</span>upperConf<span class="br0">&#91;</span><span class="nu0">3</span>:<span class="nu0">4</span><span class="br0">&#93;</span><span class="br0">&#41;</span><br />
Brack<span class="br0">&#40;</span>bar<span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span>+.07,brackY1,bar<span class="br0">&#91;</span><span class="nu0">2</span><span class="br0">&#93;</span>-.01,brackY1,.07<span class="br0">&#41;</span><br />
Brack<span class="br0">&#40;</span>bar<span class="br0">&#91;</span><span class="nu0">3</span><span class="br0">&#93;</span>-.09,brackY2,bar<span class="br0">&#91;</span><span class="nu0">4</span><span class="br0">&#93;</span>-.17,brackY2,.11<span class="br0">&#41;</span><br />
<br />
<span class="co0"># And now we also make some straight line groupings</span><br />
arrows<span class="br0">&#40;</span>mean<span class="br0">&#40;</span>bar<span class="br0">&#91;</span><span class="nu0">1</span>:<span class="nu0">2</span><span class="br0">&#93;</span><span class="br0">&#41;</span>,<span class="nu0">1.4</span><span class="sy0">*</span>upperConf<span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span>,mean<span class="br0">&#40;</span>bar<span class="br0">&#91;</span><span class="nu0">3</span>:<span class="nu0">4</span><span class="br0">&#93;</span><span class="br0">&#41;</span>, <span class="nu0">1.4</span><span class="sy0">*</span>upperConf<span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span>,<span class="re2">length</span>=<span class="nu0">0</span><span class="br0">&#41;</span><br />
arrows<span class="br0">&#40;</span>mean<span class="br0">&#40;</span>bar<span class="br0">&#91;</span><span class="nu0">1</span>:<span class="nu0">2</span><span class="br0">&#93;</span><span class="br0">&#41;</span>,<span class="nu0">1.4</span><span class="sy0">*</span>upperConf<span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span>,mean<span class="br0">&#40;</span>bar<span class="br0">&#91;</span><span class="nu0">1</span>:<span class="nu0">2</span><span class="br0">&#93;</span><span class="br0">&#41;</span>, <span class="nu0">1.35</span><span class="sy0">*</span>upperConf<span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span>,<span class="re2">length</span>=<span class="nu0">0</span><span class="br0">&#41;</span><br />
arrows<span class="br0">&#40;</span>mean<span class="br0">&#40;</span>bar<span class="br0">&#91;</span><span class="nu0">3</span>:<span class="nu0">4</span><span class="br0">&#93;</span><span class="br0">&#41;</span>,<span class="nu0">1.4</span><span class="sy0">*</span>upperConf<span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span>,mean<span class="br0">&#40;</span>bar<span class="br0">&#91;</span><span class="nu0">3</span>:<span class="nu0">4</span><span class="br0">&#93;</span><span class="br0">&#41;</span>, <span class="nu0">1.35</span><span class="sy0">*</span>upperConf<span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span>,<span class="re2">length</span>=<span class="nu0">0</span><span class="br0">&#41;</span><br />
arrows<span class="br0">&#40;</span>mean<span class="br0">&#40;</span>bar<span class="br0">&#91;</span><span class="nu0">2</span>:<span class="nu0">3</span><span class="br0">&#93;</span><span class="br0">&#41;</span>,<span class="nu0">1.4</span><span class="sy0">*</span>upperConf<span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span>,mean<span class="br0">&#40;</span>bar<span class="br0">&#91;</span><span class="nu0">2</span>:<span class="nu0">3</span><span class="br0">&#93;</span><span class="br0">&#41;</span>, <span class="nu0">1.45</span><span class="sy0">*</span>upperConf<span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span>,<span class="re2">length</span>=<span class="nu0">0</span><span class="br0">&#41;</span><br />
<span class="co0"># we label the groupings</span><br />
text<span class="br0">&#40;</span>mean<span class="br0">&#40;</span>bar<span class="br0">&#91;</span><span class="nu0">1</span>:<span class="nu0">2</span><span class="br0">&#93;</span><span class="br0">&#41;</span>,<span class="nu0">1.25</span><span class="sy0">*</span>upperConf<span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span>,<span class="st0">&quot;fixed babble&quot;</span>,<span class="re2">cex</span>=.9,<span class="re2"><span class="kw2">col</span></span>=barcolors<span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span><span class="br0">&#41;</span><br />
text<span class="br0">&#40;</span>mean<span class="br0">&#40;</span>bar<span class="br0">&#91;</span><span class="nu0">3</span>:<span class="nu0">4</span><span class="br0">&#93;</span><span class="br0">&#41;</span>,<span class="nu0">1.25</span><span class="sy0">*</span>upperConf<span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span>,<span class="st0">&quot;random babble&quot;</span>,<span class="re2">cex</span>=.9,<span class="re2"><span class="kw2">col</span></span>=barcolors<span class="br0">&#91;</span><span class="nu0">3</span><span class="br0">&#93;</span><span class="br0">&#41;</span><br />
<br />
<span class="co0"># we add the stats in</span><br />
text<span class="br0">&#40;</span>mean<span class="br0">&#40;</span>bar<span class="br0">&#91;</span><span class="nu0">2</span>:<span class="nu0">3</span><span class="br0">&#93;</span><span class="br0">&#41;</span>,<span class="nu0">1.55</span><span class="sy0">*</span>upperConf<span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span>,paste<span class="br0">&#40;</span><span class="st0">&quot;t =&quot;</span>, formatC<span class="br0">&#40;</span>itemBetweenT<span class="re1">$statistic</span>,<span class="re2">digits</span>=<span class="nu0">3</span><span class="br0">&#41;</span>, <span class="st0">&quot;, p&quot;</span>, prettyPval<span class="br0">&#40;</span>itemBetweenT<span class="re1">$p</span>.value<span class="br0">&#41;</span><span class="br0">&#41;</span>,<span class="re2">cex</span>=.9<span class="br0">&#41;</span><br />
<br />
<span class="co0"># and we add the values on the bars as well</span><br />
text<span class="br0">&#40;</span>bar<span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span>,.7<span class="sy0">*</span>bardata<span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span>,formatC<span class="br0">&#40;</span>bardata<span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span>,<span class="re2">digits</span>=<span class="nu0">3</span><span class="br0">&#41;</span>,<span class="re2"><span class="kw2">col</span></span>=<span class="st_h">'white'</span><span class="br0">&#41;</span><br />
text<span class="br0">&#40;</span>bar<span class="br0">&#91;</span><span class="nu0">2</span><span class="br0">&#93;</span>,.7<span class="sy0">*</span>bardata<span class="br0">&#91;</span><span class="nu0">2</span><span class="br0">&#93;</span>,formatC<span class="br0">&#40;</span>bardata<span class="br0">&#91;</span><span class="nu0">2</span><span class="br0">&#93;</span>,<span class="re2">digits</span>=<span class="nu0">3</span><span class="br0">&#41;</span>,<span class="re2"><span class="kw2">col</span></span>=<span class="st_h">'white'</span><span class="br0">&#41;</span><br />
text<span class="br0">&#40;</span>bar<span class="br0">&#91;</span><span class="nu0">3</span><span class="br0">&#93;</span>,.7<span class="sy0">*</span>bardata<span class="br0">&#91;</span><span class="nu0">3</span><span class="br0">&#93;</span>,formatC<span class="br0">&#40;</span>bardata<span class="br0">&#91;</span><span class="nu0">3</span><span class="br0">&#93;</span>,<span class="re2">digits</span>=<span class="nu0">3</span><span class="br0">&#41;</span>,<span class="re2"><span class="kw2">col</span></span>=<span class="st_h">'white'</span><span class="br0">&#41;</span><br />
text<span class="br0">&#40;</span>bar<span class="br0">&#91;</span><span class="nu0">4</span><span class="br0">&#93;</span>,.7<span class="sy0">*</span>bardata<span class="br0">&#91;</span><span class="nu0">4</span><span class="br0">&#93;</span>,formatC<span class="br0">&#40;</span>bardata<span class="br0">&#91;</span><span class="nu0">4</span><span class="br0">&#93;</span>,<span class="re2">digits</span>=<span class="nu0">3</span><span class="br0">&#41;</span>,<span class="re2"><span class="kw2">col</span></span>=<span class="st_h">'white'</span><span class="br0">&#41;</span><br />
<br />
<span class="co0"># and then I print it to a pdf file</span><br />
dev.print<span class="br0">&#40;</span>pdf,<span class="st0">&quot;fig/48v96.pdf&quot;</span>,<span class="re2">height</span>=<span class="nu0">2.8</span>,<span class="re2">width</span>=<span class="nu0">4</span>,<span class="re2">pointsize</span>=<span class="nu0">11</span><span class="br0">&#41;</span></div></div>
<p>While these results were suggestive of a difference, it is also possible that the difference was due to the re-leveling, and not the fixed vs. random babble. If the listeners were really habituating to the fixed babble, this should show up as an improvement over the course of the experiment. Therefore I also compared the learning rates of these two groups. It is normal for participants to get better as they get more familiar with a task, so we will always expect some learning. However if the participants are becoming habituated to a particular aspect of the stimuli, (in this case the fact that the same segment of babble is being used over and over again), then we would expect more learning in this group. This figure displays the percent correct over a moving 30 trial window. That is, the first point represents trials 1-30, the second point 2-31 and so on. It looks like the fixed-babble group is learning more. To test this statistically, I subtracted the fixed babble values from the random babble values, and performed a correlation on these values against the trial window. If the learning rates are the same, then there should be no correlation. If the fixed babble group is learning more rapidly however, we should see the difference between the two groups increase over the course of the experiment, which is what we found. Here is the nice figure:<br />
<a href='http://test.robfelty.org/wp-content/uploads/2008/04/learning.png'><img src="http://test.robfelty.org/wp-content/uploads/2008/04/learning-300x209.png" alt="R figure with multiple y axes" title="R figure with multiple y axes" width="300" height="209" class="aligncenter size-medium wp-image-90" /></a><br />
And here is the code:</p>
<div class="codecolorer-container r dawn" style="overflow:auto;white-space:nowrap;width:0"><div class="r codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="co0">#compute the percent correct for each window</span><br />
<span class="re2">numPoints</span>=min<span class="br0">&#40;</span>length<span class="br0">&#40;</span>unique<span class="br0">&#40;</span>Trials1<span class="re1">$Trial</span><span class="br0">&#41;</span><span class="br0">&#41;</span>,length<span class="br0">&#40;</span>unique<span class="br0">&#40;</span>Trials1<span class="re1">$Trial</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span>-trialWindow<br />
&nbsp; <span class="re2">pc1</span>=c<span class="br0">&#40;</span><span class="nu0">1</span>:numPoints<span class="br0">&#41;</span><br />
&nbsp; <span class="re2">pc2</span>=c<span class="br0">&#40;</span><span class="nu0">1</span>:numPoints<span class="br0">&#41;</span><br />
&nbsp; <span class="re2">xvalues</span>=c<span class="br0">&#40;</span><span class="nu0">1</span>:numPoints<span class="br0">&#41;</span><br />
&nbsp; <span class="kw1">for</span> <span class="br0">&#40;</span>i <span class="kw1">in</span> <span class="nu0">0</span>:numPoints<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="re2">upperTrials1</span>=subset<span class="br0">&#40;</span>Trials1,Trials1<span class="re1">$Trial</span><span class="sy0">&gt;</span>i<span class="br0">&#41;</span><br />
&nbsp; &nbsp; <span class="re2">theseTrials1</span>=subset<span class="br0">&#40;</span>upperTrials1,upperTrials1<span class="re1">$Trial</span><span class="sy0">&lt;</span>=i+trialWindow<span class="br0">&#41;</span><br />
&nbsp; &nbsp; corr1 = <span class="br0">&#40;</span>nrow<span class="br0">&#40;</span>subset<span class="br0">&#40;</span>theseTrials1, theseTrials1<span class="re1">$correct</span>==<span class="st0">&quot;CORRECT&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; wrong1 = <span class="br0">&#40;</span>nrow<span class="br0">&#40;</span>subset<span class="br0">&#40;</span>theseTrials1,theseTrials1<span class="re1">$correct</span>==<span class="st0">&quot;WRONG&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; missing1 = <span class="br0">&#40;</span>nrow<span class="br0">&#40;</span>subset<span class="br0">&#40;</span>theseTrials1,theseTrials1<span class="re1">$correct</span>==<span class="st0">&quot;MISSING&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; nonword1 = <span class="br0">&#40;</span>nrow<span class="br0">&#40;</span>subset<span class="br0">&#40;</span>theseTrials1,theseTrials1<span class="re1">$correct</span>==<span class="st0">&quot;NONWORD&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; pc1<span class="br0">&#91;</span>i<span class="br0">&#93;</span> = corr1<span class="sy0">/</span><span class="br0">&#40;</span>corr1+wrong1+nonword1+missing1<span class="br0">&#41;</span><br />
<br />
&nbsp; &nbsp; <span class="re2">upperTrials2</span>=subset<span class="br0">&#40;</span>Trials2,Trials2<span class="re1">$Trial</span><span class="sy0">&gt;</span>i<span class="br0">&#41;</span><br />
&nbsp; &nbsp; <span class="re2">theseTrials2</span>=subset<span class="br0">&#40;</span>upperTrials2,upperTrials2<span class="re1">$Trial</span><span class="sy0">&lt;</span>=i+trialWindow<span class="br0">&#41;</span><br />
&nbsp; &nbsp; corr2 = <span class="br0">&#40;</span>nrow<span class="br0">&#40;</span>subset<span class="br0">&#40;</span>theseTrials2, theseTrials2<span class="re1">$correct</span>==<span class="st0">&quot;CORRECT&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; wrong2 = <span class="br0">&#40;</span>nrow<span class="br0">&#40;</span>subset<span class="br0">&#40;</span>theseTrials2,theseTrials2<span class="re1">$correct</span>==<span class="st0">&quot;WRONG&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; missing2 = <span class="br0">&#40;</span>nrow<span class="br0">&#40;</span>subset<span class="br0">&#40;</span>theseTrials2,theseTrials2<span class="re1">$correct</span>==<span class="st0">&quot;MISSING&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; nonword2 = <span class="br0">&#40;</span>nrow<span class="br0">&#40;</span>subset<span class="br0">&#40;</span>theseTrials2,theseTrials2<span class="re1">$correct</span>==<span class="st0">&quot;NONWORD&quot;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp; pc2<span class="br0">&#91;</span>i<span class="br0">&#93;</span> = corr2<span class="sy0">/</span><span class="br0">&#40;</span>corr2+wrong2+nonword2+missing2<span class="br0">&#41;</span><br />
<br />
&nbsp; &nbsp; xvalues<span class="br0">&#91;</span>i<span class="br0">&#93;</span>=i;<br />
&nbsp; <span class="br0">&#125;</span><br />
<span class="co0"># compute the differences between the two groups</span><br />
<span class="re2">diffs</span>=pc1-pc2<br />
<br />
<span class="co0">#set up some graphical paramets</span><br />
&nbsp; &nbsp; par<span class="br0">&#40;</span><span class="re2">mar</span>=c<span class="br0">&#40;</span><span class="nu0">3</span>,<span class="nu0">3</span>,<span class="nu0">0.3</span>,<span class="nu0">3</span><span class="br0">&#41;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re2">fin</span>=c<span class="br0">&#40;</span><span class="nu0">4.1</span>,<span class="nu0">2.9</span><span class="br0">&#41;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re2">fig</span>=c<span class="br0">&#40;</span><span class="nu0">0</span>,<span class="nu0">1</span>,<span class="nu0">0</span>,<span class="nu0">1</span><span class="br0">&#41;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re2">mgp</span>=c<span class="br0">&#40;</span><span class="nu0">2</span>,<span class="nu0">1</span>,<span class="nu0">0</span><span class="br0">&#41;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co0">#usr=c(min(xdata),max(xdata),0,1),</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re2">lab</span>=c<span class="br0">&#40;</span><span class="nu0">10</span>,<span class="nu0">10</span>,<span class="nu0">3</span><span class="br0">&#41;</span>,<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="co0">#ps=11,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re2">family</span>=<span class="st_h">'serif'</span><br />
&nbsp; &nbsp; &nbsp; &nbsp;<span class="br0">&#41;</span><br />
<span class="co0"># plot the first group</span><br />
plot<span class="br0">&#40;</span>xvalues,pc1,<span class="re2"><span class="kw2">col</span></span>=<span class="st_h">'#EE0000'</span>,<span class="re2">pch</span>=<span class="st0">&quot;+&quot;</span>,<span class="re2">ylim</span>=c<span class="br0">&#40;</span>.4,.65<span class="br0">&#41;</span>,<span class="re2">axes</span>=F,<span class="re2">xlab</span>=<span class="st_h">'trial window'</span>, <span class="re2">ylab</span>=<span class="st_h">'proportion correct'</span>,<span class="re2">cex</span>=.8<span class="br0">&#41;</span><br />
<span class="co0"># add the second group</span><br />
points<span class="br0">&#40;</span>xvalues,pc2,<span class="re2"><span class="kw2">col</span></span>=<span class="st_h">'#0000EE'</span>,<span class="re2">pch</span>=<span class="st0">&quot;x&quot;</span>,<span class="re2">ylim</span>=c<span class="br0">&#40;</span>.4,.65<span class="br0">&#41;</span>,<span class="re2">cex</span>=.8<span class="br0">&#41;</span><br />
<br />
<span class="co0"># how much to add to the fitline y values to make it fit on the plot</span><br />
<span class="re2">fudge</span>=.42<br />
<span class="co0"># plot the slope of the line we fitted to the differences</span><br />
<span class="re2">fitline</span>=lsfit<span class="br0">&#40;</span>xvalues,diffs+fudge<span class="br0">&#41;</span><br />
abline<span class="br0">&#40;</span>fitline,<span class="re2"><span class="kw2">col</span></span>=<span class="st_h">'#000F00'</span><span class="br0">&#41;</span><br />
<span class="co0"># do a correlation test</span><br />
<span class="re2">slope</span>=cor.test<span class="br0">&#40;</span>xvalues,diffs<span class="br0">&#41;</span>;<br />
<span class="co0"># the stats to put on the graph</span><br />
<span class="re2">stats</span>=paste<span class="br0">&#40;</span><span class="st_h">'r= '</span>, formatC<span class="br0">&#40;</span>slope<span class="re1">$estimate</span>,<span class="re2">digits</span>=<span class="nu0">3</span><span class="br0">&#41;</span>, <span class="st0">&quot;, p &quot;</span>, prettyPval<span class="br0">&#40;</span>slope<span class="re1">$p</span>.value<span class="br0">&#41;</span>,<span class="re2">sep</span>=<span class="st_h">''</span><span class="br0">&#41;</span><br />
<br />
<span class="co0"># put the values on the axes</span><br />
axis<span class="br0">&#40;</span><span class="nu0">1</span><span class="br0">&#41;</span> <span class="co0">#bottom</span><br />
<span class="re2">axis2values</span>=c<span class="br0">&#40;</span>.4,.45,.5,.55,.6,.65<span class="br0">&#41;</span><br />
axis<span class="br0">&#40;</span><span class="nu0">2</span>,<span class="re2">at</span>=axis2values<span class="br0">&#41;</span> <span class="co0">#left</span><br />
axis<span class="br0">&#40;</span><span class="nu0">4</span>,<span class="re2">at</span>=axis2values,<span class="re2">lab</span>=formatC<span class="br0">&#40;</span>axis2values-fudge,<span class="re2">digits</span>=<span class="nu0">2</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="co0">#right</span><br />
box<span class="br0">&#40;</span><span class="br0">&#41;</span> <span class="co0">#draw a box around the figure</span><br />
<br />
<span class="co0"># put the stats on the graph</span><br />
text<span class="br0">&#40;</span><span class="nu0">280</span>,.53,stats,<span class="re2">cex</span>=.75<span class="br0">&#41;</span><br />
<br />
<span class="co0">#label the right axis</span><br />
mtext<span class="br0">&#40;</span><span class="st0">&quot;difference between groups&quot;</span>, <span class="re2">side</span>=<span class="nu0">4</span>,<span class="re2">line</span>=<span class="nu0">2</span><span class="br0">&#41;</span><br />
<br />
<span class="co0"># label the points</span><br />
text<span class="br0">&#40;</span><span class="nu0">80</span>,.64,<span class="st0">&quot;fixed babble&quot;</span>,<span class="re2"><span class="kw2">col</span></span>=<span class="st_h">'#EE0000'</span>, <span class="re2">cex</span>=.8<span class="br0">&#41;</span><br />
text<span class="br0">&#40;</span><span class="nu0">275</span>,.44,<span class="st0">&quot;random babble&quot;</span>,<span class="re2"><span class="kw2">col</span></span>=<span class="st_h">'#0000EE'</span>, <span class="re2">cex</span>=.8<span class="br0">&#41;</span><br />
<span class="co0"># print as pdf</span><br />
dev.print<span class="br0">&#40;</span>pdf,<span class="st0">&quot;fig/learning.pdf&quot;</span>,<span class="re2">height</span>=<span class="nu0">2.8</span>,<span class="re2">width</span>=<span class="nu0">4</span>,<span class="re2">pointsize</span>=<span class="nu0">11</span><span class="br0">&#41;</span></div></div>
]]></content:encoded>
			<wfw:commentRss>http://robfelty.org/2008/04/03/working-on-making-fancy-graphs-with-r-fixed-versus-random-babble/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:thumbnail url="http://test.robfelty.org/wp-content/uploads/2008/04/48v96-300x209.png" />
		<media:content url="http://test.robfelty.org/wp-content/uploads/2008/04/48v96-300x209.png" medium="image">
			<media:title type="html">R plot using the Brack function with error bars and statistics displayed</media:title>
		</media:content>

		<media:thumbnail url="http://test.robfelty.org/wp-content/uploads/2008/04/learning-300x209.png" />
		<media:content url="http://test.robfelty.org/wp-content/uploads/2008/04/learning-300x209.png" medium="image">
			<media:title type="html">R figure with multiple y axes</media:title>
		</media:content>
	</item>
		<item>
		<title>100 yootles bounty for solution to nested loop rounding error</title>
		<link>http://robfelty.org/2007/11/05/100-yootles-bounty-for-solution-to-nested-loop-rounding-error</link>
		<comments>http://robfelty.org/2007/11/05/100-yootles-bounty-for-solution-to-nested-loop-rounding-error#comments</comments>
		<pubDate>Mon, 05 Nov 2007 22:31:47 +0000</pubDate>
		<dc:creator>robfelty</dc:creator>
				<category><![CDATA[linguistics]]></category>
		<category><![CDATA[perl]]></category>

		<guid isPermaLink="false">http://test.robfelty.org/2007/11/05/100-yootles-bounty-for-solution-to-nested-loop-rounding-error/</guid>
		<description><![CDATA[I am working on doing some monte carlo simulations. I want to do a particular manipulation n times, but I want to constrain what I do based on three parameters, x, y, and z, which are probability distributions coded as &#8230; <a href="http://robfelty.org/2007/11/05/100-yootles-bounty-for-solution-to-nested-loop-rounding-error">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I am working on doing some monte carlo simulations. I want to do a particular manipulation n times, but I want to constrain what I do based on three parameters, <em>x</em>, <em>y</em>, and <em>z</em>, which are probability distributions coded as arrays. For example, if I want to run this simulation 1000 times, then 24 should be <em>xayaza</em>, 24 <em>xayazb</em>, 72 <em>xaybzc</em> and so on. My code seems to work right when everything is integers, but not when some of the numbers are non-integers reals (always positive). I have tried a couple different strategies of rounding, ceiling, and floor, but it seems to always be off by a few. The correct solution should output $total = $trials; </p>
<p>I will offer 100 <a href='http://yootles.com'>yootles</a> to the first person who finds a solution for me. (I am including the perl code I have been playing around with, but my problem lies in the algorithm, not in the syntax.)</p>
<div class="codecolorer-container perl dawn" style="overflow:auto;white-space:nowrap;width:0"><div class="perl codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="co1">#!/usr/bin/perl -w</span><br />
<span class="kw2">use</span> strict<span class="sy0">;</span><br />
<span class="kw2">use</span> POSIX <span class="kw3">qw</span><span class="br0">&#40;</span>floor ceil<span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="kw1">my</span> <span class="re0">$trials</span><span class="sy0">=</span><span class="nu0">795</span><span class="sy0">;</span><br />
<span class="re0">$trials</span> <span class="sy0">=</span> <span class="kw3">shift</span><span class="sy0">;</span><br />
<span class="kw1">my</span> <span class="re0">@x</span> <span class="sy0">=</span> <span class="br0">&#40;</span>.4<span class="sy0">,</span>.4<span class="sy0">,</span>.2<span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="kw1">my</span> <span class="re0">@y</span> <span class="sy0">=</span> <span class="br0">&#40;</span>.3<span class="sy0">,</span>.5<span class="sy0">,</span>.2<span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="kw1">my</span> <span class="re0">@z</span> <span class="sy0">=</span> <span class="br0">&#40;</span>.2<span class="sy0">,</span>.2<span class="sy0">,</span>.6<span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
<span class="kw1">my</span> <span class="re0">$trial</span> <span class="sy0">=</span><span class="nu0">0</span><span class="sy0">;</span><br />
<span class="kw1">my</span> <span class="re0">$total</span> <span class="sy0">=</span><span class="nu0">1</span><span class="sy0">;</span><br />
<span class="kw1">my</span> <span class="re0">$a</span><span class="sy0">=</span><span class="nu0">0</span><span class="sy0">;</span><br />
<span class="kw1">while</span> <span class="br0">&#40;</span><span class="re0">$a</span><span class="sy0">&lt;</span>scalar <span class="re0">@x</span> <span class="sy0">&amp;&amp;</span> <span class="re0">$trial</span> <span class="sy0">&lt;=</span> round<span class="br0">&#40;</span><span class="re0">$trials</span><span class="sy0">*</span><span class="re0">$x</span><span class="br0">&#91;</span><span class="re0">$a</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; <span class="kw1">my</span> <span class="re0">$b</span><span class="sy0">=</span><span class="nu0">0</span><span class="sy0">;</span><br />
&nbsp; <span class="kw1">while</span> <span class="br0">&#40;</span><span class="re0">$b</span><span class="sy0">&lt;</span> <span class="kw3">scalar</span> <span class="re0">@y</span> <span class="sy0">&amp;&amp;</span> <span class="re0">$trial</span> <span class="sy0">&lt;=</span> round<span class="br0">&#40;</span><span class="re0">$trials</span><span class="sy0">*</span><span class="re0">$x</span><span class="br0">&#91;</span><span class="re0">$a</span><span class="br0">&#93;</span><span class="sy0">*</span><span class="re0">$y</span><span class="br0">&#91;</span><span class="re0">$b</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">my</span> <span class="re0">$c</span><span class="sy0">=</span><span class="nu0">0</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw1">while</span> <span class="br0">&#40;</span><span class="re0">$c</span><span class="sy0">&lt;</span> <span class="kw3">scalar</span> <span class="re0">@z</span> <span class="sy0">&amp;&amp;</span> <span class="re0">$trial</span> <span class="sy0">&lt;=</span> round<span class="br0">&#40;</span><span class="re0">$trials</span><span class="sy0">*</span><span class="re0">$x</span><span class="br0">&#91;</span><span class="re0">$a</span><span class="br0">&#93;</span><span class="sy0">*</span><span class="re0">$y</span><span class="br0">&#91;</span><span class="re0">$b</span><span class="br0">&#93;</span><span class="sy0">*</span><span class="re0">$z</span><span class="br0">&#91;</span><span class="re0">$c</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; <span class="re0">$total</span><span class="sy0">++;</span><br />
&nbsp; &nbsp; &nbsp; <span class="re0">$trial</span><span class="sy0">++;</span><br />
&nbsp; &nbsp; &nbsp; <span class="kw1">if</span> <span class="br0">&#40;</span><span class="re0">$trial</span> <span class="sy0">&gt;=</span> round<span class="br0">&#40;</span><span class="re0">$trials</span><span class="sy0">*</span><span class="re0">$x</span><span class="br0">&#91;</span><span class="re0">$a</span><span class="br0">&#93;</span><span class="sy0">*</span><span class="re0">$y</span><span class="br0">&#91;</span><span class="re0">$b</span><span class="br0">&#93;</span><span class="sy0">*</span><span class="re0">$z</span><span class="br0">&#91;</span><span class="re0">$c</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$c</span><span class="sy0">++;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span class="re0">$trial</span><span class="sy0">=</span><span class="nu0">0</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="br0">&#125;</span><br />
&nbsp; &nbsp; <span class="re0">$b</span><span class="sy0">++;</span><br />
&nbsp; &nbsp; <span class="re0">$trial</span><span class="sy0">=</span><span class="nu0">0</span><span class="sy0">;</span><br />
&nbsp; <span class="br0">&#125;</span><br />
&nbsp; <span class="re0">$a</span><span class="sy0">++;</span><br />
&nbsp; <span class="re0">$trial</span><span class="sy0">=</span><span class="nu0">0</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span><br />
<span class="kw3">print</span> <span class="st0">&quot;trials = $trials, total = $total<span class="es0">\n</span>&quot;</span><span class="sy0">;</span><br />
<br />
<span class="kw2">sub</span> round <span class="br0">&#123;</span><br />
&nbsp; &nbsp; <span class="kw1">my</span><span class="br0">&#40;</span><span class="re0">$number</span><span class="br0">&#41;</span> <span class="sy0">=</span> <span class="kw3">shift</span><span class="sy0">;</span><br />
&nbsp; &nbsp; <span class="kw3">return</span> <span class="kw3">int</span><span class="br0">&#40;</span><span class="re0">$number</span> <span class="sy0">+</span> .5 <span class="sy0">*</span> <span class="br0">&#40;</span><span class="re0">$number</span> <span class="sy0">&lt;=&gt;</span> <span class="nu0">0</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="br0">&#125;</span></div></div>
<h4>Update</h4>
<p>My friend <a href='http://soule-reeves.com/danny'>Danny Reeves</a>, along with some help from David Yang solved my problem in a completely different way. Here is Danny&#8217;s solution:</p>
<div class="codecolorer-container perl dawn" style="overflow:auto;white-space:nowrap;width:0"><div class="perl codecolorer" style="font-family:Monaco,Lucida Console,monospace"><span class="co1">#!/usr/bin/perl</span><br />
<span class="co1"># Rob's monstronsity that is surely the solution to the wrong problem.</span><br />
<span class="co1"># But for 100 yootles, we'll just do as we're told.</span><br />
<span class="co1"># This would be much nicer in a properly functional-style language!</span><br />
<br />
<span class="kw1">my</span> <span class="re0">$trials</span> <span class="sy0">=</span> <span class="nu0">795</span><span class="sy0">;</span><br />
<br />
<span class="kw1">my</span> <span class="re0">@x</span> <span class="sy0">=</span> <span class="br0">&#40;</span>.4<span class="sy0">,</span>.4<span class="sy0">,</span>.2<span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="kw1">my</span> <span class="re0">@y</span> <span class="sy0">=</span> <span class="br0">&#40;</span>.3<span class="sy0">,</span>.5<span class="sy0">,</span>.2<span class="br0">&#41;</span><span class="sy0">;</span><br />
<span class="kw1">my</span> <span class="re0">@z</span> <span class="sy0">=</span> <span class="br0">&#40;</span>.2<span class="sy0">,</span>.2<span class="sy0">,</span>.6<span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
<span class="re0">@tuples</span> <span class="sy0">=</span> cross<span class="br0">&#40;</span>\<span class="re0">@x</span><span class="sy0">,</span>\<span class="re0">@y</span><span class="sy0">,</span>\<span class="re0">@z</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
<br />
<span class="co1"># compute idealized tuple counts:</span><br />
<span class="re0">@counts</span> <span class="sy0">=</span> <span class="kw3">map</span> <span class="br0">&#123;</span> <span class="re0">$trials</span><span class="sy0">*</span>prod<span class="br0">&#40;</span><span class="sy0">@</span><span class="co5">$_</span><span class="br0">&#41;</span> <span class="br0">&#125;</span> <span class="re0">@tuples</span><span class="sy0">;</span><br />
<br />
<span class="re0">@ic</span> <span class="sy0">=</span> <span class="kw3">map</span> <span class="br0">&#123;</span> <span class="kw3">int</span><span class="br0">&#40;</span><span class="co5">$_</span><span class="br0">&#41;</span> <span class="br0">&#125;</span> <span class="re0">@counts</span><span class="sy0">;</span> &nbsp;<span class="co1"># floors of counts.</span><br />
<span class="re0">@fc</span> <span class="sy0">=</span> <span class="kw3">map</span> <span class="br0">&#123;</span> <span class="co5">$_</span><span class="sy0">-</span><span class="kw3">int</span><span class="br0">&#40;</span><span class="co5">$_</span><span class="br0">&#41;</span> <span class="br0">&#125;</span> <span class="re0">@counts</span><span class="sy0">;</span> &nbsp;<span class="co1"># fractional parts.</span><br />
<span class="re0">$f</span> <span class="sy0">=</span> sum<span class="br0">&#40;</span><span class="re0">@fc</span><span class="br0">&#41;</span><span class="sy0">;</span> &nbsp;<span class="co1"># sum of fractional parts, to redistribute.</span><br />
<br />
<span class="co1"># redistribute...</span><br />
<span class="kw1">for</span><span class="br0">&#40;</span><span class="re0">$i</span><span class="sy0">=</span><span class="nu0">1</span><span class="sy0">;</span> <span class="re0">$i</span><span class="sy0">&lt;=</span><span class="re0">$f</span><span class="sy0">;</span> <span class="re0">$i</span><span class="sy0">++</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp;<span class="re0">$ic</span><span class="br0">&#91;</span>posmax<span class="br0">&#40;</span>deltas<span class="br0">&#40;</span>\<span class="re0">@counts</span><span class="sy0">,</span>\<span class="re0">@ic</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#93;</span><span class="sy0">++;</span><br />
<span class="br0">&#125;</span><br />
<br />
<span class="re0">$total</span> <span class="sy0">=</span> <span class="nu0">0</span><span class="sy0">;</span><br />
<span class="kw1">for</span><span class="br0">&#40;</span><span class="re0">$i</span><span class="sy0">=</span><span class="nu0">0</span><span class="sy0">;</span> <span class="re0">$i</span><span class="sy0">&lt;</span>scalar<span class="br0">&#40;</span><span class="re0">@ic</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="re0">$i</span><span class="sy0">++</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp;<span class="br0">&#40;</span><span class="re0">$x</span><span class="sy0">,</span> <span class="re0">$y</span><span class="sy0">,</span> <span class="re0">$z</span><span class="br0">&#41;</span> <span class="sy0">=</span> <span class="sy0">@</span><span class="br0">&#123;</span><span class="re0">$tuples</span><span class="br0">&#91;</span><span class="re0">$i</span><span class="br0">&#93;</span><span class="br0">&#125;</span><span class="sy0">;</span><br />
&nbsp; &nbsp;<span class="kw1">for</span><span class="br0">&#40;</span><span class="re0">$j</span><span class="sy0">=</span><span class="nu0">0</span><span class="sy0">;</span> <span class="re0">$j</span><span class="sy0">&lt;</span><span class="re0">$ic</span><span class="br0">&#91;</span><span class="re0">$i</span><span class="br0">&#93;</span><span class="sy0">;</span> <span class="re0">$j</span><span class="sy0">++</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp;<span class="kw3">print</span> <span class="st0">&quot;do something with ($x, $y, $z)<span class="es0">\n</span>&quot;</span><span class="sy0">;</span><br />
&nbsp; &nbsp; &nbsp;<span class="re0">$total</span><span class="sy0">++;</span><br />
&nbsp; &nbsp;<span class="br0">&#125;</span><br />
<span class="br0">&#125;</span><br />
<br />
<span class="kw3">print</span> <span class="st0">&quot;trials = $trials, total = $total<span class="es0">\n</span>&quot;</span><span class="sy0">;</span><br />
<br />
<br />
<span class="co1"># Return a cross product from its arguments. Arguments are array refs.</span><br />
<span class="co1"># Result is a list of array refs. &nbsp;[found this on the web; damn slick]</span><br />
<span class="co1"># (note that this returns the tuples in not quite canonical order)</span><br />
<span class="kw2">sub</span> cross <span class="br0">&#123;</span><br />
&nbsp; &nbsp;<span class="kw1">my</span> <span class="re0">@r</span> <span class="sy0">=</span> <span class="br0">&#91;</span><span class="br0">&#93;</span><span class="sy0">;</span><br />
&nbsp; &nbsp;<span class="re0">@r</span> <span class="sy0">=</span> <span class="kw3">map</span> <span class="br0">&#123;</span><span class="kw1">my</span> <span class="re0">$s</span> <span class="sy0">=</span> <span class="co5">$_</span><span class="sy0">;</span> <span class="kw3">map</span> <span class="br0">&#123;</span><span class="br0">&#91;</span><span class="sy0">@</span><span class="co5">$_</span> <span class="sy0">=&gt;</span> <span class="re0">$s</span><span class="br0">&#93;</span><span class="br0">&#125;</span> <span class="re0">@r</span><span class="br0">&#125;</span> <span class="sy0">@</span><span class="co5">$_</span> <span class="kw1">for</span> <span class="co5">@_</span><span class="sy0">;</span><br />
&nbsp; &nbsp;<span class="re0">@r</span><br />
<span class="br0">&#125;</span><br />
<br />
<span class="co1"># Return sum of arguments. &nbsp;Ie, reduce(+, args, 0).</span><br />
<span class="kw2">sub</span> sum <span class="br0">&#123;</span> <span class="kw1">my</span> <span class="re0">$x</span> <span class="sy0">=</span> <span class="nu0">0</span><span class="sy0">;</span> &nbsp;<span class="kw1">for</span><span class="br0">&#40;</span><span class="co5">@_</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="re0">$x</span> <span class="sy0">+=</span> <span class="co5">$_</span><span class="sy0">;</span> <span class="br0">&#125;</span> &nbsp;<span class="re0">$x</span> <span class="br0">&#125;</span><br />
<br />
<span class="co1"># Return product of arguments. &nbsp;Ie, reduce(*, args, 1).</span><br />
<span class="kw2">sub</span> prod <span class="br0">&#123;</span> <span class="kw1">my</span> <span class="re0">$x</span> <span class="sy0">=</span> <span class="nu0">1</span><span class="sy0">;</span> &nbsp;<span class="kw1">for</span><span class="br0">&#40;</span><span class="co5">@_</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="re0">$x</span> <span class="sy0">*=</span> <span class="co5">$_</span><span class="sy0">;</span> <span class="br0">&#125;</span> &nbsp;<span class="re0">$x</span> <span class="br0">&#125;</span><br />
<br />
<span class="co1"># Return a list of differences between 2 lists, passed as refs.</span><br />
<span class="co1"># (assumes the lists have the same length)</span><br />
<span class="kw2">sub</span> deltas <span class="br0">&#123;</span><br />
&nbsp; &nbsp;<span class="kw1">my</span> <span class="re0">@ans</span><span class="sy0">;</span><br />
&nbsp; &nbsp;<span class="kw1">for</span><span class="br0">&#40;</span><span class="kw1">my</span> <span class="re0">$i</span><span class="sy0">=</span><span class="nu0">0</span><span class="sy0">;</span> <span class="re0">$i</span><span class="sy0">&lt;</span>scalar<span class="br0">&#40;</span><span class="sy0">@</span><span class="br0">&#123;</span><span class="co5">$_</span><span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span><span class="br0">&#125;</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="re0">$i</span><span class="sy0">++</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp;<span class="kw3">push</span><span class="br0">&#40;</span><span class="re0">@ans</span><span class="sy0">,</span> <span class="co5">$_</span><span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span><span class="sy0">-&gt;</span><span class="br0">&#91;</span><span class="re0">$i</span><span class="br0">&#93;</span> <span class="sy0">-</span> <span class="co5">$_</span><span class="br0">&#91;</span><span class="nu0">1</span><span class="br0">&#93;</span><span class="sy0">-&gt;</span><span class="br0">&#91;</span><span class="re0">$i</span><span class="br0">&#93;</span><span class="br0">&#41;</span><span class="sy0">;</span><br />
&nbsp; &nbsp;<span class="br0">&#125;</span><br />
&nbsp; &nbsp;<span class="re0">@ans</span><br />
<span class="br0">&#125;</span><br />
<br />
<span class="co1"># Takes list, return the position of the largest element.</span><br />
<span class="kw2">sub</span> posmax <span class="br0">&#123;</span><br />
&nbsp; &nbsp;<span class="kw1">if</span> <span class="br0">&#40;</span><span class="kw3">scalar</span><span class="br0">&#40;</span><span class="co5">@_</span><span class="br0">&#41;</span><span class="sy0">==</span><span class="nu0">0</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="kw3">return</span> <span class="sy0">-</span><span class="nu0">1</span><span class="sy0">;</span> <span class="br0">&#125;</span><br />
&nbsp; &nbsp;<span class="kw1">my</span> <span class="re0">$x</span> <span class="sy0">=</span> <span class="nu0">0</span><span class="sy0">;</span> &nbsp;<span class="co1"># index of best so far.</span><br />
&nbsp; &nbsp;<span class="kw1">for</span><span class="br0">&#40;</span><span class="kw1">my</span> <span class="re0">$i</span><span class="sy0">=</span><span class="nu0">0</span><span class="sy0">;</span> <span class="re0">$i</span><span class="sy0">&lt;</span>scalar<span class="br0">&#40;</span><span class="co5">@_</span><span class="br0">&#41;</span><span class="sy0">;</span> <span class="re0">$i</span><span class="sy0">++</span><span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
&nbsp; &nbsp; &nbsp;<span class="kw1">if</span><span class="br0">&#40;</span><span class="co5">$_</span><span class="br0">&#91;</span><span class="re0">$i</span><span class="br0">&#93;</span> <span class="sy0">&gt;</span> <span class="co5">$_</span><span class="br0">&#91;</span><span class="re0">$x</span><span class="br0">&#93;</span><span class="br0">&#41;</span> <span class="br0">&#123;</span> <span class="re0">$x</span> <span class="sy0">=</span> <span class="re0">$i</span><span class="sy0">;</span> <span class="br0">&#125;</span><br />
&nbsp; &nbsp;<span class="br0">&#125;</span><br />
&nbsp; &nbsp;<span class="re0">$x</span><br />
<span class="br0">&#125;</span></div></div>
<p>And because Danny is a huge fan of Mathematica, he also included a Mathematica version</p>
<div class="codecolorer-container python dawn" style="overflow:auto;white-space:nowrap;width:0"><div class="python codecolorer" style="font-family:Monaco,Lucida Console,monospace">trials = <span class="nu0">795</span><span class="sy0">;</span><br />
x = <span class="br0">&#123;</span>.4, .4, .2<span class="br0">&#125;</span><span class="sy0">;</span><br />
y = <span class="br0">&#123;</span>.3, .5, .2<span class="br0">&#125;</span><span class="sy0">;</span><br />
z = <span class="br0">&#123;</span>.2, .2, .6<span class="br0">&#125;</span><span class="sy0">;</span><br />
<br />
<span class="br0">&#40;</span><span class="sy0">*</span> index of the largest element<span class="sy0">;</span> i<span class="st0">'m sure there'</span>s an adorable one-liner<br />
&nbsp; &nbsp; <span class="kw1">for</span> this <span class="kw1">if</span> i thought hard enough <span class="sy0">*</span><span class="br0">&#41;</span><br />
posmax<span class="br0">&#91;</span><span class="br0">&#123;</span><span class="br0">&#125;</span><span class="br0">&#93;</span> = -<span class="nu0">1</span><span class="sy0">;</span><br />
posmax<span class="br0">&#91;</span>l_<span class="br0">&#93;</span> := Module<span class="br0">&#91;</span><span class="br0">&#123;</span>i, x = <span class="nu0">1</span><span class="br0">&#125;</span>, <span class="br0">&#40;</span><span class="sy0">*</span> x <span class="kw1">is</span> index of best so far <span class="sy0">*</span><span class="br0">&#41;</span><br />
&nbsp; &nbsp;For<span class="br0">&#91;</span>i = <span class="nu0">1</span>, i <span class="sy0">&lt;</span> Length<span class="br0">&#91;</span>l<span class="br0">&#93;</span>, i++, If<span class="br0">&#91;</span>l<span class="br0">&#91;</span><span class="br0">&#91;</span>i<span class="br0">&#93;</span><span class="br0">&#93;</span> <span class="sy0">&gt;</span> l<span class="br0">&#91;</span><span class="br0">&#91;</span>x<span class="br0">&#93;</span><span class="br0">&#93;</span>, x = i<span class="br0">&#93;</span><span class="br0">&#93;</span><span class="sy0">;</span><br />
&nbsp; &nbsp;x<span class="br0">&#93;</span><br />
<br />
tuples = Tuples<span class="br0">&#91;</span><span class="br0">&#123;</span>x, y, z<span class="br0">&#125;</span><span class="br0">&#93;</span><span class="sy0">;</span><br />
counts = <span class="br0">&#40;</span>trials<span class="sy0">*</span>Times @@ <span class="co1"># &amp;) /@ tuples;</span><br />
ic = IntegerPart /@ counts<span class="sy0">;</span><br />
fc = FractionalPart /@ counts<span class="sy0">;</span><br />
f = Total<span class="br0">&#91;</span>fc<span class="br0">&#93;</span><span class="sy0">;</span><br />
For<span class="br0">&#91;</span>i=<span class="nu0">1</span>, i<span class="sy0">&lt;</span>=f, i++, ic<span class="br0">&#91;</span><span class="br0">&#91;</span>posmax<span class="br0">&#91;</span>counts - ic<span class="br0">&#93;</span><span class="br0">&#93;</span><span class="br0">&#93;</span>++<span class="br0">&#93;</span><span class="sy0">;</span><br />
total = <span class="nu0">0</span><span class="sy0">;</span><br />
MapThread<span class="br0">&#91;</span>Do<span class="br0">&#91;</span><span class="br0">&#123;</span><span class="st0">&quot;do something with &quot;</span>, <span class="co1">#1}; total++, {#2}]&amp;, {tuples,ic}];</span><br />
total</div></div>
]]></content:encoded>
			<wfw:commentRss>http://robfelty.org/2007/11/05/100-yootles-bounty-for-solution-to-nested-loop-rounding-error/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>More on LaTeX multimedia presentations</title>
		<link>http://robfelty.org/2007/03/10/more-on-latex-multimedia-presentations</link>
		<comments>http://robfelty.org/2007/03/10/more-on-latex-multimedia-presentations#comments</comments>
		<pubDate>Sat, 10 Mar 2007 19:15:14 +0000</pubDate>
		<dc:creator>robfelty</dc:creator>
				<category><![CDATA[latex]]></category>
		<category><![CDATA[linguistics]]></category>

		<guid isPermaLink="false">http://test.robfelty.org/2007/03/10/more-on-latex-multimedia-presentations/</guid>
		<description><![CDATA[Yesterday I gave a talk in the Linguistics department colloquium series. I like to cover all my bases, so I had a handout and a slide presentation, which were both made from the same LaTeX code. In an earlier post, &#8230; <a href="http://robfelty.org/2007/03/10/more-on-latex-multimedia-presentations">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Yesterday I gave a talk in the <a href="http://ling.lsa.umich.edu/home/colloquium.html#2007.03.09">Linguistics department colloquium series</a>. I like to cover all my bases, so I had a handout and a slide presentation, which were both made from the same LaTeX code. In an <a href="http://test.robfelty.org/2007/02/26/intro-to-latex-multimedia-presentations/">earlier post</a>, I briefly discussed using the <a href="http://prosper.sourceforge.net/">prosper</a> package for LaTeX to make presentations. A few months ago, I discovered the <a href="http://stuwww.uvt.nl/%7Ehendri/index.html?/%7Ehendri/Downloads/powerdot.html&amp;mainframeha">powerdot</a> package, which is kind of the niece of prosper (cousin of ha-prosper). The syntax and framework is very similar to prosper, but it has a few advantages. Some of the advantage include better overlay and verbatim support, which is definitely nice. I think the biggest advantage though is the possibility to include a running table of contents on your slides. You can see this in the screenshots below.</p>
<p><a href="http://test.robfelty.org/wp-content/uploads/2007/03/screenshot2.png"><img class='alignleft' src="http://test.robfelty.org/wp-content/uploads/2007/03/screenshot2.thumbnail.png" title="powerdot screenshot 1" alt="powerdot screenshot 1"  /></a><br />
In the first screenshot, you can also see some nicely typeset equations with LaTeX. This is an obviously nice feature of using LaTeX to do presentations. If you are already using LaTeX for other writing, you can do a lot of copying and pasting, which certainly is not possible with powerpoint (for equations at least). And, if you like dark backgrounds with light text, this works fine for your equations. Powerpoint seems to only be handle black on white equations.</p>
<p><a href="http://test.robfelty.org/wp-content/uploads/2007/03/screenshot3.png"><img class='alignleft' src="http://test.robfelty.org/wp-content/uploads/2007/03/screenshot3.thumbnail.png" title="powerdot screenshot 2" alt="powerdot screenshot 2" style='clear:both' /></a><br />
Back to the running table of contents. This is probably not great for everyone, but at least one person who was at my talk said he liked it. And I agree. It lets you know where you are at in the talk the whole time, and is fairly unobtrusive. If for some reason you need more space on the slide, you can simply use the <tt>wideslide</tt> environment, which gets rid of the table of contents bar. Before I gave my talk yesterday, I saw another talk, which was quite interesting, but I was definitely confused, when I saw a slide titled &#8220;summary&#8221;, which was then followed immediately by 20 more slides, and a final summary, about 25 minutes later. This was very distracting. Sure, the speaker could have said something like &#8220;summary so far&#8221;, but having the outline of the talk would have been helpful. Actually, he did present an outline of the talk at the beginning, on one slide, which he displayed for about 20 seconds. Not very helpful. Another option is to display the outline periodically throughout the talk, but this means you have to keep saying what you are about to say, instead of just saying it. Especially in short talks, I don&#8217;t like to waste time saying what I am going to say. Having the running table of contents, and also a handout, gives people a good idea of what I am going to say, without me having to waste time saying it.</p>
<p>This brings up a more general point about handouts. I think that a good handout can be very helpful to your audience, for a number of reasons:</p>
<ol>
<li>They can read ahead to see what you are going to say</li>
<li>They can re-read stuff if they don&#8217;t understand it the first time you say it</li>
<li>They can take as long as they want to look at your figures</li>
<li>They can take notes on your handout if they want to</li>
<li>If they really liked your talk, they can keep your handout, and perhaps share it with others, or learn more from it</li>
</ol>
<p>And just to clarify, when I mean handout, I don&#8217;t mean your slides printed off on paper. Using this method leaves a lot of whitespace (good for extensive note-takers I suppose, of which I am not one), wasting paper. The handout might be a good place to include long quotes, or large tables, which might not be appropriate for the screen. The handout is also a good place to list all your references, which is very valuable to people who want to know more about your research. It also might be appropriate to display some of your figures differently. In this particular presentation, I had several figures, which I placed one per slide. In the handout however, the figures are grouped into 3&#215;2 subfigures, which allows for better comparison, and also makes them more compact. Furthermore, they are black &amp; white, with font sizes appropriate for the handout. Doing all this with LaTeX was quite simple. Out of the box, LaTeX gives the user the ability to use conditional (if &#8211; then) statements. I find it easiest to do with counts, e.g.:</p>
<div class="codecolorer-container text dawn" style="overflow:auto;white-space:nowrap;width:0"><div class="text codecolorer" style="font-family:Monaco,Lucida Console,monospace">\newcount\Slides<br />
\Slides=1<br />
\ifnum\Slides=1<br />
&nbsp; \includegraphics{myColorfigure}<br />
\else<br />
&nbsp; \includegraphics{myBWfigure}<br />
\fi</div></div>
<p>I think that is probably enough for now. If you are interested, you can download the <a href='http://test.robfelty.org/wp-content/uploads/2007/03/colloquium20070309light.pdf'>compiled pdf</a> or the <a href='http://test.robfelty.org/wp-content/uploads/2007/03/colloquium20070309.tex'>TeX source</a> for my presentation, as well as the <a href='http://test.robfelty.org/wp-content/uploads/2007/03/colloquium20070309handout.pdf'>compiled handout</a>. Note that the .tex file will not compile on your system as is, due to missing figure files and such, as well as my own custom powerdot theme. But hopefully it should be illustrative.</p>
]]></content:encoded>
			<wfw:commentRss>http://robfelty.org/2007/03/10/more-on-latex-multimedia-presentations/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:thumbnail url="http://test.robfelty.org/wp-content/uploads/2007/03/screenshot2.thumbnail.png" />
		<media:content url="http://test.robfelty.org/wp-content/uploads/2007/03/screenshot2.thumbnail.png" medium="image">
			<media:title type="html">powerdot screenshot 1</media:title>
		</media:content>

		<media:thumbnail url="http://test.robfelty.org/wp-content/uploads/2007/03/screenshot3.thumbnail.png" />
		<media:content url="http://test.robfelty.org/wp-content/uploads/2007/03/screenshot3.thumbnail.png" medium="image">
			<media:title type="html">powerdot screenshot 2</media:title>
		</media:content>
	</item>
		<item>
		<title>syllable-based confusions</title>
		<link>http://robfelty.org/2007/02/16/syllable-based-confusions</link>
		<comments>http://robfelty.org/2007/02/16/syllable-based-confusions#comments</comments>
		<pubDate>Fri, 16 Feb 2007 20:54:15 +0000</pubDate>
		<dc:creator>robfelty</dc:creator>
				<category><![CDATA[linguistics]]></category>

		<guid isPermaLink="false">http://test.robfelty.org/2007/02/16/syllable-based-confusions/</guid>
		<description><![CDATA[So my current research focuses heavily on confusion, specifically phonetic confusions. For my disseration, I play people words mixed with noise, and ask them to type what they hear. Then I look at the types of mistakes they make. For &#8230; <a href="http://robfelty.org/2007/02/16/syllable-based-confusions">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>So my current research focuses heavily on confusion, specifically phonetic confusions. For my disseration, I play people words mixed with noise, and ask them to type what they hear. Then I look at the types of mistakes they make. For example, <em>pit</em> and <em>kit</em> are often confused with one another, but <em>pit</em> and <em>lit</em> are not, because [p] and [k] have very similar acoustic properties, whereas [p] and [l] are not very similar.</p>
<p>I often wonder why I have chosen this line of research, and I think that it might have to do with the fact that I make many confusions of this sort myself. Sometimes I do it on purpose, to make people laugh, but frequently I also have genuine confusions. Today at school prospective graduate students are visiting, and the current grad students had breakfast with them. The student services coordinator, Sylvia, who was helping to arrange rides from the airport and such, came into the somewhat crowded and noisy room, and announced that <em>[3 syllable word] Washington</em> is on his way. I initially heard that three syllable word as &#8220;President&#8221;, and so I said &#8220;President?&#8221;, to which Sylvia emphatically replied, &#8220;Jonathan!&#8221;. It seems that most people heard <em>Jonathan</em>, but I really only perceived the fact that the word before Washington had three syllables, so I made an educated guess, which was &#8220;President&#8221;. Perhaps in the future I can construct some experiments to see if other people made these sorts of errors, where the exact sounds are incorrect, but some of the linguistic structure is still present, in this case the syllable. In fact, looking at my data from two syllables words and nonwords, all with a CVCCVC structure (C = consonant, V = vowel), most of the errors are disyllabic, and most preserve the consonant-vowel structure as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://robfelty.org/2007/02/16/syllable-based-confusions/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>a new LaTeX class file for U-M dissertations</title>
		<link>http://robfelty.org/2007/02/06/a-new-latex-class-file-for-u-m-dissertations</link>
		<comments>http://robfelty.org/2007/02/06/a-new-latex-class-file-for-u-m-dissertations#comments</comments>
		<pubDate>Tue, 06 Feb 2007 19:51:16 +0000</pubDate>
		<dc:creator>robfelty</dc:creator>
				<category><![CDATA[latex]]></category>
		<category><![CDATA[linguistics]]></category>

		<guid isPermaLink="false">http://test.robfelty.org/2007/02/06/a-new-latex-class-file-for-u-m-dissertations/</guid>
		<description><![CDATA[I have been working on a new LaTeX class file for University of Michigan dissertations for awhile now. I finally got tired of the limitations of umdiss.cls. The main goals (which I believe I have achieved) of the new class &#8230; <a href="http://robfelty.org/2007/02/06/a-new-latex-class-file-for-u-m-dissertations">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I have been working on a new LaTeX class file for University of Michigan dissertations for awhile now. I finally got tired of the limitations of umdiss.cls. The main goals (which I believe I have achieved) of the new class file are:</p>
<ol>
<li>load the book class and modify only what&#8217;s necessary</li>
<li>be compatible with as many packages as possible</li>
<li>require the hyperref package, because it does many very handy things, like automatically creating pdf bookmarks and links from the table of contents, list of figures etc.</li>
<li>work with includeonly (umdiss.cls does not)</li>
<li>follow formatting guidelines of the University of Michigan</li>
</ol>
<p>I know of one feature which is not implemented fully yet, and that is the abstract. If you use the abstract environment, it will typeset your abstract according to the guidelines set for dissertation abstracts by Rackham, but there is not an option yet to have it formatted for actual inclusion in the dissertation, including being listed in the table of contents. This will come soon.</p>
<p>You can either download the <a href="http://robfelty/umthesis.zip">zip file</a>, <a href="http://robfelty/umthesis">browse the directory</a>, or view the latest version in the <a href='http://robfelty/svn/viewvc.cgi/?root=umthesis'>svn repository</a>. I have included an extensively commented example, which includes several macros that I use to make things easier. There are also quite a few comments in the .cls file as well. A more thorough documentation will come later.</p>
<p>I hope you find the class file handy, and <em>please</em> let me know if you find any errors.</p>
<p>Now back to writing the actual content of the dissertation&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://robfelty.org/2007/02/06/a-new-latex-class-file-for-u-m-dissertations/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>speech perception, therapeutic ultrasound and detecting land mines</title>
		<link>http://robfelty.org/2006/12/03/speech-perception-therapeutic-ultrasound-and-detecting-land-mines</link>
		<comments>http://robfelty.org/2006/12/03/speech-perception-therapeutic-ultrasound-and-detecting-land-mines#comments</comments>
		<pubDate>Sun, 03 Dec 2006 05:06:28 +0000</pubDate>
		<dc:creator></dc:creator>
				<category><![CDATA[general]]></category>
		<category><![CDATA[linguistics]]></category>

		<guid isPermaLink="false">http://test.robfelty.org/2006/12/03/speech-perception-therapeutic-ultrasound-and-detecting-land-mines/</guid>
		<description><![CDATA[Today was the last day of my first meeting of the Acoustical Society of America. It was actually the 155th meeting of the society, and the 4th joint meeting with the Acoustical Society of Japan. Oh, and it was in &#8230; <a href="http://robfelty.org/2006/12/03/speech-perception-therapeutic-ultrasound-and-detecting-land-mines">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Today was the last day of my first meeting of the <a href='http://asa.aip.org'>Acoustical Society of America</a>. It was actually the 155th meeting of the society, and the 4th joint meeting with the Acoustical Society of Japan. Oh, and it was in Hawaii.</p>
<p>I have been a member of the ASA for several years now, and have read many articles in its journal, but I have not spent that much time reading journals outside of my subfield. There are 13 subfields at each meeting of the society, which also roughly correspond to different topics in the journal. I am most interested in the Speech Communication subfield, and spent the great majority of my time learning about all sorts of interesting research going on in that area. Even within Speech Communication, there is a great diversity. I saw some posters and presentations about lexical access, which I do, as well as posters on developing better cochlear implants, quite a few papers on automated speech recognition, some on clinical applications of phonetics, and a few on using ultrasound to track the movement of the tongue. </p>
<p>In addition to these talks, I also saw a couple in different fields. There were two plenary talks at the beginning of the conference &#8211; one Japanese person, and one American. The first plenary, by Masayuki Morimoto, covered a fairly wide range, from architectural acoustics to psychological acoustics. Ultimately, these two are very related. Acoustic engineers are interested in designing buildings with good acoustics, but ultimately, the definition of &#8220;good&#8221; is dependent upon how humans perceive the acoustics of the space. He talked quite a bit about what types of parameters that one can measure, as opposed to parameters that cannot objectively be measured. Whether a person finds a space pleasing or not is very subjective. Whether a person finds a space ringy or deadening can be quantified though, and depending upon the space, one or the other might be desirable. </p>
<p>The second plenary, by Lawrence Crum, was on a completely different topic &#8211; therapeutic ultrasound. I had never really heard about this before. He gave a nice overview of how therapeutic ultrasound works, the history (first used in the 1950&#8242;s), and its applications. When we hear ultrasound, we usually think of imaging, and that is correct. Ultrasound imaging (or diagnostic ultrasound), shoots low power, low frequency sound waves into a medium, and registers the time it takes for the waves to bounce back. Objects at different angles and distances will take differing amounts of time to bounce back, and thus one can make an image. Therapeutic ultrasound uses high power, high frequency sound waves, and concentrates the waves at a particular point, much in the way one can use a magnifying glass to concentrate electromagnetic waves (e.g. sunlight) onto a piece of paper and catch it on fire. With very high power sound waves, one can do quite a bit of destruction. Destruction? Yes, destruction. One common application is for breaking up kidney stones &#8212; without surgery. Another is killing cancerous tissue, specifically for pancreatic cancer, which is a terrible sort of cancer. Another application is blood clotting (hemostasis).  </p>
<p>Many acousticians are concerned about noise. Many speech communication people use noisy conditions to test hearing (including myself), and many are also concerned about trying to reduce noise pollution. I saw several talks about that. David Bowen gave a talk about how to perform acoustic audits for consumer products, mostly by isolating different parts of the product, such as the motor, or a fan, and using different tools to measure the amount of noise it produces. Then one can create a sound profile for the product, and try to reduce the noise through various methods. One example he gave was a copy machine. They swapped the metal chain with a composite chain, and perforated the aluminum frame inside, along with a few other modifications, to reduce the overall noise by about 8 decibels (remember that decibels are on a log scale, so that is actually a fairly large reduction). </p>
<p>One last small note. I did not attend any of these talks, but while reading through the abstract booklet, I noticed that there was a whole session on using acoustics to detect land mines. Talk about a diverse field. I am excited to learn more.</p>
]]></content:encoded>
			<wfw:commentRss>http://robfelty.org/2006/12/03/speech-perception-therapeutic-ultrasound-and-detecting-land-mines/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

