<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.3.1" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>
<channel>
	<title>Comments on: Should min and max Marry?</title>
	<link>http://blogs.mathworks.com/loren/2008/02/27/should-min-and-max-marry/</link>
	<description>Loren Shure  works on design of the MATLAB language at The MathWorks. She writes here about once a week on MATLAB programming and related topics. </description>
	<pubDate>Mon, 12 May 2008 07:28:29 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.1</generator>
		<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2008/02/27/should-min-and-max-marry/#comment-28294</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Mon, 14 Apr 2008 11:54:27 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2008/02/27/should-min-and-max-marry/#comment-28294</guid>
		<description>Daniel-

Thanks.  I've added your suggestion to the enhancement list for consideration.

--Loren</description>
		<content:encoded><![CDATA[<p>Daniel-</p>
<p>Thanks.  I&#8217;ve added your suggestion to the enhancement list for consideration.</p>
<p>&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Armyr</title>
		<link>http://blogs.mathworks.com/loren/2008/02/27/should-min-and-max-marry/#comment-28293</link>
		<dc:creator>Daniel Armyr</dc:creator>
		<pubDate>Mon, 14 Apr 2008 11:51:02 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2008/02/27/should-min-and-max-marry/#comment-28293</guid>
		<description>1) Due to the sheer bulk of data, memory allocation and shuffling is probably the tighter bottleneck, but the variance/mean does take visible time. At this time I have a java implementation to handle these calculations in the time-critical applications, so I can't provide you with profiling output, unfortunately.

2) Well, if it were documented, I suppose some would find it. I know I looked there before posting here. But I am sure you have usability experts who can answer that question for you.</description>
		<content:encoded><![CDATA[<p>1) Due to the sheer bulk of data, memory allocation and shuffling is probably the tighter bottleneck, but the variance/mean does take visible time. At this time I have a java implementation to handle these calculations in the time-critical applications, so I can&#8217;t provide you with profiling output, unfortunately.</p>
<p>2) Well, if it were documented, I suppose some would find it. I know I looked there before posting here. But I am sure you have usability experts who can answer that question for you.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2008/02/27/should-min-and-max-marry/#comment-28283</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Sun, 13 Apr 2008 11:40:49 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2008/02/27/should-min-and-max-marry/#comment-28283</guid>
		<description>Daniel-

Congratulations on your new position!  Certainly mean and var could be combined?  I don't think it would do away with the need for mean, but could be more efficient IF people realized how to best use the new variance to get both.  The question I have for all of these thoughts is 

1) is that really a bottleneck in the code
2) will uses figure it out and find what they need

Thanks for the suggestion.
--Loren</description>
		<content:encoded><![CDATA[<p>Daniel-</p>
<p>Congratulations on your new position!  Certainly mean and var could be combined?  I don&#8217;t think it would do away with the need for mean, but could be more efficient IF people realized how to best use the new variance to get both.  The question I have for all of these thoughts is </p>
<p>1) is that really a bottleneck in the code<br />
2) will uses figure it out and find what they need</p>
<p>Thanks for the suggestion.<br />
&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Daniel Armyr</title>
		<link>http://blogs.mathworks.com/loren/2008/02/27/should-min-and-max-marry/#comment-28258</link>
		<dc:creator>Daniel Armyr</dc:creator>
		<pubDate>Fri, 11 Apr 2008 09:33:24 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2008/02/27/should-min-and-max-marry/#comment-28258</guid>
		<description>Hi.
Today I was implementing an algorithm and I came to think of this post and the idea of "marrying" related functions.

In my work I regularly calculate the mean and variance of several hundreds of matrices, each with over a milion elements. Now, this usually runs faster than one might suspect and limited amouts of RAM are generally the big problem.

However, when calculating the variance, one gets the mean as a by-product. Would it be possible for var (or a variant of it) to output the mean as well as the variance? Would it be useful? It would definately be economical.

