<?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/"
	>

<channel>
	<title>2718.us blog &#187; browser</title>
	<atom:link href="http://2718.us/blog/tag/browser/feed/" rel="self" type="application/rss+xml" />
	<link>http://2718.us/blog</link>
	<description>Miscellaneous Technological Geekery</description>
	<lastBuildDate>Tue, 18 May 2010 02:42:55 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>Randomizing by Random-Comparison Sorting (Revisited)</title>
		<link>http://2718.us/blog/2010/02/24/randomizing-by-random-comparison-sorting-revisited/</link>
		<comments>http://2718.us/blog/2010/02/24/randomizing-by-random-comparison-sorting-revisited/#comments</comments>
		<pubDate>Wed, 24 Feb 2010 21:09:28 +0000</pubDate>
		<dc:creator>2718.us</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[algorithms]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[browser ballot]]></category>
		<category><![CDATA[bubblesort]]></category>
		<category><![CDATA[eu]]></category>
		<category><![CDATA[european union]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[mathematica]]></category>
		<category><![CDATA[mathematics]]></category>
		<category><![CDATA[mergesort]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[nb]]></category>
		<category><![CDATA[quicksort]]></category>
		<category><![CDATA[selectionsort]]></category>
		<category><![CDATA[sort]]></category>
		<category><![CDATA[sorting]]></category>
		<category><![CDATA[sorting algorithms]]></category>
		<category><![CDATA[statistics]]></category>

		<guid isPermaLink="false">http://2718.us/blog/?p=215</guid>
		<description><![CDATA[Yesterday, I posted the results of my quick exploration of whether sorting the list {0,1,2,3,4} using a comparison function that randomly returns &#60; or &#62; (with equal probability).  My exploration was prompted by a report on the non-uniformity of the distribution of the random orderings of the browsers in Microsoft&#8217;s EU browser ballot.  I had [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday, I posted <a href="http://2718.us/blog/2010/02/23/the-eu-browser-ballot-and-random-sorting/">the results of my quick exploration</a> of whether sorting the list {0,1,2,3,4} using a comparison function that randomly returns &lt; or &gt; (with equal probability).  My exploration was prompted by <a href="http://techcrunch.com/2010/02/22/microsoft-ballot-screen/">a report on the non-uniformity of the distribution</a> of the random orderings of the browsers in <a href="http://www.browserchoice.eu/BrowserChoice/browserchoice_en.htm">Microsoft&#8217;s EU browser ballot</a>.  I had said that it seemed likely that the distribution would vary based on the sorting algorithm used.</p>
<p>Today, I have data (and code) that confirms the distribution is sorting-algorithm-dependent.  For each sorting algorithm, 1,000,000 instances of the list {0,1,2,3,4} were sorted with a random comparison function and the relative frequencies (rounded to the nearest whole percent) of each number in each position were computed.<span id="more-215"></span></p>
<table border="1" cellspacing="0">
<tbody>
<tr>
<td>Mathematica&#8217;s Sort[]</td>
<td>
<table>
<tbody>
<tr>
<td>position/number</td>
<td>0</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>first</td>
<td>18%</td>
<td>12%</td>
<td>12%</td>
<td>12%</td>
<td>46%</td>
</tr>
<tr>
<td>second</td>
<td>18%</td>
<td>24%</td>
<td>18%</td>
<td>18%</td>
<td>24%</td>
</tr>
<tr>
<td>third</td>
<td>20%</td>
<td>20%</td>
<td>26%</td>
<td>20%</td>
<td>12%</td>
</tr>
<tr>
<td>fourth</td>
<td>22%</td>
<td>22%</td>
<td>22%</td>
<td>28%</td>
<td>6%</td>
</tr>
<tr>
<td>fifth</td>
<td>22%</td>
<td>22%</td>
<td>22%</td>
<td>22%</td>
<td>12%</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td>BubbleSort</td>
<td>
<table>
<tbody>
<tr>
<td>position/number</td>
<td>0</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>first</td>
<td>36%</td>
<td>28%</td>
<td>20%</td>
<td>10%</td>
<td>6%</td>
</tr>
<tr>
<td>second</td>
<td>28%</td>
<td>32%</td>
<td>22%</td>
<td>12%</td>
<td>6%</td>
</tr>
<tr>
<td>third</td>
<td>20%</td>
<td>22%</td>
<td>32%</td>
<td>18%</td>
<td>10%</td>
</tr>
<tr>
<td>fourth</td>
<td>12%</td>
<td>12%</td>
<td>18%</td>
<td>38%</td>
<td>20%</td>
</tr>
<tr>
<td>fifth</td>
<td>6%</td>
<td>6%</td>
<td>10%</td>
<td>20%</td>
<td>60%</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td>QuickSort (random pivot)</td>
<td>
<table>
<tbody>
<tr>
<td>position/number</td>
<td>0</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>first</td>
<td>20%</td>
<td>20%</td>
<td>20%</td>
<td>20%</td>
<td>20%</td>
</tr>
<tr>
<td>second</td>
<td>20%</td>
<td>20%</td>
<td>20%</td>
<td>20%</td>
<td>20%</td>
</tr>
<tr>
<td>third</td>
<td>20%</td>
<td>20%</td>
<td>20%</td>
<td>20%</td>
<td>20%</td>
</tr>
<tr>
<td>fourth</td>
<td>20%</td>
<td>20%</td>
<td>20%</td>
<td>20%</td>
<td>20%</td>
</tr>
<tr>
<td>fifth</td>
<td>20%</td>
<td>20%</td>
<td>20%</td>
<td>20%</td>
<td>20%</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td>MergeSort</td>
<td>
<table>
<tbody>
<tr>
<td>position/number</td>
<td>0</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>first</td>
<td>24%</td>
<td>24%</td>
<td>26%</td>
<td>12%</td>
<td>12%</td>
</tr>
<tr>
<td>second</td>
<td>26%</td>
<td>24%</td>
<td>18%</td>
<td>16%</td>
<td>16%</td>
</tr>
<tr>
<td>third</td>
<td>18%</td>
<td>18%</td>
<td>22%</td>
<td>20%</td>
<td>20%</td>
</tr>
<tr>
<td>fourth</td>
<td>16%</td>
<td>16%</td>
<td>18%</td>
<td>26%</td>
<td>26%</td>
</tr>
<tr>
<td>fifth</td>
<td>16%</td>
<td>16%</td>
<td>18%</td>
<td>26%</td>
<td>26%</td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td>SelectionSort</td>
<td>
<table>
<tbody>
<tr>
<td>position/number</td>
<td>0</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>first</td>
<td>6%</td>
<td>6%</td>
<td>12%</td>
<td>26%</td>
<td>50%</td>
</tr>
<tr>
<td>second</td>
<td>12%</td>
<td>12%</td>
<td>20%</td>
<td>32%</td>
<td>24%</td>
</tr>
<tr>
<td>third</td>
<td>20%</td>
<td>20%</td>
<td>26%</td>
<td>20%</td>
<td>12%</td>
</tr>
<tr>
<td>fourth</td>
<td>30%</td>
<td>30%</td>
<td>20%</td>
<td>12%</td>
<td>6%</td>
</tr>
<tr>
<td>fifth</td>
<td>30%</td>
<td>30%</td>
<td>20%</td>
<td>12%</td>
<td>6%</td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<p>The distributions are significantly different among these sorts.  QuickSort appears to provide a uniform distribution.  I believe that this is because QuickSort will only compare a particular pair of elements once, whereas each of the other sorting algorithms may compare a given pair of elements more than once (and with a random comparison function, receive a different result from one time to the next).</p>
<p>Here is the Mathematica notebook I used to generate this data: <a href="http://2718.us/blog/wp-content/uploads/2010/02/testing-randomize-by-sorting-2.nb">Randomize by Sorting.nb</a>.  As noted in the file, some of the code for the sorting algorithms was taken from other locations and may be/is subject to their copyrights and/or license terms (I reasonably believe that this use complies with their licenses and/or constitutes fair use.  Also, some algorithms exhibited improper behavior when trying to sort lists with duplicate entries using a normal comparison function as noted in the file, though this should have no effect on the data above.</p>
]]></content:encoded>
			<wfw:commentRss>http://2718.us/blog/2010/02/24/randomizing-by-random-comparison-sorting-revisited/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The EU Browser Ballot and Random Sorting</title>
		<link>http://2718.us/blog/2010/02/23/the-eu-browser-ballot-and-random-sorting/</link>
		<comments>http://2718.us/blog/2010/02/23/the-eu-browser-ballot-and-random-sorting/#comments</comments>
		<pubDate>Wed, 24 Feb 2010 02:09:44 +0000</pubDate>
		<dc:creator>2718.us</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[browser ballot]]></category>
		<category><![CDATA[eu]]></category>
		<category><![CDATA[european union]]></category>
		<category><![CDATA[ie8]]></category>
		<category><![CDATA[internet explorer]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[math]]></category>
		<category><![CDATA[mathematica]]></category>
		<category><![CDATA[mathematics]]></category>
		<category><![CDATA[microsoft]]></category>
		<category><![CDATA[statistics]]></category>

		<guid isPermaLink="false">http://2718.us/blog/?p=212</guid>
		<description><![CDATA[An Ars Technica &#8220;etc&#8221; post linked to a TechCrunch article (apparently based on a Slovakian article, but I didn&#8217;t look into the Slovakian article to be sure) that talks about the ordering of the browsers in Microsoft&#8217;s EU Browser Ballot not being uniformly distributed.  At a glance at the Javascript that does the randomizing of [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://arstechnica.com/microsoft/news/2010/02/-the-javascript-code-on.ars">An Ars Technica &#8220;etc&#8221; post</a> linked to <a href="http://techcrunch.com/2010/02/22/microsoft-ballot-screen/">a TechCrunch article</a> (apparently based on <a href="http://www.dsl.sk/article.php?article=8770">a Slovakian article</a>, but I didn&#8217;t look into the Slovakian article to be sure) that talks about the ordering of the browsers in <a href="http://www.browserchoice.eu/BrowserChoice/browserchoice_en.htm">Microsoft&#8217;s EU Browser Ballot</a> not being uniformly distributed.  At a glance at the Javascript that does the randomizing of the browsers (randomly orders the top 5, and randomly orders the rest), it appears to randomize by calling the Javascript array sort with a comparison function that returns &lt; half the time and &gt; the other half of the time.  I believe that this is likely the underlying cause of the non-uniformity of the orderings.</p>
<p><a href="http://www.javascriptkit.com/javatutors/arraysort.shtml">The second result</a> in <a href="http://www.google.com/search?sourceid=chrome&amp;ie=UTF-8&amp;q=javascript+sort">a google search for &#8220;javascript sort&#8221;</a> says:</p>
<blockquote><p>To randomize the order of the elements within an array, what we need is the body of our sortfunction to return a number that is randomly &lt;0, 0, or &gt;0, irrespective to the relationship between &#8220;a&#8221; and &#8220;b&#8221;. The below will do the trick:</p>
<pre>//Randomize the order of the array:
var myarray=[25, 8, "George", "John"]
myarray.sort(function() {return 0.5 - Math.random()}) //Array elements now scrambled</pre>
</blockquote>
<p>This is almost exactly the method of randomization used in the browser ballot javascript.</p>
<p>To test the results of this randomization technique, I applied it 1,000,000 times to the list {0,1,2,3,4} in Mathematica and tabulated the relative frequencies of each number in each position.  (Rounded to the nearest whole %).</p>
<table>
<tbody>
<tr>
<td>position/number</td>
<td>0</td>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
</tr>
<tr>
<td>first</td>
<td>18%</td>
<td>12%</td>
<td>12%</td>
<td>12%</td>
<td>47%</td>
</tr>
<tr>
<td>second</td>
<td>18%</td>
<td>24%</td>
<td>18%</td>
<td>18%</td>
<td>24%</td>
</tr>
<tr>
<td>third</td>
<td>20%</td>
<td>21%</td>
<td>27%</td>
<td>20%</td>
<td>12%</td>
</tr>
<tr>
<td>fourth</td>
<td>22%</td>
<td>22%</td>
<td>22%</td>
<td>28%</td>
<td>6%</td>
</tr>
<tr>
<td>fifth</td>
<td>22%</td>
<td>22%</td>
<td>22%</td>
<td>22%</td>
<td>12%</td>
</tr>
</tbody>
</table>
<p>At a glance, it appears that the distribution is far from uniform.  My quick attempt at re-learning how to use the Χ<sup>2</sup> test gave a probability less than 1×10<sup>-100000</sup> that this data matched a uniform distribution (if someone can confirm/fix that, please comment).</p>
<p>I used the Mathematica Sort[] command to do the sorting.  I don&#8217;t know what algorithm that uses.  It appears that the algorithm used by Javascript&#8217;s sort() varies from browser to browser, though the browser ballot would be displayed in IE8 by default.  I suspect that the distribution is highly dependent on the sorting algorithm used, though I cannot readily verify it [<em>edit</em>: <a href="http://2718.us/blog/2010/02/24/randomizing-by-random-comparison-sorting-revisited/">I verified it</a>].  Regardless, this seems to be a very poor way to generate a random ordering.</p>
]]></content:encoded>
			<wfw:commentRss>http://2718.us/blog/2010/02/23/the-eu-browser-ballot-and-random-sorting/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Fluid: Freeing Web Apps from the Browser on OS X</title>
		<link>http://2718.us/blog/2009/06/05/fluid-freeing-web-apps-from-the-browser-on-os-x/</link>
		<comments>http://2718.us/blog/2009/06/05/fluid-freeing-web-apps-from-the-browser-on-os-x/#comments</comments>
		<pubDate>Sat, 06 Jun 2009 04:27:45 +0000</pubDate>
		<dc:creator>2718.us</dc:creator>
				<category><![CDATA[Mac OS X]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[growl]]></category>
		<category><![CDATA[hahlo]]></category>
		<category><![CDATA[lala]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[mac os x]]></category>
		<category><![CDATA[os x]]></category>
		<category><![CDATA[rememberthemilk]]></category>
		<category><![CDATA[rtm]]></category>
		<category><![CDATA[single-site]]></category>
		<category><![CDATA[single-site browser]]></category>
		<category><![CDATA[ssb]]></category>
		<category><![CDATA[twitter]]></category>
		<category><![CDATA[web app]]></category>
		<category><![CDATA[webkit]]></category>

		<guid isPermaLink="false">http://2718.us/blog/?p=150</guid>
		<description><![CDATA[Discovering Fluid has given me a lot to play with today.  Fluid itself is a program that you use to create other programs.  In Fluid, you enter the web site you want and give it a name and give it an icon and it creates an application.  That application is a Webkit (Safari-like) browser that [...]]]></description>
			<content:encoded><![CDATA[<p>Discovering <a href="http://fluidapp.com/">Fluid</a> has given me a lot to play with today.  Fluid itself is a program that you use to create other programs.  In Fluid, you enter the web site you want and give it a name and give it an icon and it creates an application.  That application is a Webkit (Safari-like) browser that is more or less dedicated to the site you selected (a &#8220;single-site browser&#8221; or SSB).  There are a variety of specific settings for different purposes, but that&#8217;s the general idea.</p>
<p>I stumbled into Fluid when I was looking for a way to keep my <a href="http://rememberthemilk.com/">RememberTheMilk</a> task list open on the side somewhere rather than always having a Firefox tab devoted to it (and trying to remember not to just close the Firefox window).  With Fluid, not only do I have an app dedicated to my RTM task list (and, since installing <a href="http://gears.google.com/">Gears</a> into Safari<sup>*</sup> makes it available to Fluid SSBs, it should have some ability to function offline, too), but I was able to create a separate menu-extra type app with the gadget interface to RTM so I can also access my task list quickly in the menu bar.</p>
<p>Having done that, it was a short skip over to having a proper <a href="http://calendar.google.com/">Google Calendar</a> app.  Nothing special there yet, save for the same hope that Gears will make it work offline.</p>
<p>More usefully, I found <a href="http://mytwitterverse.com/content/twitter-client-using-fluid-and-hahlo-growl">this post</a> about using Fluid and <a href="http://hahlo.com">Hahlo</a> along with some scripting to create a pretty good <a href="http://twitter.com/">Twitter</a> client that even uses <a href="http://growl.info/">Growl</a> notifications.  That post has all the links you need, including a direct link for the script and a link to a usable icon on Flickr.</p>
<p>Better still, it occurred to me tonight to apply Fluid to <a href="http://lala.com/">Lala</a>.  With Fluid&#8217;s option to hide the window when the user closes it, rather than actually closing it, I can &#8220;close&#8221; the window that has Lala and it keeps playing.  If I go back to my Lala SSB app, the window pops right back up.</p>
<p>Mind you, while all this web-app-turned-mac-app stuff is nice, the biggest benefit is probably the fact that if my web-browsing browser crashes, it doesn&#8217;t take my web apps with it and no one of my web apps can crash the others.  Unfortunately, Webkit seems to share one big cookie jar among all its instances, so separate Fluid-created instances won&#8217;t allow you to simultaneously log into the same site using different credentials if you couldn&#8217;t already do so (the login cookies will clobber each other and/or any such Safari cookies&#8230; though Firefox&#8217;s cookie jar is separate from Webkit&#8217;s&#8230;).</p>
<p><sup>*</sup>note that, interestingly, the Gears site displays an essentially blank page with no help or guidance whatsoever if you have javascript turned off in Safari (I mast have been testing something or other without javascript and forgotten to turn it back on).</p>
]]></content:encoded>
			<wfw:commentRss>http://2718.us/blog/2009/06/05/fluid-freeing-web-apps-from-the-browser-on-os-x/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

