<?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:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Abandon MATLAB</title>
	<atom:link href="http://abandonmatlab.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://abandonmatlab.wordpress.com</link>
	<description>MATLAB is not good. Do not use it.</description>
	<lastBuildDate>Thu, 26 Jan 2012 20:07:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='abandonmatlab.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Abandon MATLAB</title>
		<link>http://abandonmatlab.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://abandonmatlab.wordpress.com/osd.xml" title="Abandon MATLAB" />
	<atom:link rel='hub' href='http://abandonmatlab.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Rhetorical question.</title>
		<link>http://abandonmatlab.wordpress.com/2011/07/09/rhetorical-question/</link>
		<comments>http://abandonmatlab.wordpress.com/2011/07/09/rhetorical-question/#comments</comments>
		<pubDate>Sun, 10 Jul 2011 00:10:51 +0000</pubDate>
		<dc:creator>crowding</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://abandonmatlab.wordpress.com/?p=170</guid>
		<description><![CDATA[Is anyone providing a useful and innovative service like this for MATLAB? Surprise me. All the MATLAB users I know are maintaining their own clusters and licensing at great hassle and cost.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abandonmatlab.wordpress.com&amp;blog=8693608&amp;post=170&amp;subd=abandonmatlab&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Is anyone providing a <a href="http://cloudnumbers.com/">useful and innovative service like this</a> for MATLAB?</p>
<p>Surprise me. All the MATLAB users I know are maintaining their own clusters and licensing at great hassle and cost.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/abandonmatlab.wordpress.com/170/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/abandonmatlab.wordpress.com/170/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/abandonmatlab.wordpress.com/170/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/abandonmatlab.wordpress.com/170/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/abandonmatlab.wordpress.com/170/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/abandonmatlab.wordpress.com/170/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/abandonmatlab.wordpress.com/170/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/abandonmatlab.wordpress.com/170/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/abandonmatlab.wordpress.com/170/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/abandonmatlab.wordpress.com/170/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/abandonmatlab.wordpress.com/170/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/abandonmatlab.wordpress.com/170/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/abandonmatlab.wordpress.com/170/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/abandonmatlab.wordpress.com/170/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abandonmatlab.wordpress.com&amp;blog=8693608&amp;post=170&amp;subd=abandonmatlab&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://abandonmatlab.wordpress.com/2011/07/09/rhetorical-question/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/56a9f6905eee8797a30f70f109a40853?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">crowding</media:title>
		</media:content>
	</item>
		<item>
		<title>Cleaning up after yourself, prologue.</title>
		<link>http://abandonmatlab.wordpress.com/2011/06/22/cleaning-up-after-yourself-prologue/</link>
		<comments>http://abandonmatlab.wordpress.com/2011/06/22/cleaning-up-after-yourself-prologue/#comments</comments>
		<pubDate>Wed, 22 Jun 2011 23:32:40 +0000</pubDate>
		<dc:creator>crowding</dc:creator>
				<category><![CDATA[errors in error handling]]></category>
		<category><![CDATA[thirty misfeature pileup]]></category>

		<guid isPermaLink="false">https://abandonmatlab.wordpress.com/?p=182</guid>
		<description><![CDATA[Errors that happen during onCleanup are transformed into warnings? Really? It doesn&#8217;t help that cleanup functions also can&#8217;t be closures &#8212; they can&#8217;t actually respond to data about a resource that was gathered during a program. But first things first. Hey: if an error happens in my code, that is an error. My program should [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abandonmatlab.wordpress.com&amp;blog=8693608&amp;post=182&amp;subd=abandonmatlab&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Errors that happen during onCleanup are <i>transformed into warnings?</i> Really?</p>
<p>It doesn&#8217;t help that cleanup functions also can&#8217;t be closures &#8212; they can&#8217;t actually respond to data about a resource that was gathered during a program. But first things first.</p>
<p>Hey: if an error happens in my code, <b>that is an error.</b> My program should <i>not continue</i> unless it specifically handles that error. If an error happens while my program is trying to <i>clean up after itself</i>, that means <i>something is wrong</i> and MATLAB should not force my program to blithely continue and wreak further havoc.</p>
<p>I&#8217;ve restrained myself from picking <i>too</i> hard on The Mathworks&#8217; decision to promise deterministic destruction for closures and objects, even though it has unacceptable performance penalties. The reason for the restraint is that I can see the argument for object lifecycle management: when your objects correspond to exclusive resources you hold, you <i>do</i> want to have control and guarantees over when they get released.</p>
<p>Well, I just looked into onCleanup and as usual, the Mathworks <i>fucked it up</i>: You cannot write robust programs using onCleanup, because exceptions during cleanup are <i>swallowed.</i></p>
<p>So I&#8217;m going to have to start kicking at the <a href="http://tvtropes.org/pmwiki/pmwiki.php/Main/ThirtyXanatosPileup">thirty misfeature pileup</a> where MATLAB&#8217;s memory management meets its error handling, after all.</p>
<p>There are a number of languages that offer both automatic memory management and exceptions. A few of them are Python, R, Java, and MATLAB. All of these <i>except</i> MATLAB deal with resource cleanup easily with a try/finally statement, which MATLAB lacks, and most also offer some extra sugar in the form of a try-with-resource, which MATLAB <i>tries</i> to do with deterministic destructors, and fails. </p>
<p>One of these things is not like the others:</p>
<dt>
<dt>Python <a href="http://docs.python.org/reference/compound_stmts.html#the-try-statement">try/finally</a></dt>
<dd> &#8220;If finally is present, it specifies a ‘cleanup’ handler&#8230;. If there is a saved exception, it is re-raised at the end of the finally clause. If the finally clause raises another exception or executes a return or break statement, the saved exception is lost.&#8221;</dd>
<dt>Python <a href="http://www.python.org/dev/peps/pep-0343/"> with</a> </p>
<dd>&#8220;That way, if the caller needs to tell whether the __exit__()  invocation *failed* (as opposed to successfully cleaning up before<br />
    propagating the original error), it can do so.&#8221;</dd>
<dt>Java <a href="http://java.sun.com/docs/books/jls/third_edition/html/exceptions.html#11.3">try/finally</a></dt>
<dd>&#8220;If a finally clause is executed because of abrupt completion of a try block and the finally clause itself completes abruptly, then the reason for the abrupt completion of the try block is discarded and the new reason for abrupt completion is propagated from there.&#8221;</dd>
<dt>Java <a href="http://download.java.net/jdk7/docs/technotes/guides/language/try-with-resources.html">try-with-resources</a></dt>
<dd>&#8220;If exceptions are thrown from both the try block and the try-with-resources statement, then the method readFirstLineFromFile throws the exception thrown from the try block; the exception thrown from the try-with-resources block is suppressed. In Java SE 7 and later, you can retrieve suppressed exceptions&#8221;</dd>
<dt>R <a href="http://stat.ethz.ch/R-manual/R-patched/library/base/html/conditions.html">tryCatch</a></dt>
<dd>&#8220;The finally expression is then evaluated in the context in which tryCatch was called; that is, the handlers supplied to the current tryCatch call are not active when the finally expression is evaluated.&#8221;</dd>
<dt>MATLAB <a href="http://www.mathworks.com/help/techdoc/ref/handle.delete.html">delete</a></dt>
<dd>&#8220;A delete method should not generate errors&#8221;</dd>
</dl>
<p>One of these things is not like the others, and the one that fucked up is of course MATLAB.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/abandonmatlab.wordpress.com/182/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/abandonmatlab.wordpress.com/182/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/abandonmatlab.wordpress.com/182/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/abandonmatlab.wordpress.com/182/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/abandonmatlab.wordpress.com/182/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/abandonmatlab.wordpress.com/182/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/abandonmatlab.wordpress.com/182/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/abandonmatlab.wordpress.com/182/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/abandonmatlab.wordpress.com/182/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/abandonmatlab.wordpress.com/182/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/abandonmatlab.wordpress.com/182/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/abandonmatlab.wordpress.com/182/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/abandonmatlab.wordpress.com/182/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/abandonmatlab.wordpress.com/182/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abandonmatlab.wordpress.com&amp;blog=8693608&amp;post=182&amp;subd=abandonmatlab&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://abandonmatlab.wordpress.com/2011/06/22/cleaning-up-after-yourself-prologue/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/56a9f6905eee8797a30f70f109a40853?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">crowding</media:title>
		</media:content>
	</item>
		<item>
		<title>Profiling</title>
		<link>http://abandonmatlab.wordpress.com/2011/06/20/profiling/</link>
		<comments>http://abandonmatlab.wordpress.com/2011/06/20/profiling/#comments</comments>
		<pubDate>Tue, 21 Jun 2011 06:20:19 +0000</pubDate>
		<dc:creator>crowding</dc:creator>
				<category><![CDATA[doing it wrong]]></category>
		<category><![CDATA[matlab is bad at math]]></category>

		<guid isPermaLink="false">https://abandonmatlab.wordpress.com/?p=177</guid>
		<description><![CDATA[Occasionally I try to work around problems with MATLAB&#8217;s shitty slow performance by using its &#8220;profiler.&#8221; A profiler is simple in concept: It records how much time a program spends in various functions, so you can tell which ones are slowing you down. There are a couple of different ways to implement a profiler: You [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abandonmatlab.wordpress.com&amp;blog=8693608&amp;post=177&amp;subd=abandonmatlab&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Occasionally I try to work around problems with MATLAB&#8217;s <a href="https://groups.google.com/forum/?hl=en#!topic/comp.soft-sys.matlab/Rhq-3yjo_xg">shitty slow performance</a> by using its &#8220;profiler.&#8221; </p>
<p>A profiler is simple in concept: It records how much time a program spends in various functions, so you can tell which ones are slowing you down. There are a couple of different ways to implement a profiler: You could arrange to interrupt the language runtime every millisecond or so and see what functions you&#8217;re in the middle of executing. Alternately, you could arrange to record the time every function call begins or ends. Both these techniques involve either instrumenting the runtime, or concurrency and runtime introspection &#8212; that&#8217;s the kind of runtime stuff that MATLAB doesn&#8217;t provide users access to, so instead of being able to actually write a profiler, we have to rely on what profiling ability TMW&#8217;s programmers have already built into the runtime.</p>
<p>But fundamentally, that&#8217;s the hard part. After you&#8217;ve instrumented your runtime and are recording data while the program runs, everything after that is just tabulating and adding up numbers.</p>
<p>Which leads me to ask, how the fuck is MATLAB fucking up at the &#8220;adding up numbers&#8221; part so badly?</p>
<p>No, I do not have 36 CPUs in my machine, and <code>mainLoop&gt;go</code> does not recurse on itself at all, either.</p>
<div style="text-align:center;"><img src="http://abandonmatlab.files.wordpress.com/2011/06/what1.png?w=495" alt="what1.png" border="0" width="100%" /></div>
<p>More after the jump&#8230;<span id="more-177"></span>Oh! One twentieth of the calls to <code>require</code> take 50 times as long as <i>twenty twentieths</i> of them. </p>
<div style="text-align:center;"><img src="http://abandonmatlab.files.wordpress.com/2011/06/what2.png?w=495" alt="what2.png" border="0" width="100%" /></div>
<p>In a new profiler run, everything that calls <code>mainLoop&gt;go</code> is accounted for, Interestingly, we conclude this function accounts 94% of its time <i>not being called at all.</i></p>
<div style="text-align:center;"><img src="http://abandonmatlab.files.wordpress.com/2011/06/what3.png?w=495" alt="what3.png" border="0" width="100%" /></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/abandonmatlab.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/abandonmatlab.wordpress.com/177/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/abandonmatlab.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/abandonmatlab.wordpress.com/177/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/abandonmatlab.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/abandonmatlab.wordpress.com/177/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/abandonmatlab.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/abandonmatlab.wordpress.com/177/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/abandonmatlab.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/abandonmatlab.wordpress.com/177/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/abandonmatlab.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/abandonmatlab.wordpress.com/177/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/abandonmatlab.wordpress.com/177/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/abandonmatlab.wordpress.com/177/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abandonmatlab.wordpress.com&amp;blog=8693608&amp;post=177&amp;subd=abandonmatlab&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://abandonmatlab.wordpress.com/2011/06/20/profiling/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/56a9f6905eee8797a30f70f109a40853?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">crowding</media:title>
		</media:content>

		<media:content url="http://abandonmatlab.files.wordpress.com/2011/06/what1.png" medium="image">
			<media:title type="html">what1.png</media:title>
		</media:content>

		<media:content url="http://abandonmatlab.files.wordpress.com/2011/06/what2.png" medium="image">
			<media:title type="html">what2.png</media:title>
		</media:content>

		<media:content url="http://abandonmatlab.files.wordpress.com/2011/06/what3.png" medium="image">
			<media:title type="html">what3.png</media:title>
		</media:content>
	</item>
		<item>
		<title>Let&#8217;s talk colormaps.</title>
		<link>http://abandonmatlab.wordpress.com/2011/05/07/lets-talk-colormaps/</link>
		<comments>http://abandonmatlab.wordpress.com/2011/05/07/lets-talk-colormaps/#comments</comments>
		<pubDate>Sat, 07 May 2011 22:04:16 +0000</pubDate>
		<dc:creator>crowding</dc:creator>
				<category><![CDATA[powerfully stupid graphics]]></category>

		<guid isPermaLink="false">https://abandonmatlab.wordpress.com/?p=173</guid>
		<description><![CDATA[T. Lennert and J. Martinez-Trujillo. Strength of response suppression to distracter stimuli determines attentional-ﬁltering performance in primate prefrontal neurons. Neuron, 70(1):141–52, Apr 2011. [pubmed] [for less ranty, try here.] Dear everyone who uses colormaps: The &#8216;jet&#8217; colormap, the default colormap in MATLAB, is a perceptual disaster. STOP USING THAT SHIT. I mean, just what is [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abandonmatlab.wordpress.com&amp;blog=8693608&amp;post=173&amp;subd=abandonmatlab&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><img src="http://abandonmatlab.files.wordpress.com/2011/05/picture-17.png?w=851&#038;h=308" alt="Picture 17.png" border="0" width="851" height="308" /></p>
<p><small>T. Lennert and J. Martinez-Trujillo. Strength of response suppression to distracter stimuli determines<br />
attentional-ﬁltering performance in primate prefrontal neurons. <i>Neuron,</i> 70(1):141–52, Apr 2011. [<a href="http://www.ncbi.nlm.nih.gov/pubmed/21482363">pubmed</a>]</small></p>
<p>[for less ranty, try <a href="http://www.research.ibm.com/dx/proceedings/pravda/truevis.htm">here</a>.]</p>
<p>Dear everyone who uses colormaps: The &#8216;jet&#8217; colormap, the default colormap in MATLAB, is a perceptual disaster. STOP USING THAT SHIT. I mean, just what is happening in the lower right sector of these plots?</p>
<p>Okay, more background. The scale is a raster of a modulation index (area under ROC, to be particular) for a group of neurons, plotted over the time from stimulus onset. The big salient feature of each plot is a yellow band. You see the yellow band because each raster plot sorts its neurons according to the &#8220;latency,&#8221; that is, the earliest time that the modulation passed some arbitrary threshold. Because that arbitrary threshold coincides with yellow, the highest-luminance value on the colormap, effectively the authors have chosen a computational and graphical procedure that says &#8220;Hey, sort my data that it makes a nice yellow stripe down the middle, NO MATTER WHAT THE DATA ACTUALLY CONTAINS.&#8221;</p>
<p>And what is happening to the right of that stripe? Well, because your spatial resolution for chroma differences (and especially for blue) is much worse than that for luminance differences (which is why sane colormaps, that are not &#8220;jet&#8221;, always have a monotonic luminance component), you have to get your nose right up to the screen to decide that under the stripe is a pretty good mixup of blue and red and yellow &#8212; all over the scale. In other words, some of these cells are well modulated past where they pass the arbitrary threshold, but a lot of cells stop being modulated at all after they dinged the threshold. Which is conveniently difficult to discern due to the colormap &#8212; and kind of raises the question of how reasonable that threshold setting is, or the cell inclusion criteria are. </p>
<p>We&#8217;ll just note in passing that the sorting is done separately for EACH subplot, so that row-by-row comparisons of the cells can&#8217;t be done, and the &#8220;neuron number&#8221; scale on the left is pretty much meaningless. Which also, by the way, fully undermines the claim that modulation for larger ordinal differences(*) happens faster.</p>
<p>I hope you noticed after you got close up to the screen, that the dark red and dark blue values are a lot harder to distinguish than, say, the yellow-to-cyan colors that makes up the middle of the scale. You know, we should be easily able to see when things are at <i>opposite ends of the scale,</i> right? I mean, if we&#8217;re <i>plotting our data</i>, I mean.</p>
<p>What kind of insane colormap has the property that values spanning the extreme ends of the scale stand out less, and can&#8217;t be distinguished as easily as values in the noisy middle? Why, it&#8217;s MATLAB&#8217;s default colormap, of course!</p>
<p>You know, <a href="http://had.co.nz/ggplot2/geom_tile.html">ggplot</a> uses a much better preset for its color maps, as well as <a href="http://had.co.nz/ggplot2/scale_brewer.html">better alternatives.</a> Just sayin&#8217;.</p>
<p>(*) You want to know the ironic punchline? This catastrophe is figure 4 of a paper ABOUT NEURAL PROCESSING OF ORDINAL COLOR SCALES. Seriously!</p>
<p><small>I&#8217;m not sure whether this belongs on the ranting-about-neuroscience blog, or the ranting-about-MATLAB blog. so it goes on both places.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/abandonmatlab.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/abandonmatlab.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/abandonmatlab.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/abandonmatlab.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/abandonmatlab.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/abandonmatlab.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/abandonmatlab.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/abandonmatlab.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/abandonmatlab.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/abandonmatlab.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/abandonmatlab.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/abandonmatlab.wordpress.com/173/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/abandonmatlab.wordpress.com/173/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/abandonmatlab.wordpress.com/173/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abandonmatlab.wordpress.com&amp;blog=8693608&amp;post=173&amp;subd=abandonmatlab&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://abandonmatlab.wordpress.com/2011/05/07/lets-talk-colormaps/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/56a9f6905eee8797a30f70f109a40853?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">crowding</media:title>
		</media:content>

		<media:content url="http://abandonmatlab.files.wordpress.com/2011/05/picture-17.png" medium="image">
			<media:title type="html">Picture 17.png</media:title>
		</media:content>
	</item>
		<item>
		<title>Graphics: you&#8217;re doing it wrong.</title>
		<link>http://abandonmatlab.wordpress.com/2010/11/01/graphics-youre-doing-it-wrong/</link>
		<comments>http://abandonmatlab.wordpress.com/2010/11/01/graphics-youre-doing-it-wrong/#comments</comments>
		<pubDate>Tue, 02 Nov 2010 02:19:01 +0000</pubDate>
		<dc:creator>crowding</dc:creator>
				<category><![CDATA[doing it wrong]]></category>
		<category><![CDATA[lying documentation]]></category>
		<category><![CDATA[powerfully stupid graphics]]></category>

		<guid isPermaLink="false">https://abandonmatlab.wordpress.com/?p=160</guid>
		<description><![CDATA[GETFRAME returns a movie frame. The frame is a snapshot of the current axis. No it bloody well isn&#8217;t. GETFRAME (as least on OS X) captures a snapshot of the portion of the display screen that might or might or might not have the current axis on top. If you have a long-running script to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abandonmatlab.wordpress.com&amp;blog=8693608&amp;post=160&amp;subd=abandonmatlab&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<blockquote><pre>GETFRAME returns a movie frame. The frame is a snapshot
    of the current axis.</pre>
</blockquote>
<p>No it bloody well isn&#8217;t. <code>GETFRAME</code> (as least on OS X) captures a snapshot of the portion of the display screen that might or might or might not have the current axis on top. If you have a long-running script to produce an animation, you might be tempted to switch over to read email or a PDF while your animation renders. In which case, when all is finished, you&#8217;ll find yourself a nice AVI file full of your email and none of your calculations. You want to render animations using <code>GETFRAME</code>, better have a single task computer to dedicate to it, and make sure to turn off the screen saver. What is this, 1992?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/abandonmatlab.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/abandonmatlab.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/abandonmatlab.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/abandonmatlab.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/abandonmatlab.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/abandonmatlab.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/abandonmatlab.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/abandonmatlab.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/abandonmatlab.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/abandonmatlab.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/abandonmatlab.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/abandonmatlab.wordpress.com/160/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/abandonmatlab.wordpress.com/160/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/abandonmatlab.wordpress.com/160/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abandonmatlab.wordpress.com&amp;blog=8693608&amp;post=160&amp;subd=abandonmatlab&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://abandonmatlab.wordpress.com/2010/11/01/graphics-youre-doing-it-wrong/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/56a9f6905eee8797a30f70f109a40853?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">crowding</media:title>
		</media:content>
	</item>
		<item>
		<title>Every time&#8230;</title>
		<link>http://abandonmatlab.wordpress.com/2010/09/26/153/</link>
		<comments>http://abandonmatlab.wordpress.com/2010/09/26/153/#comments</comments>
		<pubDate>Mon, 27 Sep 2010 05:12:13 +0000</pubDate>
		<dc:creator>crowding</dc:creator>
				<category><![CDATA[powerfully stupid graphics]]></category>

		<guid isPermaLink="false">http://abandonmatlab.wordpress.com/?p=153</guid>
		<description><![CDATA[Every time I open up MATLAB and try to do something with it, it rewards me with another anachronistic stupidity. Turns out it is seriously NOT POSSIBLE as of R2009b to have a single figure, containing plots of two images, where each image uses a different colormap. In the world where you haven&#8217;t had to worry [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abandonmatlab.wordpress.com&amp;blog=8693608&amp;post=153&amp;subd=abandonmatlab&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Every time I open up MATLAB and try to do something with it, it rewards me with another anachronistic stupidity.</p>
<p>Turns out it is seriously NOT POSSIBLE as of R2009b to have a single figure, containing plots of two images, where each image uses a different colormap.</p>
<p>In the world where you haven&#8217;t had to worry about outputting to indexed-color graphics buffers for a decade or so.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/abandonmatlab.wordpress.com/153/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/abandonmatlab.wordpress.com/153/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/abandonmatlab.wordpress.com/153/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/abandonmatlab.wordpress.com/153/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/abandonmatlab.wordpress.com/153/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/abandonmatlab.wordpress.com/153/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/abandonmatlab.wordpress.com/153/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/abandonmatlab.wordpress.com/153/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/abandonmatlab.wordpress.com/153/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/abandonmatlab.wordpress.com/153/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/abandonmatlab.wordpress.com/153/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/abandonmatlab.wordpress.com/153/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/abandonmatlab.wordpress.com/153/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/abandonmatlab.wordpress.com/153/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abandonmatlab.wordpress.com&amp;blog=8693608&amp;post=153&amp;subd=abandonmatlab&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://abandonmatlab.wordpress.com/2010/09/26/153/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/56a9f6905eee8797a30f70f109a40853?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">crowding</media:title>
		</media:content>
	</item>
		<item>
		<title>Matlab doesn&#8217;t know how to draw one ball out of an urn containing one ball.</title>
		<link>http://abandonmatlab.wordpress.com/2010/06/02/matlab-doesnt-know-how-to-draw-one-ball-out-of-an-urn-containing-one-ball/</link>
		<comments>http://abandonmatlab.wordpress.com/2010/06/02/matlab-doesnt-know-how-to-draw-one-ball-out-of-an-urn-containing-one-ball/#comments</comments>
		<pubDate>Wed, 02 Jun 2010 20:33:08 +0000</pubDate>
		<dc:creator>crowding</dc:creator>
				<category><![CDATA[matlab is bad at math]]></category>
		<category><![CDATA[trouble with small numbers]]></category>

		<guid isPermaLink="false">http://abandonmatlab.wordpress.com/?p=131</guid>
		<description><![CDATA[You are stimulating a discrete Markov process. You have a left-stochastic(*) matrix X where X(j,i) gives the probability of transitioning from state i to the state j. There are a lot of states, and most of the state transition probabilities are zero, so to fit your system into memory, you have built X as a sparse [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abandonmatlab.wordpress.com&amp;blog=8693608&amp;post=131&amp;subd=abandonmatlab&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>You are stimulating a discrete Markov process. You have a left-stochastic(*) matrix <code>X</code> where <code>X(j,i)</code> gives the probability of transitioning from state <code>i</code> to the state <code>j</code>. There are a lot of states, and most of the state transition probabilities are zero, so to fit your system into memory, you have built <code>X</code> as a sparse matrix.</p>
<p>You have the index of the current state, <code>i</code>; you want to simulate the next step and randomly draw a value for the index the next state <code>j</code>.</p>
<p>Easy enough to begin with, we find the indices and probabilities of the potential next states like this:</p>
<blockquote><p><code>nextStates = find(X(:,i));<br />
weights = X(nextStates,i);</code></p></blockquote>
<p>So now we need to generate a random draw from a discrete distribution, where we know the probability of each value of the distribution. Isn&#8217;t there a function that does that? Oh yes, <code>randsample</code>. After looking through the help for randsample (a task that is <a href="http://abandonmatlab.wordpress.com/2010/05/30/the-mathworks-doesnt-even-know-how-to-look-up-functions-in-their-own-global-namespace/">more difficult than it sounds</a>) we might write:</p>
<blockquote><p><code>j = randsample(nextStates, 1, 1, full(weights));</code></p></blockquote>
<p>Now a really easy question: How and why does this break? Answer below the fold. (hint: look at the category of the post)</p>
<p>(*) while almost all the mathematical literature uses right-stochastic matrices, in MATLAB the sparse matrices are mush slower if you use them that way.</p>
<p><span id="more-131"></span></p>
<p>Indeed, if your dynamics are such that some states have just one transition out of them, then <code>nextStates</code> will have one element, and <code>weights</code> will have just the value 1. The fun part comes in when <code>randsample</code> arbitrarily changes its behavior in response to its first argument having fewer than two elements.</p>
<p>In effect, if you ask MATLAB to randomly draw single ball out of an urn containing one red ball, it comes back with an &#8220;error:&#8221;</p>
<blockquote><p><code>"there are fewer than 'red' balls in this urn."</code></p></blockquote>
<p>Actually, what it says is:</p>
<blockquote><p><code>W must have length equal to N.<br />
 </code></p></blockquote>
<p>Which is no more helpful because you <em>did</em> supply a W that was equal in length to N.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/abandonmatlab.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/abandonmatlab.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/abandonmatlab.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/abandonmatlab.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/abandonmatlab.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/abandonmatlab.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/abandonmatlab.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/abandonmatlab.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/abandonmatlab.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/abandonmatlab.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/abandonmatlab.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/abandonmatlab.wordpress.com/131/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/abandonmatlab.wordpress.com/131/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/abandonmatlab.wordpress.com/131/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abandonmatlab.wordpress.com&amp;blog=8693608&amp;post=131&amp;subd=abandonmatlab&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://abandonmatlab.wordpress.com/2010/06/02/matlab-doesnt-know-how-to-draw-one-ball-out-of-an-urn-containing-one-ball/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/56a9f6905eee8797a30f70f109a40853?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">crowding</media:title>
		</media:content>
	</item>
		<item>
		<title>The Mathworks don&#8217;t even know how to look up functions in their own global namespace.</title>
		<link>http://abandonmatlab.wordpress.com/2010/05/30/the-mathworks-doesnt-even-know-how-to-look-up-functions-in-their-own-global-namespace/</link>
		<comments>http://abandonmatlab.wordpress.com/2010/05/30/the-mathworks-doesnt-even-know-how-to-look-up-functions-in-their-own-global-namespace/#comments</comments>
		<pubDate>Sun, 30 May 2010 08:59:27 +0000</pubDate>
		<dc:creator>crowding</dc:creator>
				<category><![CDATA[lying documentation]]></category>
		<category><![CDATA[my kingdom for a namespace]]></category>
		<category><![CDATA[thirty misfeature pileup]]></category>
		<category><![CDATA[unexpressive language]]></category>

		<guid isPermaLink="false">http://abandonmatlab.wordpress.com/?p=118</guid>
		<description><![CDATA[MATLAB went decades without having any mechanism resembling function namespaces. If you downloaded code from two authors for use in a single project, and both toolboxes defined a function of the same name, well, you were in for a headache. Case in point: the Psychtoolbox provides a function called &#8216;RandSample.&#8217; The statistics toolbox, on the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abandonmatlab.wordpress.com&amp;blog=8693608&amp;post=118&amp;subd=abandonmatlab&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>MATLAB went decades without having any mechanism resembling function namespaces. If you downloaded code from two authors for use in a single project, and both toolboxes defined a function of the same name, well, you were in for a headache.</p>
<p>Case in point: the Psychtoolbox provides a function called &#8216;RandSample.&#8217; The statistics toolbox, on the other hand, provides its own, somewhat different function named &#8216;randsample.&#8217; If you wrote some code using the Statistics toolbox &#8220;randsample&#8221;, and the person trying to use is has Psychtoolbox installed, or vice versa, you were in for problems. The code fails inside of whatever &#8216;randsample&#8217; you happen to have installed; if you are reasonably quick at deciding the problem is not with randSample itself, you jump up the stack trace a step and look at how randsample was called. (Which reminds me how MATLAB&#8217;s default behavior on an error is to print out the stack starting with the root&#8230;. and if the stack is too deep, it chops off the <em>top </em>of the stack. Whereas everyone who&#8217;s remotely sane needs to see the stack starting at the top and working downwards if there is to be any hope at debugging.)</p>
<p>Anyway, you look at this code you downloaded that calls &#8216;randsample,&#8217; and you try to work out what it&#8217;s doing. You compare the code&#8217;s usage with the documentation which you access, perhaps by typing &#8216;help randsample.&#8217; (Oh, but as we will discover below, there&#8217;s a <em>delicious</em> way MATLAB will screw you over if you try to read the doc for the function that is now failing.) Presuming you are reading the right documentation string, you try to work out what the calling code is trying to do. Only belatedly do you check &#8216;which randsample&#8217; and discover that there are two of them (or not &#8212; in case the functions being confused are capitalized differently, and you are trying to use bad old code written before case sensitivity &#8211; &#8216;which&#8217; has no option to ignore case, which is only the tip of the iceberg&#8230;) You realize, finally, that the code you&#8217;re trying to run is calling the wrong &#8216;randsample.&#8217;  And then you are presented with a dilemma: do you reorder your path to use the correct function? But what if there is other code using the one that is already on top of the path? Choose which is better, or more popular, rename the other one to &#8216;randsample_bad,&#8217; and go on a global grep-and-replace to find out which of your library functions are using the worse one, and change the name in all the places they use it? If you take that path, the next time you upgrade a new version of something you changed, your edit is going to disappear. Maybe you start maintaining patches against the upstream versions of the code you have to change, just because you are unfortunate enough to want to use more than one person&#8217;s toolbox. If the original author even knows what a version control system is so that it can provide an &#8220;upstream version.&#8221; But there&#8217;s no hope of that: you didn&#8217;t get the code from a version control repository, you got it from the <i>Mathworks File Exchange</i>.</p>
<p>So if you have any large number of MATLAB functions, you have a headache around ensuring that no two functions can have the same name. The Mathworks File Exchange even includes a tool that inspects your uploaded code to see if the names you&#8217;ve given your functions are unique enough &#8212; you get downgraded for &#8216;collisions.&#8217; (It was too hard to fix the language to make it more usable and to make code sharing easier, you see, so they fixed the website to make it less usable and to code sharing harder.) This exerts a selective pressure on the ecosystem of user-written functions, with a couple of effects. The first effect is that MATLAB function names tend to be extremely cryptic; you end up with names like (and this is just from Mathworks toolboxes and not user contributions) &#8216;etfe,&#8217;  &#8217;tf2ca,&#8217; and &#8216;cumtrapz&#8217;. The second effect is that people pack as many completely different behaviors into the same function as they can think of, just to avoid having a second function/file to drag around. The function&#8217;s behavior changes arbitrarily based on how many arguments are given, how many output arguments are taken, the classes of the inputs, and so on; helpfully there is an InputParser class that is written with sufficient unnecessary generality to preserve the completely arbitrary and pattern-free manner in which functions parse their arguments. Very frequently people wind up building functions that behave differently for an input of size 1 than they would if you logically extrapolated the behavior on larger array inputs down to an array of size one. The lack of namespacing is thus a contributing factor to the innumerable <a href="http://abandonmatlab.wordpress.com/category/trouble-with-small-numbers/">problems with small numbers</a> that MATLAB users have to deal with.</p>
<p>Up until very recently, there was simply <em>no way</em> for your code to specify that it wanted the Statistics toolbox&#8217;s &#8216;randsample&#8217; instead of some imposter. Now lately, (which is to say, about 15 to 20 years <em>too</em> lately compared to competing languages,) TMW has introduced &#8220;packages&#8221; which try to break up the global function namespace. (Technically it&#8217;s not a global function namespace, it&#8217;s a global function <em>search path</em>, which is something that is more complicated without being more helpful.) We&#8217;ll see if packages help going forward into the future. They certainly don&#8217;t help with all the existing package-less code out there.</p>
<p>Oh, but there are more wrinkles! At some point TMW decided to switch from a case insensitive global function namespace to a case sensitive one. That&#8217;s nice, I suppose, in that one function can be called &#8216;randsample&#8217; and the other can be called &#8216;RandSample&#8217; and they are technically distinct. Still, if you shipped your code to someone who had one not the other, they wouldn&#8217;t get an obvious error like &#8216;no such function&#8217; but a cryptic warning about case insensitivity being deprecated that they&#8217;re all to used to seeing and ignoring, followed by a failed program because the imposter randsample got called <em>anyway</em>.</p>
<p>Which brings me to today&#8217;s problem. When TMW introduced case sensitivity among function names, they didn&#8217;t even fix <em>their own</em> functions to reflect the change. Take, for instance, &#8216;help&#8217; and &#8216;doc.&#8217; The help for &#8216;help&#8217; says (in R2009b),</p>
<blockquote>
<pre>HELP FUN displays a description of and syntax for the function FUN.

When FUN is in multiple directories on the MATLAB path, HELP displays
information about the first FUN found on the path.</pre>
</blockquote>
<p>Great! Let&#8217;s say I&#8217;m having a problem with some code that&#8217;s calling &#8216;randsample.&#8217; Which is the first &#8216;randsample&#8217; on the path?</p>
<blockquote>
<pre>K&gt;&gt; which randsample
/Applications/MATLAB_R2009b.app/toolbox/stats/randsample.m</pre>
</blockquote>
<p>Great! How do I use it?</p>
<blockquote>
<pre>
<pre>help randsample
  x=RandSample(list,[dims])

  Returns a random sample from a list. The optional second argument may be
  used to request an array (of size dims) of independent samples. E.g.
RandSample(-1:1,[10,10]) returns a 10x10 array of samples from the list
  -1:1.  RandSample is a quick way to generate samples (e.g. visual noise)
  ...</pre>
</pre>
</blockquote>
<p>Wait, visual noise? is that really the help string for randsample?</p>
<blockquote>
<pre>K&gt;&gt; system(['head -10 ' which('randsample')])
function y = randsample(s, n, k, replace, w)
%RANDSAMPLE Random sample, with or without replacement.
%   Y = RANDSAMPLE(N,K) returns Y as a vector of K values sampled
%   uniformly at random, without replacement, from the integers 1:N.</pre>
</blockquote>
<p>Well, &#8216;help&#8217; is showing me the wrong help! Maybe I&#8217;m too used to using &#8216;help&#8217; but it&#8217;s old and everyone uses &#8216;doc&#8217; now. What&#8217;s the documentation for Psychtoolbox&#8217;s &#8216;RandSample&#8217;?</p>
<blockquote>
<pre>K&gt;&gt; which RandSample
/Users/peter/eyetracking/library/osx/Psychtoolbox/PsychProbability/RandSample.m
K&gt;&gt; doc RandSample</pre>
</blockquote>
<p>At this point I am presented with a doc window about&#8230; the Statistics Toolbox &#8216;randsample.&#8217; Which, again, is not what I asked for.</p>
<p>If The Mathworks can&#8217;t correctly navigate the stupid function namespace they created for themselves, when they try to implement basic things used every five minutes, like &#8216;help&#8217; and &#8216;doc,&#8217; how can they expect their users to tolerate it?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/abandonmatlab.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/abandonmatlab.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/abandonmatlab.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/abandonmatlab.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/abandonmatlab.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/abandonmatlab.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/abandonmatlab.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/abandonmatlab.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/abandonmatlab.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/abandonmatlab.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/abandonmatlab.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/abandonmatlab.wordpress.com/118/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/abandonmatlab.wordpress.com/118/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/abandonmatlab.wordpress.com/118/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abandonmatlab.wordpress.com&amp;blog=8693608&amp;post=118&amp;subd=abandonmatlab&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://abandonmatlab.wordpress.com/2010/05/30/the-mathworks-doesnt-even-know-how-to-look-up-functions-in-their-own-global-namespace/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/56a9f6905eee8797a30f70f109a40853?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">crowding</media:title>
		</media:content>
	</item>
		<item>
		<title>Another day, another way it doesn&#8217;t do what it say</title>
		<link>http://abandonmatlab.wordpress.com/2010/05/29/another-day-another-way-it-doesnt-do-what-it-say/</link>
		<comments>http://abandonmatlab.wordpress.com/2010/05/29/another-day-another-way-it-doesnt-do-what-it-say/#comments</comments>
		<pubDate>Sat, 29 May 2010 11:14:47 +0000</pubDate>
		<dc:creator>crowding</dc:creator>
				<category><![CDATA[lying documentation]]></category>
		<category><![CDATA[matlab is bad at math]]></category>
		<category><![CDATA[Simple trivia about its fundamental behavior that you probably can't answer]]></category>

		<guid isPermaLink="false">http://abandonmatlab.wordpress.com/?p=115</guid>
		<description><![CDATA[The documentation for sparse claims, S = sparse(i,j,s,m,n,nzmax) uses vectors i, j, and s to generate an m-by-n sparse matrix such that S(i(k),j(k)) = s(k). This claim is, plainly, false. That is to say, there are easy to find values of i, j and s where sparse(i,j,s,m,n,nzmax) produces numerically wildly different results from X = [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abandonmatlab.wordpress.com&amp;blog=8693608&amp;post=115&amp;subd=abandonmatlab&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The documentation for <code>sparse</code> claims,</p>
<blockquote><p><code>S = sparse(i,j,s,m,n,nzmax) uses vectors i, j, and s to generate an m-by-n sparse matrix such that S(i(k),j(k)) = s(k).</code></p></blockquote>
<p>This claim is, plainly, false. That is to say, there are easy to find values of i, j and s where</p>
<p><code>sparse(i,j,s,m,n,nzmax)</code></p>
<p>produces numerically wildly different results from<br />
<code><br />
X = zeros(m, n)<br />
X(sub2ind([m n], i(:), j(:))) = s(:);<br />
</code></p>
<p>and, therefore,</p>
<p><code>S = sparse(i,j,s,m,n,nzmax)<br />
if all( S( sub2ind(size(S), i, j) == s )<br />
    print("documentation passes!")<br />
else<br />
    print("documentation is lying!")<br />
end</code></p>
<p>produces the expected result (i.e. the result you expect from its being written on this blog.)</p>
<p>Can you figure out under what condition <code>sparse</code> behaves differently from the promises the documentation makes?</p>
<p>Hint: I&#8217;m populating a stochastic matrix that encodes dynamics over a discretized state space. That space has boundary conditions, so that while in the middle of the state space you might diffuse in N dimensions to your 2^N nearest grid points, at the edges of the state space you are stuck at the wall and have to reflect onto fewer points.</p>
<p>For extra credit, comment on the ease of converting code using non-sparse matrices to code using sparse matrices, given that it won&#8217;t even be numerically the same to begin with.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/abandonmatlab.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/abandonmatlab.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/abandonmatlab.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/abandonmatlab.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/abandonmatlab.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/abandonmatlab.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/abandonmatlab.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/abandonmatlab.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/abandonmatlab.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/abandonmatlab.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/abandonmatlab.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/abandonmatlab.wordpress.com/115/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/abandonmatlab.wordpress.com/115/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/abandonmatlab.wordpress.com/115/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abandonmatlab.wordpress.com&amp;blog=8693608&amp;post=115&amp;subd=abandonmatlab&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://abandonmatlab.wordpress.com/2010/05/29/another-day-another-way-it-doesnt-do-what-it-say/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/56a9f6905eee8797a30f70f109a40853?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">crowding</media:title>
		</media:content>
	</item>
		<item>
		<title>Multiple output arguments</title>
		<link>http://abandonmatlab.wordpress.com/2010/05/28/multiple-output-arguments/</link>
		<comments>http://abandonmatlab.wordpress.com/2010/05/28/multiple-output-arguments/#comments</comments>
		<pubDate>Fri, 28 May 2010 10:57:15 +0000</pubDate>
		<dc:creator>crowding</dc:creator>
				<category><![CDATA[crap data structures]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[unexpressive language]]></category>

		<guid isPermaLink="false">http://abandonmatlab.wordpress.com/?p=105</guid>
		<description><![CDATA[There are many reasons to be told why multiple output arguments in Matlab were a poor design decision. But here is a start. In an unsuccessful attempt to find a code that&#8217;s less than O(N*M) in storage for a problem that in any implementation in a real language is O(N) in storage, (*) I saw [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abandonmatlab.wordpress.com&amp;blog=8693608&amp;post=105&amp;subd=abandonmatlab&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>There are many reasons to be told why multiple output arguments in Matlab were a poor design decision. But here is a start. In an <a href="http://desk.stinkpot.org:8080/tricks/index.php/2006/03/in-matlab-find-the-array-position-of-an-entry-closest-to-some-arbitrary-value/">unsuccessful attempt to find a code that&#8217;s less than O(N*M) in storage for a problem that in any implementation in a real language is O(N) in storage</a>, (*) I saw that someone wants to know,</p>
<blockquote><p>Is there a similar way to get position information out of a matrix.</p>
<p>I tried something like,<br />
<code>[row,col]=min(min(matrix))</code><br />
but that returns only the final row that the element is in, not its exact location.</p></blockquote>
<p>This poor fellow wants to find the indices of a global minimum of a matrix. Now, <code>min</code> by itself finds the column-wise minimum of a matrix, and in a second output returns the row indices. Unless it&#8217;s a matrix with a size of 1 in the first dimension, in which case it mysteriously changes behavior and returns the row-wise minimum of a matrix. If the size of the matrix is 1 in both the first and second dimensions, it changes behavior again and gives you the minimum along the third dimension. No external indication is given of which dimension of minimum <code>min</code> happens to be pursuing&#8230; but I digress. The questioner just wants a 2-d min!</p>
<p>But here&#8217;s the thing: while composing min twice will give the global minimum of a 2-D array, there is no way you can compose two functions in one expression that makes use of the second output. So there is a failure to generalize: <code>[m,i] = min(x)</code> finds a minimum in one dimension, <strong>and </strong>tells you where the minimum is. The generalization <code>m = min(min(x)) </code>finds a minimum across two dimensions, <strong>but</strong> there is no way to use this form to find <strong>where </strong>the minimum is.</p>
<p>But here&#8217;s thing: there&#8217;s no simple expression that does it. Best I could come up with is:</p>
<p><code>i = ind2sub(size(x), second_output_of(@min, x(:)))</code></p>
<p>That will work, leaving <code>second_output_of</code> to be implemented by anyone who perceives a gaping lack in the language at this point &#8212; you see, while composing functions with multiple outputs is an ability virtually mandated by the presence of multiple outputs and the mathematical nature of the problems you might want to solve in MATLAB, the ability to use the second output <strong>in an expression</strong> is just plain missing.</p>
<p>Well, here&#8217;s an even more arcane version that uses only built in functions:</p>
<p><code>i = ind2sub(size(x), find(x == min(x(:)))</code></p>
<p>This doubles both the time and space requirements as well as bypassing the second output of min() altogether! What a lesson &#8212; if you want a simple matlab expression to find the location of a min in 2-d, you <strong>can&#8217;t</strong> use the existing function (the second output of <code>min</code>) that finds the location of a min in 1-D! Instead, you have to hunt down <code>find</code>, <code>ind2sub</code>, and the incantation <code>(:)</code> and live with code that&#8217;s twice as slow. There is no simple expression without these incantations that does it; if you want the simple compositionality of applying min twice you are limited to using multiple statements with intermediary temporary variables:</p>
<p><code>[m,r] = min(x);</code></p>
<p><code>[m,c] = min(m);</code></p>
<p><code>i = [r(c) c];</code></p>
<p>While functions with single outputs have the full compositionality of algebra available to them (well, <strong>unless</strong> you want do something simple like <strong>subscripting</strong> the output of a function, ahem), second and subsequent outputs are not composable unless you first assign their outputs to intermediary variables. This is unacceptable. A requirement of intermediary variables is <strong>evil</strong>. There is a longer post planned on this, but you may search for clues why, <a href="http://sites.google.com/site/steveyegge2/transformation">here</a> and <a href="http://books.google.com/books?id=1MsETFPD3I0C&amp;lpg=PP1&amp;dq=refactoring&amp;pg=PA120#v=onepage&amp;q&amp;f=false">here</a>, before I go live with that.</p>
<p>This is by no means the only problem with multiple outputs in MATLAB. More later.</p>
<p>(*) the answer to my original problem was something in the extra add-on ($$$) Signal Processing Toolbox. To sort points along grid lines. Well, I&#8217;m not the one paying for my license, except via externalities and frustration.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/abandonmatlab.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/abandonmatlab.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/abandonmatlab.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/abandonmatlab.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/abandonmatlab.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/abandonmatlab.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/abandonmatlab.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/abandonmatlab.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/abandonmatlab.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/abandonmatlab.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/abandonmatlab.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/abandonmatlab.wordpress.com/105/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/abandonmatlab.wordpress.com/105/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/abandonmatlab.wordpress.com/105/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=abandonmatlab.wordpress.com&amp;blog=8693608&amp;post=105&amp;subd=abandonmatlab&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://abandonmatlab.wordpress.com/2010/05/28/multiple-output-arguments/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/56a9f6905eee8797a30f70f109a40853?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">crowding</media:title>
		</media:content>
	</item>
	</channel>
</rss>