Sincerely
Daniel Armyr
Newly appointed "Head Matlab Expert" at his department.</description>
		<content:encoded><![CDATA[<p>Hi.<br />
Today I was implementing an algorithm and I came to think of this post and the idea of &#8220;marrying&#8221; related functions.</p>
<p>In my work I regularly calculate the mean and variance of several hundreds of matrices, each with over a milion elements. Now, this usually runs faster than one might suspect and limited amouts of RAM are generally the big problem.</p>
<p>However, when calculating the variance, one gets the mean as a by-product. Would it be possible for var (or a variant of it) to output the mean as well as the variance? Would it be useful? It would definately be economical.</p>
<p>Sincerely<br />
Daniel Armyr<br />
Newly appointed &#8220;Head Matlab Expert&#8221; at his department.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike N</title>
		<link>http://blogs.mathworks.com/loren/2008/02/27/should-min-and-max-marry/#comment-27640</link>
		<dc:creator>Mike N</dc:creator>
		<pubDate>Fri, 14 Mar 2008 21:42:52 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2008/02/27/should-min-and-max-marry/#comment-27640</guid>
		<description>I would like to see MATLAB in-lining function calls, in this case, with a bit of optimisation, it would be possible to do both calculations inside a single loop, saving the time, without requiring users to make their code less clear.

A more practical example would be inlining calls to functions coded in MATLAB - making it as efficient (say) to call a function within a loop as to execute the same program with the function hand coded inside the loop.</description>
		<content:encoded><![CDATA[<p>I would like to see MATLAB in-lining function calls, in this case, with a bit of optimisation, it would be possible to do both calculations inside a single loop, saving the time, without requiring users to make their code less clear.</p>
<p>A more practical example would be inlining calls to functions coded in MATLAB - making it as efficient (say) to call a function within a loop as to execute the same program with the function hand coded inside the loop.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: aslak grinsted</title>
		<link>http://blogs.mathworks.com/loren/2008/02/27/should-min-and-max-marry/#comment-27010</link>
		<dc:creator>aslak grinsted</dc:creator>
		<pubDate>Mon, 03 Mar 2008 08:19:31 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2008/02/27/should-min-and-max-marry/#comment-27010</guid>
		<description>I'd really like to see a new "range" function giving me both min and max. In my case it is more for convenience than for speed. I really often find my self needing exactly that.</description>
		<content:encoded><![CDATA[<p>I&#8217;d really like to see a new &#8220;range&#8221; function giving me both min and max. In my case it is more for convenience than for speed. I really often find my self needing exactly that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kelly</title>
		<link>http://blogs.mathworks.com/loren/2008/02/27/should-min-and-max-marry/#comment-26970</link>
		<dc:creator>Kelly</dc:creator>
		<pubDate>Sat, 01 Mar 2008 16:15:15 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2008/02/27/should-min-and-max-marry/#comment-26970</guid>
		<description>I have my own version of a minmax function.  I won't chime in on the speed discussion, since I usually use this function for convenience rather than speed.  My usual use is to equate axis limits (or colormap limits) of several plots.  My minmax returns a single value for min and max regardless of the number of dimensions in the input data.  This way, I can just pass all the y data, or all the xdata, that I plan to plot and figure out what my axis limits need to be, like so:

ax(1) = subplot(2,1,1);
plot(x1,y1);
ax(2) = subplot(2,1,2);
plot(x2, y2);
set(ax, 'ylim', minmax([y1 y2]));

It's perhaps a trivial use, but I use it pretty often.</description>
		<content:encoded><![CDATA[<p>I have my own version of a minmax function.  I won&#8217;t chime in on the speed discussion, since I usually use this function for convenience rather than speed.  My usual use is to equate axis limits (or colormap limits) of several plots.  My minmax returns a single value for min and max regardless of the number of dimensions in the input data.  This way, I can just pass all the y data, or all the xdata, that I plan to plot and figure out what my axis limits need to be, like so:</p>
<p>ax(1) = subplot(2,1,1);<br />
plot(x1,y1);<br />
ax(2) = subplot(2,1,2);<br />
plot(x2, y2);<br />
set(ax, &#8216;ylim&#8217;, minmax([y1 y2]));</p>
<p>It&#8217;s perhaps a trivial use, but I use it pretty often.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Loren</title>
		<link>http://blogs.mathworks.com/loren/2008/02/27/should-min-and-max-marry/#comment-26944</link>
		<dc:creator>Loren</dc:creator>
		<pubDate>Fri, 29 Feb 2008 15:24:51 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2008/02/27/should-min-and-max-marry/#comment-26944</guid>
		<description>Folks-

Much food for thought here and I thank you for it.  I will mention just a couple of points.

I was trying to see how common the combined use of min and max are.  I still don't know if I have a feel for that.  I was also trying to understand how big a portion of your overall algorithms were dominated by the calls to min and max vs. spending time doing lots of other stuff as well.  My guess is that min and max, while perhaps taking some time, would not be dominant in most of your application profile reports.  But again, I don't know.

We do often have to decide in a design what to do for large for small data sizes because as Tim mentioned, algorithms can be dominated by computer architecture, etc.

As for readability, I am not sure that minAndMax, or whatever name might be used, we be much less readible than calling min and then max.  Sometimes the function names do help out.  Still I understand the desire for readability and applaud it totally.

Thanks again for chiming in!
--Loren</description>
		<content:encoded><![CDATA[<p>Folks-</p>
<p>Much food for thought here and I thank you for it.  I will mention just a couple of points.</p>
<p>I was trying to see how common the combined use of min and max are.  I still don&#8217;t know if I have a feel for that.  I was also trying to understand how big a portion of your overall algorithms were dominated by the calls to min and max vs. spending time doing lots of other stuff as well.  My guess is that min and max, while perhaps taking some time, would not be dominant in most of your application profile reports.  But again, I don&#8217;t know.</p>
<p>We do often have to decide in a design what to do for large for small data sizes because as Tim mentioned, algorithms can be dominated by computer architecture, etc.</p>
<p>As for readability, I am not sure that minAndMax, or whatever name might be used, we be much less readible than calling min and then max.  Sometimes the function names do help out.  Still I understand the desire for readability and applaud it totally.</p>
<p>Thanks again for chiming in!<br />
&#8211;Loren</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim Davis</title>
		<link>http://blogs.mathworks.com/loren/2008/02/27/should-min-and-max-marry/#comment-26942</link>
		<dc:creator>Tim Davis</dc:creator>
		<pubDate>Fri, 29 Feb 2008 13:50:21 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2008/02/27/should-min-and-max-marry/#comment-26942</guid>
		<description>randperm can be done in O(n) time, as laz points out.  I've got one in CSparse, called cs_randperm:

http://www.cise.ufl.edu/research/sparse/CSparse/CSparse/Source/cs_randperm.c

It uses a minor variant of the shuffle method laz cites on Wikipedia.  Mine is not ideal because it uses rand()%(n-k), and that's not so good because the lower bits from rand() are as "random" as the upper bits.  I didn't write it because I needed statistical purity, though.  I use it in dmperm (the one in MATLAB) except that dmperm in MATLAB doesn't have an option given to the user to use its randomized version.

Is the performance of randperm critical to your application?</description>
		<content:encoded><![CDATA[<p>randperm can be done in O(n) time, as laz points out.  I&#8217;ve got one in CSparse, called cs_randperm:</p>
<p><a href="http://www.cise.ufl.edu/research/sparse/CSparse/CSparse/Source/cs_randperm.c" rel="nofollow">http://www.cise.ufl.edu/research/sparse/CSparse/CSparse/Source/cs_randperm.c</a></p>
<p>It uses a minor variant of the shuffle method laz cites on Wikipedia.  Mine is not ideal because it uses rand()%(n-k), and that&#8217;s not so good because the lower bits from rand() are as &#8220;random&#8221; as the upper bits.  I didn&#8217;t write it because I needed statistical purity, though.  I use it in dmperm (the one in MATLAB) except that dmperm in MATLAB doesn&#8217;t have an option given to the user to use its randomized version.</p>
<p>Is the performance of randperm critical to your application?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tim Davis</title>
		<link>http://blogs.mathworks.com/loren/2008/02/27/should-min-and-max-marry/#comment-26941</link>
		<dc:creator>Tim Davis</dc:creator>
		<pubDate>Fri, 29 Feb 2008 13:41:07 +0000</pubDate>
		<guid>http://blogs.mathworks.com/loren/2008/02/27/should-min-and-max-marry/#comment-26941</guid>
		<description>Actually, there's no need to try, if you look at my previous comment.  Compare the performance of computing both the min and max at the same time ( http://www.cise.ufl.edu/~davis/minmax.c ) versus computing just the min ( http://www.cise.ufl.edu/~davis/justmin.c ).  These two functions take the same time, even though minmax.c is doing twice the number of comparisons.</description>
		<content:encoded><![CDATA[<p>Actually, there&#8217;s no need to try, if you look at my previous comment.  Compare the performance of computing both the min and max at the same time ( <a href="http://www.cise.ufl.edu/~davis/minmax.c" rel="nofollow">http://www.cise.ufl.edu/~davis/minmax.c</a> ) versus computing just the min ( <a href="http://www.cise.ufl.edu/~davis/justmin.c" rel="nofollow">http://www.cise.ufl.edu/~davis/justmin.c</a> ).  These two functions take the same time, even though minmax.c is doing twice the number of comparisons.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
