<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4652888793139849030</id><updated>2024-09-28T21:10:45.968-04:00</updated><title type='text'>Pat Canny Online</title><subtitle type='html'>An evolving, inconsistently updated record of my thought process.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://patcanny.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://patcanny.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Pat</name><uri>http://www.blogger.com/profile/06278702331176564567</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>864</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4652888793139849030.post-2279070194284669842</id><published>2014-12-29T11:49:00.000-05:00</published><updated>2014-12-29T11:49:28.060-05:00</updated><title type='text'>MATLAB Script: Dealing Cards</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;
I played cards (poorly) over Christmas, and thought a good way to break through the end-of-year boredom at work would be to write a quick MATLAB script that dealt a given number of cards from a randomly shuffled deck to a given number of players.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
I got to use the eval command again, which is always exciting.&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;% Randomly shuffle a deck of cards&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;% Distribute to a given number of players (user input)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;% Display the hands for each player&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;% Assign a number for each card&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;% 1-13 are for Spades (in order)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;% 14-26 are for Clubs&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;% 27-39 are for Diamonds&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;% 40-52 are for Hearts&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{1} = &#39;2 of Spades&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{2} = &#39;3 of Spades&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{3} = &#39;4 of Spades&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{4} = &#39;5 of Spades&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{5} = &#39;6 of Spades&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{6} = &#39;7 of Spades&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{7} = &#39;8 of Spades&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{8} = &#39;9 of Spades&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{9} = &#39;10 of Spades&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{10} = &#39;Jack of Spades&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{11} = &#39;Queen of Spades&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{12} = &#39;King of Spades&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{13} = &#39;Ace of Spades&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{14} = &#39;2 of Clubs&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{15} = &#39;3 of Clubs&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{16} = &#39;4 of Clubs&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{17} = &#39;5 of Clubs&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{18} = &#39;6 of Clubs&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{19} = &#39;7 of Clubs&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{20} = &#39;8 of Clubs&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{21} = &#39;9 of Clubs&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{22} = &#39;10 of Clubs&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{23} = &#39;Jack of Clubs&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{24} = &#39;Queen of Clubs&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{25} = &#39;King of Clubs&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{26} = &#39;Ace of Clubs&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{27} = &#39;2 of Diamonds&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{28} = &#39;3 of Diamonds&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{29} = &#39;4 of Diamonds&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{30} = &#39;5 of Diamonds&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{31} = &#39;6 of Diamonds&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{32} = &#39;7 of Diamonds&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{33} = &#39;8 of Diamonds&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{34} = &#39;9 of Diamonds&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{35} = &#39;10 of Diamonds&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{36} = &#39;Jack of Diamonds&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{37} = &#39;Queen of Diamonds&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{38} = &#39;King of Diamonds&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{39} = &#39;Ace of Diamonds&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{40} = &#39;2 of Hearts&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{41} = &#39;3 of Hearts&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{42} = &#39;4 of Hearts&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{43} = &#39;5 of Hearts&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{44} = &#39;6 of Hearts&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{45} = &#39;7 of Hearts&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{46} = &#39;8 of Hearts&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{47} = &#39;9 of Hearts&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{48} = &#39;10 of Hearts&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{49} = &#39;Jack of Hearts&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{50} = &#39;Queen of Hearts&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{51} = &#39;King of Hearts&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;card_names{52} = &#39;Ace of Hearts&#39;;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;% Shuffle the deck&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;shuffled_deck = randperm(52);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;% Ask the user for # of players and # of cards per player&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;clc&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;num_players = input(&#39;How many players? Enter here: &#39;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;num_cards = input(&#39;How many cards per player? Enter here: &#39;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;disp(&#39;----------------------&#39;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;% Create empty player hand arrays&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;for k=1:1:num_players&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; plyr_hnd_cmd_str = [&#39;player_hand_&#39;,num2str(k), &#39;= [];&#39;];&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; eval(plyr_hnd_cmd_str);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;end&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;% Deal cards out to the players&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;total_cards_to_deal = num_players * num_cards;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;i=1;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;while i &amp;lt; total_cards_to_deal&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; for j=1:1:num_players&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; deal_card_cmd_str = [&#39;player_hand_&#39;, num2str(j), &#39; = [player_hand_&#39;,num2str(j), &#39;, shuffled_deck(i)];&#39;];&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; eval(deal_card_cmd_str);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; i = i+1;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; end &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;end&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;% Display each player&#39;s hand&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;for k=1:1:num_players&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; disp_plyr_str = [&#39;Player &#39;, num2str(k), &#39;&#39;&#39;s hand: &#39;];&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; disp(disp_plyr_str)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; for m=1:1:num_cards&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; card_name_cmd_str = [&#39;card_name_str = card_names{player_hand_&#39;, num2str(k), &#39;(m)};&#39;];&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; eval(card_name_cmd_str)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; disp(card_name_str)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; end&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; disp(&#39;----------------------&#39;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;end&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://patcanny.blogspot.com/feeds/2279070194284669842/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4652888793139849030/2279070194284669842' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/2279070194284669842'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/2279070194284669842'/><link rel='alternate' type='text/html' href='http://patcanny.blogspot.com/2014/12/matlab-script-dealing-cards.html' title='MATLAB Script: Dealing Cards'/><author><name>Pat</name><uri>http://www.blogger.com/profile/06278702331176564567</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4652888793139849030.post-538453118772998958</id><published>2014-12-19T14:11:00.001-05:00</published><updated>2014-12-19T14:11:46.117-05:00</updated><title type='text'>MATLAB Script: Best MBA Course</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Helvetica Neue, Arial, Helvetica, sans-serif;&quot;&gt;Upon the completion of my MBA at BU, I wanted to figure out what my top 5 courses (out of 18) were.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Helvetica Neue, Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Helvetica Neue, Arial, Helvetica, sans-serif;&quot;&gt;So I wrote a brute-force, unsexy MATLAB script that did a round-robin style side-by-side comparison.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Helvetica Neue, Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Helvetica Neue, Arial, Helvetica, sans-serif;&quot;&gt;It worked out fairly well. I even put in a very rudimentary tiebreaker loop wherein the user is asked to break the tie. Basically a &quot;head to head&quot; comparison, which, upon further review, should be pre-determined, since the user had already done a head-to-head comparison of the two courses before. Room for improvement.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Helvetica Neue, Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Helvetica Neue, Arial, Helvetica, sans-serif;&quot;&gt;Here it is:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;% Determines the ranking of best MBA courses taken&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;% The user picks the best course by choosing between all combinations&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;clc&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;clear&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;num_courses = 18;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;% Create the list of courses&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;% Course 1: &quot;OB 712: Managing Organizations&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;course_names{1} = &#39;OB 712: Managing Organizations&#39;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;% Course 2: &quot;AC 711: Accounting&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;course_names{2} = &#39;AC 711: Accounting&#39;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;% Course 3: &quot;MK 724: Marketing Management&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;course_names{3} = &#39;MK 724: Marketing Management&#39;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;% Course 4: &quot;QM 717: Statistics&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;course_names{4} = &#39;QM 717: Statistics&#39;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;% Course 5: &quot;FE 730: Economics&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;course_names{5} = &#39;FE 730: Economics&#39;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;% Course 6: &quot;IS 711: IT Strategies&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;course_names{6} = &#39;IS 711: IT Strategies&#39;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;% Course 7: &quot;OM 726: Operations&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;course_names{7} = &#39;OM 726: Operations&#39;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;% Course 8: &quot;SI 751: Strategy&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;course_names{8} = &#39;SI 751: Strategy&#39;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;% Course 9: &quot;PL 700: Law and Ethics&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;course_names{9} = &#39;PL 700: Law and Ethics&#39;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;% Course 10: &quot;ES 700: Executive Presentation&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;course_names{10} = &#39;ES 700: Executive Presentation&#39;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;% Course 11: &quot;OB 853: Negotiations&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;course_names{11} = &#39;OB 853: Negotiations&#39;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;% Course 12: &quot;OM 880: Product Design&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;course_names{12} = &#39;OM 880: Product Design&#39;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;% Course 13: &quot;MK 864: Pricing&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;course_names{13} = &#39;MK 864: Pricing&#39;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;% Course 14: &quot;MK 862: High-Tech Marketing&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;course_names{14} = &#39;MK 862: High-Tech Marketing&#39;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;% Course 15: &quot;IS 827: Platforms&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;course_names{15} = &#39;IS 827: Platforms&#39;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;% Course 16: &quot;OB 848: Leadership&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;course_names{16} = &#39;OB 848: Leadership&#39;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;% Course 17: &quot;MK 852: Marketing Analytics&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;course_names{17} = &#39;MK 852: Marketing Analytics&#39;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;% Course 18: &quot;SI 845: Technology Strategy&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;course_names{18} = &#39;SI 845: Technology Strategy&#39;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;% ES 700 and FE 722 were not considered for ranking&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;% Create a 2x18 matrix of randomly determined combinations&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;rand_course_combs = rand_combs(num_courses);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;%rand_course_combs = rand_combs2(num_courses); %Alternative algorithm that doesn&#39;t use Statistics Toolbox&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;len_rand_course_combs = length(rand_course_combs);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;points_array = zeros(1,num_courses);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;better_course = 0;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;for i=1:1:len_rand_course_combs&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; course_1_name = char(course_names(rand_course_combs(i,1)));&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; course_2_name = char(course_names(rand_course_combs(i,2)));&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; prompt_str = [course_1_name, &#39; (1) vs. &#39;,course_2_name, &#39; (2): &#39;];&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; clc&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; pct_cmplt = 100*((i-1)/len_rand_course_combs);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; pct_cmplt_str = [num2str(pct_cmplt), &#39;% complete&#39;];&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; disp(pct_cmplt_str)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; disp(&#39;Which one was better?&#39;);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; better_course = input(prompt_str);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if better_course == 1&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;points_array(rand_course_combs(i,1)) = points_array(rand_course_combs(i,1)) + 1;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;elseif better_course == 2&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;points_array(rand_course_combs(i,2)) = points_array(rand_course_combs(i,2)) + 1;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;end&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;end&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;% Sort, rank, and display&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;sorted_points_array = sort(points_array,&#39;descend&#39;);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;len_points_array = length(points_array);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;rank_array = zeros(1,len_points_array);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;i=1;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;while i &amp;lt;= len_points_array&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp;rank_array_temp = find(points_array == sorted_points_array(i));&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp;if length(rank_array_temp) &amp;gt; 1&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;% Assumes only two values will be &quot;tied&quot;. Should probably make this&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;% more robust.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;% Break the tie by prompting user to pick the better option&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;disp(&#39;Found a tie!&#39;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;disp(&#39;Need to break it!&#39;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;disp(&#39;Which one was better?&#39;)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;course_1_name = course_names{rank_array_temp(1)};&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;course_2_name = course_names{rank_array_temp(2)};&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;prompt_str = [course_1_name, &#39; (1) vs. &#39;,course_2_name, &#39; (2): &#39;];&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;tiebreaker_choice = input(prompt_str);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if tiebreaker_choice == 1&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; rank_array(i) = rank_array_temp(1);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; rank_array(i+1) = rank_array_temp(2);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;else&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; rank_array(i) = rank_array_temp(2);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; rank_array(i+1) = rank_array_temp(1);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;end&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;i=i+2;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp;else&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp;rank_array(i) = find(points_array == sorted_points_array(i));&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp;i=i+1;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp;end&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;end&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;len_rank_array = length(rank_array);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;for j = 1:1:len_rank_array&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; clc&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp;disp_str = [num2str(j), &#39;: &#39;,course_names{rank_array(j)}, &#39; : &#39;,num2str(sorted_points_array(j)), &#39; points.&#39;];&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; disp(disp_str)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;end&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Helvetica Neue, Arial, Helvetica, sans-serif;&quot;&gt;Here were the results:&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Helvetica Neue, Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Helvetica Neue, Arial, Helvetica, sans-serif;&quot;&gt;1: OM 880: Product Design : 17 points.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Helvetica Neue, Arial, Helvetica, sans-serif;&quot;&gt;2: IS 827: Platforms : 16 points.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Helvetica Neue, Arial, Helvetica, sans-serif;&quot;&gt;3: OB 853: Negotiations : 15 points.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Helvetica Neue, Arial, Helvetica, sans-serif;&quot;&gt;4: MK 862: High-Tech Marketing : 14 points.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Helvetica Neue, Arial, Helvetica, sans-serif;&quot;&gt;5: MK 852: Marketing Analytics : 13 points.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Helvetica Neue, Arial, Helvetica, sans-serif;&quot;&gt;6: MK 724: Marketing Management : 12 points.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Helvetica Neue, Arial, Helvetica, sans-serif;&quot;&gt;7: SI 751: Strategy : 11 points.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Helvetica Neue, Arial, Helvetica, sans-serif;&quot;&gt;8: FE 730: Economics : 10 points.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Helvetica Neue, Arial, Helvetica, sans-serif;&quot;&gt;9: AC 711: Accounting : 9 points.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Helvetica Neue, Arial, Helvetica, sans-serif;&quot;&gt;10: SI 845: Technology Strategy : 8 points.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Helvetica Neue, Arial, Helvetica, sans-serif;&quot;&gt;11: OB 712: Managing Organizations : 7 points.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Helvetica Neue, Arial, Helvetica, sans-serif;&quot;&gt;12: MK 864: Pricing : 6 points.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Helvetica Neue, Arial, Helvetica, sans-serif;&quot;&gt;13: ES 700: Executive Presentation : 4 points.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Helvetica Neue, Arial, Helvetica, sans-serif;&quot;&gt;14: OM 726: Operations : 4 points.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Helvetica Neue, Arial, Helvetica, sans-serif;&quot;&gt;15: OB 848: Leadership : 3 points.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Helvetica Neue, Arial, Helvetica, sans-serif;&quot;&gt;16: IS 711: IT Strategies : 2 points.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Helvetica Neue, Arial, Helvetica, sans-serif;&quot;&gt;17: QM 717: Statistics : 2 points.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Helvetica Neue, Arial, Helvetica, sans-serif;&quot;&gt;18: PL 700: Law and Ethics : 0 points.&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://patcanny.blogspot.com/feeds/538453118772998958/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4652888793139849030/538453118772998958' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/538453118772998958'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/538453118772998958'/><link rel='alternate' type='text/html' href='http://patcanny.blogspot.com/2014/12/matlab-script-best-mba-course.html' title='MATLAB Script: Best MBA Course'/><author><name>Pat</name><uri>http://www.blogger.com/profile/06278702331176564567</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4652888793139849030.post-8620394726876238315</id><published>2014-07-03T11:45:00.000-04:00</published><updated>2014-07-03T11:45:32.470-04:00</updated><title type='text'>Improved Script</title><content type='html'>I decided to get a little fancy with the &quot;random PDF&quot; script from my last post.&lt;br /&gt;
&lt;br /&gt;
I modified the random selection element to be weighted based on age. I decided to start simple by simply dividing file age (in days) by 10 (I&#39;ll try using the log next), rounding up (using math.ceil) and randomly selecting from a new array (called &quot;weighted_files&quot;) which gives more weight to older files. Basically: I want it to be more likely that an older file is opened rather than a newer file. My reading model has now shifted to a FIFO scheme.&lt;br /&gt;
&lt;br /&gt;
Here it is, with a few comments.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;#! /usr/bin/python&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;import time, os, math, sys, shutil&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;from random import randint&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;clear = lambda: os.system(&#39;cls&#39;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;clear()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;path = &#39;&lt;span style=&quot;color: red;&quot;&gt;[DIRECTORY WITH PDF FILES IN IT]&lt;/span&gt;&#39;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;pdf_files = [f for f in os.listdir(path) if f.endswith(&#39;.pdf&#39;)]&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;len_pdf_files = len(pdf_files)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;if len_pdf_files == 0:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;print (&quot;No PDF files found!&quot;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;time.sleep(3)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;sys.exit(0)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;pdf_ages = []&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;for pdf_file in pdf_files:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;os.rename(os.path.join(path, pdf_file), os.path.join(path, pdf_file.replace(&#39; &#39;, &#39;_&#39;)))&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;file_loc = path + &#39;/&#39; + pdf_file&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;file_age_sec = time.time() - os.path.getmtime(file_loc)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;file_age_days = file_age_sec/60/60/24&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;file_age_days_round = math.floor(file_age_days)&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;pdf_ages.append(file_age_days_round)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;# Build an array for use in weighted random selection&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;weighted_files = []&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;weighting_factor = 10 # arbitrary&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;for index, pdf_age in enumerate(pdf_ages):&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;weight = math.ceil(pdf_age/weighting_factor)&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;# Adds the index number (from pdf_ages, which should match pdf_files) in proportion to the weight&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;for i in range(0,weight):&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;weighted_files.append(index)&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;len_weighted_files = len(weighted_files)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;rand_int = randint(0,len_weighted_files-1)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;pdf_files_index = weighted_files[rand_int]&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;file_name_str = str(pdf_files[pdf_files_index])&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;file_loc_str = path + &#39;/&#39; + file_name_str&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;pdf_cmd_str = &quot;start &quot; + file_loc_str&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;os.system(pdf_cmd_str)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;valid_command = 0&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;while valid_command == 0 :&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;delete_file = input(&quot;Delete file? Y or N: &quot;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if (delete_file == &quot;Y&quot; or delete_file == &quot;y&quot;):&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;os.remove(file_loc_str)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;print (file_name_str + &quot; has been deleted! Good work!&quot;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;new_num_pdfs = len_pdf_files - 1&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;new_num_pdfs_str = str(new_num_pdfs)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;print (&quot;There are now &quot;,new_num_pdfs_str,&quot; PDFs remaining.&quot;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;time.sleep(3)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;valid_command = 1&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;sys.exit(0)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;elif (delete_file == &quot;N&quot; or delete_file == &quot;n&quot;):&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;print (&quot;Fine then, but next time, delete it!&quot;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;dest_folder_loc_str = &#39;D:/Users/a27m8mt/Documents/Things_To_Read/Hold_for_later/&#39;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;shutil.move(file_loc_str,dest_folder_loc_str)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;print (file_name_str + &quot; has been moved to the holding folder: &quot; + dest_folder_loc_str)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;time.sleep(3)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;valid_command = 1&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;sys.exit(0)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;else:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;print (&quot;Invalid command. Try again.&quot;)&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://patcanny.blogspot.com/feeds/8620394726876238315/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4652888793139849030/8620394726876238315' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/8620394726876238315'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/8620394726876238315'/><link rel='alternate' type='text/html' href='http://patcanny.blogspot.com/2014/07/improved-script.html' title='Improved Script'/><author><name>Pat</name><uri>http://www.blogger.com/profile/06278702331176564567</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4652888793139849030.post-432608987257248788</id><published>2014-07-01T14:07:00.002-04:00</published><updated>2014-07-01T14:07:30.808-04:00</updated><title type='text'>Python Script for Opening a Random PDF in a Given Directory</title><content type='html'>I decided to try learning Python, so I came up with a script of nominal utility. It&#39;s probably quite ugly, but it works.&lt;br /&gt;
&lt;br /&gt;
It opens a random PDF from a directory full of PDFs that I&#39;ve accumulated over the past year or so of articles I&#39;ve been meaning to read. At the end, it prompts the user to save or delete the file. It&#39;s quite cathartic.&lt;br /&gt;
&lt;br /&gt;
If you have a similar problem, I hope this helps clean up your life a bit. Red text is where you fill in the blanks. If you&#39;re using Windows, make sure to use forward slashes for the path (e.g. &#39;D:/users/something/something&#39;)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;import os, sys, time&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;from random import randint&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;# Clear the command window&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;clear = lambda: os.system(&#39;cls&#39;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;clear()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;# Set the path with all of the PDF files&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;path = &#39;&lt;span style=&quot;color: red;&quot;&gt;[directory with all of the files]&lt;/span&gt;&#39;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;# Create a list of all of the PDF files&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;pdf_files = [f for f in os.listdir(path) if f.endswith(&#39;.pdf&#39;)]&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;# Clean up the names by removing spaces&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;for pdf_file in pdf_files:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;os.rename(os.path.join(path, pdf_file), os.path.join(path, pdf_file.replace(&#39; &#39;, &#39;_&#39;)))&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;len_pdf_files = len(pdf_files)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;# Generate a random number&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;rand_int = randint(0,len_pdf_files)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;# Get the name of a random PDF file&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;file_name_str = str(pdf_files[rand_int])&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;file_loc_str = path + &#39;/&#39; + file_name_str&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;# Generate a string to be used to open the file&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;pdf_cmd_str = &quot;start &quot; + file_loc_str # Windows uses &quot;start&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;# Open the file&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;os.system(pdf_cmd_str)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;# Prompt the user to delete the file&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;delete_file = input(&quot;Delete file? Y or N: &quot;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;if delete_file == &quot;Y&quot;:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;os.remove(file_loc_str)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;print (file_name_str + &quot; deleted! Good work!&quot;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;# Give the user a few seconds to read the statement&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;time.sleep(3)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;sys.exit(0)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;else:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;# Chastise them for being a hoarder, while enabling them&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;print (&quot;Fine then, but next time, delete it!&quot;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;time.sleep(3)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Courier New, Courier, monospace;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;sys.exit(0)&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://patcanny.blogspot.com/feeds/432608987257248788/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4652888793139849030/432608987257248788' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/432608987257248788'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/432608987257248788'/><link rel='alternate' type='text/html' href='http://patcanny.blogspot.com/2014/07/python-script-for-opening-random-pdf-in.html' title='Python Script for Opening a Random PDF in a Given Directory'/><author><name>Pat</name><uri>http://www.blogger.com/profile/06278702331176564567</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4652888793139849030.post-6470750307349544771</id><published>2013-10-31T21:23:00.001-04:00</published><updated>2013-10-31T21:23:11.522-04:00</updated><title type='text'>&quot;How The Economic Machine Works&quot; by Ray Dalio</title><content type='html'>Lovely. &lt;br /&gt;
&lt;br /&gt;
&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;315&quot; src=&quot;//www.youtube.com/embed/PHe0bXAIuk0&quot; width=&quot;420&quot;&gt;&lt;/iframe&gt;</content><link rel='replies' type='application/atom+xml' href='http://patcanny.blogspot.com/feeds/6470750307349544771/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4652888793139849030/6470750307349544771' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/6470750307349544771'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/6470750307349544771'/><link rel='alternate' type='text/html' href='http://patcanny.blogspot.com/2013/10/how-economic-machine-works-by-ray-dalio.html' title='&quot;How The Economic Machine Works&quot; by Ray Dalio'/><author><name>Pat</name><uri>http://www.blogger.com/profile/06278702331176564567</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4652888793139849030.post-1939104870606733951</id><published>2013-10-07T13:40:00.001-04:00</published><updated>2013-10-07T13:40:37.060-04:00</updated><title type='text'>TED: Michael Porter on the role of business in solving social problems</title><content type='html'>Nothing really ground-breaking, but I like Porter&#39;s points.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;480&quot; src=&quot;//www.youtube.com/embed/0iIh5YYDR2o?rel=0&quot; width=&quot;640&quot;&gt;&lt;/iframe&gt;</content><link rel='replies' type='application/atom+xml' href='http://patcanny.blogspot.com/feeds/1939104870606733951/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4652888793139849030/1939104870606733951' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/1939104870606733951'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/1939104870606733951'/><link rel='alternate' type='text/html' href='http://patcanny.blogspot.com/2013/10/ted-michael-porter-on-role-of-business.html' title='TED: Michael Porter on the role of business in solving social problems'/><author><name>Pat</name><uri>http://www.blogger.com/profile/06278702331176564567</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4652888793139849030.post-2734276589401152700</id><published>2013-09-06T17:21:00.001-04:00</published><updated>2013-09-06T17:21:10.559-04:00</updated><title type='text'>Underground Automatic Bike Parking System</title><content type='html'>&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;360&quot; src=&quot;http://www.youtube.com/embed/vK9C9VtCypE?feature=player_embedded&quot; width=&quot;640&quot;&gt;&lt;/iframe&gt;&lt;br /&gt;
&lt;br /&gt;
Hat tip: &lt;i&gt;&lt;a href=&quot;http://www.theatlanticcities.com/commute/2013/09/eight-more-brilliant-pieces-bike-infrastructure/6803/&quot; target=&quot;_blank&quot;&gt;The Atlantic&lt;/a&gt;&lt;/i&gt;</content><link rel='replies' type='application/atom+xml' href='http://patcanny.blogspot.com/feeds/2734276589401152700/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4652888793139849030/2734276589401152700' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/2734276589401152700'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/2734276589401152700'/><link rel='alternate' type='text/html' href='http://patcanny.blogspot.com/2013/09/underground-automatic-bike-parking.html' title='Underground Automatic Bike Parking System'/><author><name>Pat</name><uri>http://www.blogger.com/profile/06278702331176564567</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/vK9C9VtCypE/default.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4652888793139849030.post-2347288089914837865</id><published>2013-08-08T15:54:00.003-04:00</published><updated>2013-08-08T15:59:09.506-04:00</updated><title type='text'>Prisoner&#39;s Dilemma Example and the Coalition Game</title><content type='html'>A great example of the &lt;a href=&quot;http://en.wikipedia.org/wiki/Prisoner&#39;s_dilemma&quot; target=&quot;_blank&quot;&gt;Prisoner&#39;s Dilemma&lt;/a&gt; via &lt;a href=&quot;http://kottke.org/&quot;&gt;kottke.org&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;


&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;360&quot; src=&quot;http://www.youtube.com/embed/S0qjK3TWZE8?feature=player_embedded&quot; width=&quot;640&quot;&gt;&lt;/iframe&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Note Nick&#39;s insistence upon picking &quot;Steal&quot; right away, which put Ibraham in the position of taking a serious leap of faith. I was surprised by the ending.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
I actually had a similar experience last night in my &lt;a href=&quot;http://www.negotiatingtable.com/&quot; target=&quot;_blank&quot;&gt;Negotiations class&lt;/a&gt;. We played &quot;The Coalition Game,&quot; which went like so:&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Three teams (A, B, and C) discuss how to split a pot of money. The pot of money can only be split between two teams (the coalition), leaving one team out. The pot of money to be split depends on which two teams form the coalition. The pot cannot be split evenly, and neither team can accept less than $0.01.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
If Team A and Team B form a coalition, they split $20.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
If Team A and Team C form a coalition, they split $16.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
If Team B and Team C form a coalition, they split $12.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
A coalition is formed only when two teams, after 9 rounds of one-on-one negotiations (order is below), agree on how to split the pot with one other team. After the final round of discussions, each team, individually and secretly, submits a slip of paper with their perceived agreement with another team. If none of the slips match, there is no coalition, and every one walks away with nothing.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Each team negotiates with one other team at a time, with the other team outside the room.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
The order of negotiations is:&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
AB&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
AC&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
BC&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
(repeated twice more)&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
I was on Team A. We started off by offering Team B $13, with us taking $7.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
We ended up outside the coalition at the end. It was a good exercise in trust and simple human greed.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://patcanny.blogspot.com/feeds/2347288089914837865/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4652888793139849030/2347288089914837865' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/2347288089914837865'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/2347288089914837865'/><link rel='alternate' type='text/html' href='http://patcanny.blogspot.com/2013/08/prisoners-dilemma-example-and-coalition.html' title='Prisoner&#39;s Dilemma Example and the Coalition Game'/><author><name>Pat</name><uri>http://www.blogger.com/profile/06278702331176564567</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/S0qjK3TWZE8/default.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4652888793139849030.post-4905561994493486085</id><published>2013-06-22T15:17:00.001-04:00</published><updated>2013-06-22T15:24:13.400-04:00</updated><title type='text'>The Police - &quot;Invisible Sun&quot;</title><content type='html'>One of my favorite songs by The Police. The video is unavailable online in the U.S. RSS folks: click through if you can&#39;t see the video below.


&lt;br /&gt;
&lt;br /&gt;
&lt;object classid=&quot;clsid:D27CDB6E-AE6D-11cf-96B8-444553540000&quot; codebase=&quot;http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0&quot; height=&quot;360&quot; width=&quot;480&quot;&gt;&lt;param name=&#39;flashvars&#39; value=&#39;id=1053&amp;affiliate_id=blogs&amp;autoplay=false&#39;&gt;&lt;param name=&#39;quality&#39; value=&#39;high&#39;&gt;&lt;param name=&#39;wmode&#39; value=&#39;transparent&#39;&gt; &lt;param name=&#39;allowscriptaccess&#39; value=&#39;always&#39;&gt; &lt;param name=&#39;allowfullscreen&#39; value=&#39;true&#39;&gt; &lt;param name=&#39;movie&#39; value=&#39;http://player.universalmusic.fr/AC_player.swf&#39;&gt;&lt;embed src=&#39;http://player.universalmusic.fr/AC_player.swf&#39;  quality=&#39;high&#39;  width=&#39;480&#39;  height=&#39;360&#39;  flashvars=&#39;log=enabled&amp;id=1053&amp;affiliate_id=blogs&amp;autoplay=false&#39;  type=&#39;application/x-shockwave-flash&#39;  pluginspage=&#39;http://www.macromedia.com/go/getflashplayer&#39; allowscriptaccess=&#39;always&#39;  allowfullscreen=&#39;true&#39; wmode=&quot;transparent&quot;&gt;&lt;/embed&gt;&lt;/object&gt;</content><link rel='replies' type='application/atom+xml' href='http://patcanny.blogspot.com/feeds/4905561994493486085/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4652888793139849030/4905561994493486085' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/4905561994493486085'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/4905561994493486085'/><link rel='alternate' type='text/html' href='http://patcanny.blogspot.com/2013/06/the-police-invisible-sun.html' title='The Police - &quot;Invisible Sun&quot;'/><author><name>Pat</name><uri>http://www.blogger.com/profile/06278702331176564567</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4652888793139849030.post-1331550138089944227</id><published>2013-06-10T11:11:00.000-04:00</published><updated>2013-06-10T11:12:14.485-04:00</updated><title type='text'>Function Version: Determining Effective APY</title><content type='html'>&lt;div dir=&quot;ltr&quot;&gt;In case you&amp;#39;re more into functions:&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;function effective_apy_midpoint = effective_APY_midpoint(P,Y,n)&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;% Determines the effective annual yield (APY) given a principal amount, &lt;/div&gt;    &lt;div&gt;% a final amount, and number of years.&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;% Need to calculate r (APY)&lt;/div&gt;&lt;div&gt;% Use mid-point algorithm&lt;/div&gt;&lt;div&gt;% Formula is Y = P(1+r)^n&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;% Assume range of r from 0 to 5 (0 % to 300%)&lt;/div&gt;    &lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;r_min = 0;&lt;/div&gt;&lt;div&gt;r_max = 5;&lt;/div&gt;&lt;div&gt;current_guess = r_min;&lt;/div&gt;&lt;div&gt;Y_temp = P*(1+current_guess)^n;&lt;/div&gt;&lt;div&gt;num_guesses = 1;&lt;/div&gt;&lt;div&gt;while Y_temp ~= Y&lt;/div&gt;&lt;div&gt;    if (Y_temp &amp;gt; Y*0.9999) &amp;amp;&amp;amp; (Y_temp &amp;lt; Y*1.0001)&lt;/div&gt;    &lt;div&gt;        break&lt;/div&gt;&lt;div&gt;    end&lt;/div&gt;&lt;div&gt;    if Y_temp &amp;lt; Y&lt;/div&gt;&lt;div&gt;    next_guess = (current_guess + r_max)/2;&lt;/div&gt;&lt;div&gt;    else next_guess = (r_min + current_guess)/2;&lt;/div&gt;&lt;div&gt;    end&lt;/div&gt;&lt;div&gt;    Y_temp = P*(1+next_guess)^n;&lt;/div&gt;    &lt;div&gt;    if Y_temp &amp;lt; Y&lt;/div&gt;&lt;div&gt;        r_min = next_guess;&lt;/div&gt;&lt;div&gt;    else r_max = next_guess;&lt;/div&gt;&lt;div&gt;    end&lt;/div&gt;&lt;div&gt;    current_guess = next_guess;&lt;/div&gt;&lt;div&gt;    num_guesses = num_guesses + 1;&lt;/div&gt;&lt;div&gt;    Y_temp = P*(1+current_guess)^n;&lt;/div&gt;    &lt;div&gt;end&lt;/div&gt;&lt;div&gt;effective_apy_midpoint = current_guess;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;  </content><link rel='replies' type='application/atom+xml' href='http://patcanny.blogspot.com/feeds/1331550138089944227/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4652888793139849030/1331550138089944227' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/1331550138089944227'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/1331550138089944227'/><link rel='alternate' type='text/html' href='http://patcanny.blogspot.com/2013/06/function-version-determining-effective.html' title='Function Version: Determining Effective APY'/><author><name>Pat</name><uri>http://www.blogger.com/profile/06278702331176564567</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4652888793139849030.post-4056574541405717495</id><published>2013-06-10T10:55:00.001-04:00</published><updated>2013-06-10T10:55:42.306-04:00</updated><title type='text'>MATLAB Script: Determining Effective APY</title><content type='html'>&lt;div dir=&quot;ltr&quot;&gt;It&amp;#39;s ugly, and I&amp;#39;m not sure if &amp;quot;midpoint algorithm&amp;quot; is the actual name of the algorithm. I remember doing this for my Numerical Methods course.&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;    &lt;div&gt;&lt;div&gt;% Determines the effective annual yield (APY) given a principal amount, &lt;/div&gt;&lt;div&gt;% a final amount, and number of years.&lt;/div&gt;&lt;div&gt;clear&lt;/div&gt;&lt;div&gt;clc&lt;/div&gt;&lt;div&gt;P = input(&amp;#39;Enter principal (beginning) amount: &amp;#39;);&lt;/div&gt;    &lt;div&gt;Y = input(&amp;#39;Enter final (ending) amount: &amp;#39;);&lt;/div&gt;&lt;div&gt;n = input(&amp;#39;Enter number of years: &amp;#39;);&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;% Need to calculate r (APY)&lt;/div&gt;&lt;div&gt;% Use mid-point algorithm&lt;/div&gt;&lt;div&gt;% Formula is Y = P(1+r)^n&lt;/div&gt;    &lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;% Assume range of r from 0 to 5 (0 % to 300%)&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;r_min = 0;&lt;/div&gt;&lt;div&gt;r_max = 5;&lt;/div&gt;&lt;div&gt;current_guess = r_min;&lt;/div&gt;&lt;div&gt;Y_temp = P*(1+current_guess)^n;&lt;/div&gt;&lt;div&gt;num_guesses = 1;&lt;/div&gt;    &lt;div&gt;tic&lt;/div&gt;&lt;div&gt;while Y_temp ~= Y&lt;/div&gt;&lt;div&gt;    if (Y_temp &amp;gt; Y*0.9999) &amp;amp;&amp;amp; (Y_temp &amp;lt; Y*1.0001)&lt;/div&gt;&lt;div&gt;        break&lt;/div&gt;&lt;div&gt;    end&lt;/div&gt;&lt;div&gt;    if Y_temp &amp;lt; Y&lt;/div&gt;&lt;div&gt;    next_guess = (current_guess + r_max)/2;&lt;/div&gt;    &lt;div&gt;    else next_guess = (r_min + current_guess)/2;&lt;/div&gt;&lt;div&gt;    end&lt;/div&gt;&lt;div&gt;    Y_temp = P*(1+next_guess)^n;&lt;/div&gt;&lt;div&gt;    if Y_temp &amp;lt; Y&lt;/div&gt;&lt;div&gt;        r_min = next_guess;&lt;/div&gt;&lt;div&gt;    else r_max = next_guess;&lt;/div&gt;    &lt;div&gt;    end&lt;/div&gt;&lt;div&gt;    current_guess = next_guess;&lt;/div&gt;&lt;div&gt;    num_guesses = num_guesses + 1;&lt;/div&gt;&lt;div&gt;    Y_temp = P*(1+current_guess)^n;&lt;/div&gt;&lt;div&gt;end&lt;/div&gt;&lt;div&gt;toc&lt;/div&gt;&lt;div&gt;r = current_guess;&lt;/div&gt;&lt;div&gt;effective_apy = r*100;&lt;/div&gt;    &lt;div&gt;output_str = [&amp;#39;Effective APY = &amp;#39;,num2str(effective_apy),&amp;#39;%&amp;#39;];&lt;/div&gt;&lt;div&gt;num_guess_str = [&amp;#39;With &amp;#39;,num2str(num_guesses),&amp;#39; guesses.&amp;#39;];&lt;/div&gt;&lt;div&gt;disp(output_str)&lt;/div&gt;&lt;div&gt;disp(num_guess_str)&lt;/div&gt;    &lt;/div&gt;&lt;/div&gt;&lt;/div&gt;  </content><link rel='replies' type='application/atom+xml' href='http://patcanny.blogspot.com/feeds/4056574541405717495/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4652888793139849030/4056574541405717495' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/4056574541405717495'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/4056574541405717495'/><link rel='alternate' type='text/html' href='http://patcanny.blogspot.com/2013/06/matlab-script-determining-effective-apy.html' title='MATLAB Script: Determining Effective APY'/><author><name>Pat</name><uri>http://www.blogger.com/profile/06278702331176564567</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4652888793139849030.post-5619186306082862439</id><published>2013-06-05T15:19:00.000-04:00</published><updated>2013-06-05T15:20:09.608-04:00</updated><title type='text'>Product Idea: Restaurant-Provided Credit Card Roulette</title><content type='html'>&lt;div dir=&quot;ltr&quot;&gt;&lt;div&gt;As a male in his mid 20s, I have come across the &quot;Credit Card Roulette&quot; phenomenon a few times. Personally, I think it&#39;s better to just alternate picking up the check, but I can see the appeal of random chance when it comes to paying for a meal.&lt;/div&gt;    &lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;For those unfamiliar with the game, the basic form involves all diners in a party throwing their credit cards in a hat or similar container. A random credit card is drawn from the hat, sometimes by the server to maintain objectivity, and that card is used to pay for the entire meal. Usually this game is played at the end of the meal to prevent people from ordering more food than they normally would if they were paying for it themselves.&lt;/div&gt;    &lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;But that particular moral hazard got me thinking: what if restaurants provided a system that would let patrons play Credit Card Roulette before the meal began in exchange for a 10% discount off the entire meal? The restaurant would stand to gain, of course, if non-paying diners ordered more than 10% of what they would normally order.&lt;/div&gt;    &lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;I&#39;m sure some clever game designer could figure out exactly what the interface to diners would be (kiosk at the table, smartphone app, etc.), but the concept would cater well to the gambling culture in America.&lt;/div&gt;    &lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div style&gt;Benefits:&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;- At worst, the losing player would be treating their friends or colleagues to a meal they enjoyed. And most gamblers just like the adrenaline rush, right?&lt;/div&gt;    &lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;- Payment would be easier and faster if it&amp;#39;s all going on one card (good for diners and the restaurant).&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div style&gt;- Losing diners would be encouraged to return, thinking they wouldn&amp;#39;t have to pay again because of the general misunderstanding of probability (see: the lottery). That&amp;#39;s good for the restaurant.&lt;/div&gt;    &lt;div style&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;&lt;br&gt;&lt;/div&gt;&lt;div&gt;Nobody really loses.&lt;/div&gt;&lt;/div&gt;  </content><link rel='replies' type='application/atom+xml' href='http://patcanny.blogspot.com/feeds/5619186306082862439/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4652888793139849030/5619186306082862439' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/5619186306082862439'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/5619186306082862439'/><link rel='alternate' type='text/html' href='http://patcanny.blogspot.com/2013/06/product-idea-restaurant-provided-credit.html' title='Product Idea: Restaurant-Provided Credit Card Roulette'/><author><name>Pat</name><uri>http://www.blogger.com/profile/06278702331176564567</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4652888793139849030.post-1146641170200391415</id><published>2013-05-28T15:41:00.001-04:00</published><updated>2013-05-29T09:00:56.143-04:00</updated><title type='text'>2013 Monaco Grand Prix Finishing Position vs. 2013 Driver Salary</title><content type='html'>&lt;div dir=&quot;ltr&quot;&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
I&#39;ve only watched a few Formula One races, but I did manage to catch this weekend&#39;s &lt;a href=&quot;http://en.wikipedia.org/wiki/Monaco_Grand_Prix&quot;&gt;Grand Prix de Monaco&lt;/a&gt;. Beautiful and exciting race, and only about 100 minutes long for those with things to do.&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
I did a quick regression on finishing position vs. 2013 driver salary. It&#39;s only one race, so there&#39;s bound to be some discrepancies (there were a couple accidents and one engine fire). However, the correlation is still quite moderate (R=0.613) andit makes the case for a more egalitarian approach to driver salaries. Alas: there&#39;s more to racing than just one race, and more to racing than, well: racing.&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
To note: one would expect a fairly strong downward-sloping curve if drivers were paid based on the results of just this one race.&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
I&#39;ll do another regression on 2013 World Series final results vs. salary.&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Salary data (via Reddit) courtesy of &lt;a href=&quot;http://www.crash.net/f1/news/191002/1/f1_2013_driver_salaries_published__but_who_earns_most.html&quot;&gt;Crash.net&lt;/a&gt;.&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgV1xqr4HgcGfrD2RMgCotMxTnPheb5J_GGMQxBVE8s11WJki0YxLWhh35Qs55WtIfiL2JzeRlv_01AOptWrUArCzPTT2ai3eayjRN93PVIXHkfX9XyRxx3kc0bnfal0xvXGXybKfK2IaE/s1600/2013_Monaco-703118.png&quot;&gt;&lt;img alt=&quot;&quot; border=&quot;0&quot; height=&quot;268&quot; id=&quot;BLOGGER_PHOTO_ID_5883117797054623970&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgV1xqr4HgcGfrD2RMgCotMxTnPheb5J_GGMQxBVE8s11WJki0YxLWhh35Qs55WtIfiL2JzeRlv_01AOptWrUArCzPTT2ai3eayjRN93PVIXHkfX9XyRxx3kc0bnfal0xvXGXybKfK2IaE/s640/2013_Monaco-703118.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
And when you log the salaries:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWIMJHOPT8arx_1Km5IHZCDBi4tE7JmfzW1QYwhxRDvTc6fOLmOKuEfkpUK6mtvTrNsaGYd1JNJJPwrCuuCBfiy61jndtQ-ROpH5-_U_I7L1k7hzbukopZ4-BHWnmPoDK1PrJqe8kTMAM/s1600/2013_Monaco_Log.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;302&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjWIMJHOPT8arx_1Km5IHZCDBi4tE7JmfzW1QYwhxRDvTc6fOLmOKuEfkpUK6mtvTrNsaGYd1JNJJPwrCuuCBfiy61jndtQ-ROpH5-_U_I7L1k7hzbukopZ4-BHWnmPoDK1PrJqe8kTMAM/s640/2013_Monaco_Log.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
The best fit, as one may expect, is exponential:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaltx8r9Wv9VOhdfvQ5k8D6CuN5_l3FvG2otY_6g01ERdLPLaqI0ipRpifK7C4sK9nMounDQ1ZOye0ocSmnP0gzo651Y63gN7FgfyfN6AGekKqQngg3e7qMLDd-imzMJhQb1jcVaiOxVI/s1600/2013_Monaco_Exp.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;302&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhaltx8r9Wv9VOhdfvQ5k8D6CuN5_l3FvG2otY_6g01ERdLPLaqI0ipRpifK7C4sK9nMounDQ1ZOye0ocSmnP0gzo651Y63gN7FgfyfN6AGekKqQngg3e7qMLDd-imzMJhQb1jcVaiOxVI/s640/2013_Monaco_Exp.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://patcanny.blogspot.com/feeds/1146641170200391415/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4652888793139849030/1146641170200391415' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/1146641170200391415'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/1146641170200391415'/><link rel='alternate' type='text/html' href='http://patcanny.blogspot.com/2013/05/2013-monaco-grand-prix-finishing.html' title='2013 Monaco Grand Prix Finishing Position vs. 2013 Driver Salary'/><author><name>Pat</name><uri>http://www.blogger.com/profile/06278702331176564567</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgV1xqr4HgcGfrD2RMgCotMxTnPheb5J_GGMQxBVE8s11WJki0YxLWhh35Qs55WtIfiL2JzeRlv_01AOptWrUArCzPTT2ai3eayjRN93PVIXHkfX9XyRxx3kc0bnfal0xvXGXybKfK2IaE/s72-c/2013_Monaco-703118.png" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4652888793139849030.post-4698225611053741381</id><published>2013-04-06T09:28:00.000-04:00</published><updated>2013-04-06T09:28:06.786-04:00</updated><title type='text'>Great Aerial Footage of San Francisco</title><content type='html'>From &lt;i&gt;&lt;a href=&quot;http://www.theatlantic.com/technology/archive/2013/04/this-is-how-you-shoot-aerial-footage-of-san-francisco/274643/&quot; target=&quot;_blank&quot;&gt;The Atlantic&lt;/a&gt;&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;300&quot; mozallowfullscreen=&quot;&quot; src=&quot;http://player.vimeo.com/video/62831216?portrait=0&amp;amp;badge=0&amp;amp;color=ffffff&quot; webkitallowfullscreen=&quot;&quot; width=&quot;400&quot;&gt;&lt;/iframe&gt;</content><link rel='replies' type='application/atom+xml' href='http://patcanny.blogspot.com/feeds/4698225611053741381/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4652888793139849030/4698225611053741381' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/4698225611053741381'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/4698225611053741381'/><link rel='alternate' type='text/html' href='http://patcanny.blogspot.com/2013/04/great-aerial-footage-of-san-francisco.html' title='Great Aerial Footage of San Francisco'/><author><name>Pat</name><uri>http://www.blogger.com/profile/06278702331176564567</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4652888793139849030.post-4950303807020081382</id><published>2013-02-17T15:17:00.002-05:00</published><updated>2013-02-17T15:17:14.823-05:00</updated><title type='text'>Video: A Case for Open Data in Transit</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;
As a user of open data from the MBTA (I&#39;m a big fan of &lt;a href=&quot;http://www.nextbus.com/predictor/stopSelector.jsp?a=mbta&quot; target=&quot;_blank&quot;&gt;NextBus&lt;/a&gt;), I can&#39;t agree more with the movement towards opening as much data as possible to developers for urban transit initiatives. If done right, it encourages expanded ridership and can serve to make the services more efficient.&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
I think O&#39;Reilly&#39;s point in the video of government serving as a platform for private development is&amp;nbsp;startlingly&amp;nbsp;obvious and insightful.&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;iframe allowfullscreen=&quot;&quot; frameborder=&quot;0&quot; height=&quot;300&quot; mozallowfullscreen=&quot;&quot; src=&quot;http://player.vimeo.com/video/13764646&quot; webkitallowfullscreen=&quot;&quot; width=&quot;400&quot;&gt;&lt;/iframe&gt;</content><link rel='replies' type='application/atom+xml' href='http://patcanny.blogspot.com/feeds/4950303807020081382/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4652888793139849030/4950303807020081382' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/4950303807020081382'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/4950303807020081382'/><link rel='alternate' type='text/html' href='http://patcanny.blogspot.com/2013/02/video-case-for-open-data-in-transit.html' title='Video: A Case for Open Data in Transit'/><author><name>Pat</name><uri>http://www.blogger.com/profile/06278702331176564567</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4652888793139849030.post-7655495882909036036</id><published>2013-02-09T21:15:00.002-05:00</published><updated>2013-02-09T21:36:04.289-05:00</updated><title type='text'>The Restaurant Service Auction Market</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;A &lt;a href=&quot;http://www.theatlantic.com/technology/archive/2013/02/should-what-happens-at-applebees-i-stay-i-at-applebees/272756/&quot; target=&quot;_blank&quot;&gt;recent story&lt;/a&gt;&amp;nbsp;about a cheap pastor in St. Louis who got an Applebee’s server fired for uploading a copy of the pastor’s receipt (the pastor didn’t like the mandatory 18% tip for a group of 6, so she stiffed the server citing religious reasons) got me thinking about the &lt;a href=&quot;http://en.wikipedia.org/wiki/Principal%E2%80%93agent_problem&quot; target=&quot;_blank&quot;&gt;Principal-Agent Problem&lt;/a&gt; again. I won’t dwell on it too much, but two quick things:&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;First off, the obvious: doesn’t 10% seem a little low for a pastor? Why bother giving that figure, anyway?&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;Secondly, punishing the server for a (disclosed and commonly applied) mandatory tip is a textbook example of the perils of the Principal-Agent Problem in the food service industry. The pastor should have gone directly to the manager to complain about the policy, but decided to take it out on the lowly server.&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;The fact that a religious figure was involved is a large part of why this story got out, but the fact of the matter is: the pastor should have taken out her frustration in another manner. It’s not like people blame her for bad weather events (a.k.a. Acts of God), right?&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;Anyway, this sort of customer behavior can be avoided through a market approach. That is why, if I were to open a restaurant, I’d try something like this:&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;All tips are set at a minimum of 15% and are pooled among all restaurant staff and there is no cap (i.e. a customer could bid for a 100% tip if they so desired)&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Additional preferred treatment can be arranged by bidding (in units of % of the bill as total tip), such as:&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Georgia, &#39;Times New Roman&#39;, serif;&quot;&gt;Personal food/drink recommendations&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;ul&gt;
&lt;ul&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;Faster service (this would be automatically controlled by the kitchen and bar – servers may game the system by holding up orders to appear like service to other tables is faster; customers can bid on when their meals or drinks come out)&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;ul&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;The estimated time of arrival of the meal or drink must be known to the customer for transparency.&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;Requests for special occasions (birthdays, engagements, etc.)&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;Customers are held to their promised tip amount unless the promised service at the time of the bid is not met (e.g. the food arrives a few minutes late)&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;The price for a “bid for preferential treatment” is based on supply and demand. For instance, if it’s a busy Friday night with lots of people bidding, a 1% increase in tip won’t get you to the top of the list.&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;ul&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;Customers would only know if there is someone ahead of them and will be told by the system  the current price (in % of tip) of a bid for a given request&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;Someone who does not bid must be guaranteed some reasonable level of service. You might think of this as the “floor.”&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;li style=&quot;text-align: justify;&quot;&gt;&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;Standard quality must be maintained no matter how &quot;rushed&quot; a customer wants their food. This gets tricky if people want their food to be cooked faster than good quality would allow. This would need to be factored into resource constraints when telling the customer how quickly the food can be delivered to their table.&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;I&#39;m not sure how well it would work (i.e. how long I&#39;d stay in business), but it would be a good dining experiment.&lt;/span&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://patcanny.blogspot.com/feeds/7655495882909036036/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4652888793139849030/7655495882909036036' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/7655495882909036036'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/7655495882909036036'/><link rel='alternate' type='text/html' href='http://patcanny.blogspot.com/2013/02/the-restaurant-service-auction-market.html' title='The Restaurant Service Auction Market'/><author><name>Pat</name><uri>http://www.blogger.com/profile/06278702331176564567</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4652888793139849030.post-5499623877272382458</id><published>2012-11-09T15:34:00.000-05:00</published><updated>2012-11-09T15:35:18.382-05:00</updated><title type='text'>Data Crunching, Election Edition</title><content type='html'>I&amp;#39;m getting more into data analytics, and have been looking for some substantial examples beyond the usual &amp;quot;more and more companies are using analytics&amp;quot; blanket statements from &lt;i&gt;Harvard Business Review&lt;/i&gt;. Much to my relief, &lt;i&gt;Time&lt;/i&gt; came out with &lt;a href=&quot;http://swampland.time.com/2012/11/07/inside-the-secret-world-of-quants-and-data-crunchers-who-helped-obama-win/print/&quot;&gt;a nice piece&lt;/a&gt; about the Obama campaign&amp;#39;s use of data in their recent electoral victory.&lt;br&gt;    &lt;br&gt;Full disclosure: I&amp;#39;m a libertarian and was in the 1% of the population that voted for Gary Johnson. Living in Massachusetts, my vote didn&amp;#39;t matter anyway. I also voted for Scott Brown for Senate because he is a moderate, though his campaign was poorly managed.&lt;br&gt;    &lt;br&gt;Anyway, the article points out some interesting bits about how the Obama campaign pulled off the win. Through massive computer simulations, data crunching, targeted ads, and efficient door-knocking, they were able to raise $1 billion. That is impressive no matter how you spin it, folks. One can only imagine what upcoming local elections will have. &lt;br&gt;    &lt;br&gt;I have a friend who works in the (spinning down post-election) Elizabeth Warren campaign. He&amp;#39;s more on the database-building-mechanics side of things, but he was able to talk about how the campaign used the data to target individual voters. My bet: the scale of analytics used in this year&amp;#39;s national election (per voter) will be used at the local level in 2-4 years.&lt;br&gt;    </content><link rel='replies' type='application/atom+xml' href='http://patcanny.blogspot.com/feeds/5499623877272382458/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4652888793139849030/5499623877272382458' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/5499623877272382458'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/5499623877272382458'/><link rel='alternate' type='text/html' href='http://patcanny.blogspot.com/2012/11/data-crunching-election-edition.html' title='Data Crunching, Election Edition'/><author><name>Pat</name><uri>http://www.blogger.com/profile/06278702331176564567</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4652888793139849030.post-1410998660397340965</id><published>2012-11-05T09:18:00.000-05:00</published><updated>2012-11-05T09:19:05.015-05:00</updated><title type='text'>Delivery Time Improvement Auction Market</title><content type='html'>In high school and during college breaks, I worked at a local pizza place (as I&amp;#39;ve mentioned all too frequently here). As an overzealous engineering student, I was always looking for ways to do things more efficiently. One of our biggest problems: inefficient allocation of human capital (a.k.a. delivery boys).&lt;br&gt;      &lt;br&gt;Alas, I never had the time to come up with anything fancy, until now (years later). I decided to start a pet project to develop a web-based &amp;quot;Pizza Delivery Route Optimizer&amp;quot; using as much open source software as possible.&lt;br&gt;      &lt;br&gt;I&amp;#39;m still designing the system, and don&amp;#39;t plan on selling it, but a thought occurred to me:&lt;br&gt;&lt;br&gt;What if people could bid in a live auction on how quickly their orders could arrive? Let&amp;#39;s say it&amp;#39;s a busy Friday night, and you want your pizza there in 30 minutes or less. In a fair world, even with a fancy Pizza Delivery Route Optimizer running, this would be an unrealistic expectation.&lt;br&gt;      &lt;br&gt;But what if it weren&amp;#39;t? What if you could see approximately when your order would arrive, how many orders were ahead of you, and could either bid against other orders to move up in the pecking order or pay a small fee to do the same? What would be a fair price? I&amp;#39;d imagine it would be tailored to current supply (number of drivers) and demand (number of orders). For example, if there are 20 orders ahead of you and only 15 drivers on staff, the fee would be higher than it would be if there were 10 orders and 12 drivers.&lt;br&gt;      &lt;br&gt;To do an auction, the customer would need to set up an account and would only be billed if their expected (not actual) delivery time were made earlier. It&amp;#39;d be unfair to the delivery guy (and probably unsafe) to &lt;i&gt;guarantee&lt;/i&gt; a time of arrival. Remember Domino&amp;#39;s &amp;quot;&lt;a href=&quot;http://en.wikipedia.org/wiki/Domino%27s_Pizza#30-minute_guarantee&quot;&gt;30 Minute Guarantee&lt;/a&gt;&amp;quot;? Domino&amp;#39;s ended it when a delivery guy killed someone trying to make it in the 30 minute window.&lt;br&gt;    &lt;br&gt;I think there may be a market for the auction format, but the implementation would be tough. For one, you wouldn&amp;#39;t likely have people stay on a website to actually bid in real time (they are, after all, not willing to spend the time picking the pizza up in the first place). Therefore, a simple fee would probably be easier to implement. This would, however, not necessarily do well for the delivery guy, since the customer would feel no reason to tip the delivery guy if they&amp;#39;ve already paid more for the delivery in the first place. Perhaps you could split the fee with the delivery guy? It&amp;#39;s a tough one to do if you want things to be fair to all parties.&lt;br&gt;      </content><link rel='replies' type='application/atom+xml' href='http://patcanny.blogspot.com/feeds/1410998660397340965/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4652888793139849030/1410998660397340965' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/1410998660397340965'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/1410998660397340965'/><link rel='alternate' type='text/html' href='http://patcanny.blogspot.com/2012/11/delivery-time-improvement-auction-market.html' title='Delivery Time Improvement Auction Market'/><author><name>Pat</name><uri>http://www.blogger.com/profile/06278702331176564567</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4652888793139849030.post-3306543735264242834</id><published>2012-10-29T09:42:00.001-04:00</published><updated>2012-10-29T09:42:22.226-04:00</updated><title type='text'>2012 MLB Dollars Per Win</title><content type='html'>With the San Francisco Giants&amp;#39; sweep of the Detroit Tigers last night, the 2012 MLB Season is officially in the books.&lt;br&gt;&lt;br&gt;As I&amp;#39;ve done the past few years, I broke things down in simple terms: which teams were the most efficient in getting the most value per dollar in payroll? Yes, this isn&amp;#39;t really a straightforward answer, since teams with higher payrolls tend to have higher non-baseball revenues (namely merchandising and TV deals), but from a pure baseball standpoint: who had the best year?&lt;br&gt;    &lt;br&gt;Below is a simple table of how teams ended up in terms of dollars in payroll vs. total wins (including post-season). The Oakland Athletics, a perennially efficient team, did extremely well this year, spending nearly one fifth as much per win as the lowly Red Sox. Not to be forgotten was the sub-par performance of the Phillies this season.&lt;br&gt;    &lt;br&gt;&lt;br&gt;&lt;div style=&quot;text-align:center&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHyEMpdoq18ZhnKxeL52u8RLh8VV-YP4g94MMvDb_AEUwwENBLRIOUT9bft6PRfQPCJi6O3i79zQM5erHDeazdJiseHf859CErWOkxL1pVKvQUPiakvEum8AdPOJIIK7OCHRWFmq1agsI/s1600/2012_Dollars_per_win-742226.JPG&quot;&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHyEMpdoq18ZhnKxeL52u8RLh8VV-YP4g94MMvDb_AEUwwENBLRIOUT9bft6PRfQPCJi6O3i79zQM5erHDeazdJiseHf859CErWOkxL1pVKvQUPiakvEum8AdPOJIIK7OCHRWFmq1agsI/s320/2012_Dollars_per_win-742226.JPG&quot;  border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5804726222259930466&quot; /&gt;&lt;/a&gt;&lt;br&gt;&lt;/div&gt;&lt;br&gt;Source for payroll amounts: &lt;a href=&quot;http://www.cbssports.com/mlb/salaries&quot;&gt;http://www.cbssports.com/mlb/salaries&lt;/a&gt;&lt;br&gt;    &lt;br&gt;The World Series Champion San Francisco Giants ended up in the middle of the pack due to their above average payroll, though one could argue winning it all is worth it. I would also credit the Washington Nationals for being the only other 100 win team while having a below average payroll; great year for the Natinals.&lt;br&gt;    &lt;br&gt;Just for your edification, here is the correlation between wins and payroll this year. Note how low R^2 is: 0.053. I&amp;#39;d have to look at other years, but this year turned out to be quite a year of parity.&lt;br&gt;&lt;br&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtgqpgdTBT9yuKC1zRp0-3Ol90LHjYQ91pO78k2Zm8fM2lazxKlIuwWMBf1wpIsMdWbIg1wqohWNGRvy3vgG8JuktB8VcLWMYQnwt2tbZBvrVfCJjrNEKBsxKoBN-cMjO-c43R-900IDs/s1600/Total_wins_vs_payroll-744775.JPG&quot;&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtgqpgdTBT9yuKC1zRp0-3Ol90LHjYQ91pO78k2Zm8fM2lazxKlIuwWMBf1wpIsMdWbIg1wqohWNGRvy3vgG8JuktB8VcLWMYQnwt2tbZBvrVfCJjrNEKBsxKoBN-cMjO-c43R-900IDs/s320/Total_wins_vs_payroll-744775.JPG&quot;  border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5804726231797649810&quot; /&gt;&lt;/a&gt;&lt;br&gt;    </content><link rel='replies' type='application/atom+xml' href='http://patcanny.blogspot.com/feeds/3306543735264242834/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4652888793139849030/3306543735264242834' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/3306543735264242834'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/3306543735264242834'/><link rel='alternate' type='text/html' href='http://patcanny.blogspot.com/2012/10/2012-mlb-dollars-per-win.html' title='2012 MLB Dollars Per Win'/><author><name>Pat</name><uri>http://www.blogger.com/profile/06278702331176564567</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiHyEMpdoq18ZhnKxeL52u8RLh8VV-YP4g94MMvDb_AEUwwENBLRIOUT9bft6PRfQPCJi6O3i79zQM5erHDeazdJiseHf859CErWOkxL1pVKvQUPiakvEum8AdPOJIIK7OCHRWFmq1agsI/s72-c/2012_Dollars_per_win-742226.JPG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4652888793139849030.post-2851095601018853617</id><published>2012-10-20T16:06:00.001-04:00</published><updated>2012-10-20T16:06:19.410-04:00</updated><title type='text'>Nissan&#39;s New &quot;Steer By Wire&quot; Technology</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;
Before watching the video, I wasn&#39;t sure what Nissan was trying to accomplish. I didn&#39;t know of any market demand for this technology. After viewing the video and learning of the &quot;smooth ride&quot; capabilities, I was hooked. I can&#39;t wait for this to arrive in all cars.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
I&#39;m assuming the clutch also serves as the mechanical back-up in the event of a loss of power to the control units; the video seems to state that. That would be a major concern from a safety standpoint.
&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
This also plays right into my dream of driverless cars. With this new system, all you&#39;d need to do to make the vehicle driverless (assuming you completely remove the human driver) is ditch the steering wheel and clutch and plug the control unit into a master vehicle controller, which would also control throttle and brake. No more goofy actuators on the steering wheel; &lt;a href=&quot;http://en.wikipedia.org/wiki/FADEC&quot; target=&quot;_blank&quot;&gt;full-authority&lt;/a&gt; steering!&amp;nbsp;&lt;/div&gt;
&lt;br /&gt;
&lt;iframe allowfullscreen=&quot;allowfullscreen&quot; frameborder=&quot;0&quot; height=&quot;360&quot; src=&quot;http://www.youtube.com/embed/qoSodr3J-WI?feature=player_detailpage&quot; width=&quot;640&quot;&gt;&lt;/iframe&gt;</content><link rel='replies' type='application/atom+xml' href='http://patcanny.blogspot.com/feeds/2851095601018853617/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4652888793139849030/2851095601018853617' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/2851095601018853617'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/2851095601018853617'/><link rel='alternate' type='text/html' href='http://patcanny.blogspot.com/2012/10/nissans-new-steer-by-wire-technology.html' title='Nissan&#39;s New &quot;Steer By Wire&quot; Technology'/><author><name>Pat</name><uri>http://www.blogger.com/profile/06278702331176564567</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/qoSodr3J-WI/default.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4652888793139849030.post-6874723271737728220</id><published>2012-10-08T10:48:00.000-04:00</published><updated>2012-10-08T10:49:06.893-04:00</updated><title type='text'>Pizza Delivery Routing Algorithm - A Pet Project</title><content type='html'>A couple months ago I realized that I had completely given up on my   interest in web application development. I&amp;#39;d studied it briefly towards   the end of my Master&amp;#39;s curriculum a couple years ago, and had been   meaning to reignite my interest through a couple projects. I&amp;#39;m not very   gifted at web development, but I&amp;#39;ve seen enough to become interested.   Alas, starting an MBA and getting married became greater (and   worthwhile) time sinks.&lt;br&gt;  &lt;br&gt;The good news (for me and my interest) is that my wedding is on   Saturday, which means I&amp;#39;ll have some free time coming up. That, and I&amp;#39;m   most of the way through the core MBA curriculum. Right now I&amp;#39;m taking a   course in information systems management, which, if anything, is feeding   my interest in restarting my hobby. My buddy Sam has been working on   something for a couple years now, and his advice was simple: &amp;quot;Just do   something, anything. Keep sharp.&amp;quot;&lt;br&gt;  &lt;br&gt;My first project: pizza delivery routing algorithm. As I&amp;#39;ve   mentioned before here, I used to deliver pizzas in high school and   during college breaks. I developed a strange passion for operational   efficiency after the business expanded and we had a new Point of Sale   (POS) system installed. This was in 2004. My boss had no interest in   even developing a website for the business at the time. He was mostly   concerned with building the business one week at a time. But that didn&amp;#39;t   stop me from analyzing how inefficient some of our processes were - I   was an engineering student, after all.&lt;br&gt;  &lt;br&gt;One of the major annoyances in operating a business with a personal   delivery component (e.g. pizza) is figuring out how best to allocate   your delivery resources (e.g. the drivers). My boss was notorious for   taking guys off the clock if business was slow. The drivers figured this   out quickly and gamed the system by taking as long as reasonably   possible to complete a delivery during the slow down periods. It   infuriated the boss, but he had to live with it.&lt;br&gt;  &lt;br&gt;On the flip side, when business was booming (e.g. during the dinner   rush on a Friday night), we couldn&amp;#39;t have enough drivers. Orders would   run late because of the sheer backlog. Guys would make 2-3 trips per   hour. Even with 15 drivers on the clock at once, we couldn&amp;#39;t keep up.   Drivers were motivated mostly by tips, and knew that getting the order   to the customer sooner rather than later would result in a better tip.   Drivers couldn&amp;#39;t care less if the next order was late. This led to   serious inefficiency. Whenever I was in charge of routing deliveries,   I&amp;#39;d have guys wait a few agonizing minutes for any deliveries they could   take in tandem based on geographical proximity - basically: if you have   two orders going to Main Street in Trumbull (a 15 minute drive), have   the driver take both even if they came in 10 minutes apart. It drove   drivers, and my boss, crazy, but it resulted in fewer late orders on the   whole. We would call these &amp;quot;two baggers&amp;quot; or &amp;quot;three baggers&amp;quot; - depending   on how many orders went out (in warming bags).&lt;br&gt;  &lt;br&gt;I wished that the manual routing I had to do were somehow automated. I know there &lt;i&gt;has&lt;/i&gt; to be something already out there now, but I figured my first project would be to develop something simple.&lt;br&gt;&lt;br&gt;The   interface should be straightforward: provide the user (e.g. manager)   with a table of all open delivery orders grouped by recommended batch. A   batch would be determined based on driving time for the round trip and   would be temporal - you wouldn&amp;#39;t batch two orders together that were   ordered more than 35 minutes apart (for argument&amp;#39;s sake). The idea is to   provide the manager with a set of options to maximize the efficiency of   each delivery driver at any one time.&lt;br&gt;  &lt;br&gt;The system would have to be flexible and optional. It would have to   interface with the existing POS system to collect all open orders coming   in. It should be optional because of various factors that come into   play, especially driver skill. A manager probably wouldn&amp;#39;t want to   assign a long and expensive &amp;quot;three bagger&amp;quot; to the newest driver. The   manager would have the option to break the orders into pieces.   Therefore, the system would have the be &amp;quot;slave&amp;quot; to the POS system   except, perhaps, if the manager decided to go with the recommendation   and assign deliveries through it and have the POS system only become the   &amp;quot;slave&amp;quot; in such cases. For example, if the system recommends a   particular batch, the manager would select that batch, match it with a   driver, and click &amp;quot;ASSIGN.&amp;quot; The system would send the request to the POS   system, which would assign those three orders to the driver.&lt;br&gt;  &lt;br&gt;I plan on using the &lt;a href=&quot;http://developer.mapquest.com/&quot; target=&quot;_blank&quot;&gt;MapQuest API&lt;/a&gt; for the background routing algorithm. There are many other options, but I found MapQuest&amp;#39;s to be the most open for now.&lt;br&gt;      &lt;br&gt;There are a few tricky aspects that I&amp;#39;ll need to take into account:&lt;br&gt;  &lt;br&gt;- Ensuring the correct address is entered. This would probably need   to be tied in with the POS - the user may need to confirm the address   with the customer.&lt;br&gt;- Tweaking the interface with the POS system to   pull and push requests (timing, etc.). I&amp;#39;ll have to make my own dummy   POS for starters.&lt;br&gt;  - Tweaking the algorithm to take other factors into account, like   weather (doubtful) and performance parameters for drivers like average   delivery time (maybe)&lt;br&gt;&lt;br&gt;I doubt any business would actually pay for this, but it&amp;#39;s a neat project. Maybe, just maybe, I could get a blurb in &lt;a href=&quot;http://www.pizzatoday.com/&quot;&gt;&lt;i&gt;Pizza Today&lt;/i&gt;&lt;/a&gt;.&lt;br&gt;  </content><link rel='replies' type='application/atom+xml' href='http://patcanny.blogspot.com/feeds/6874723271737728220/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4652888793139849030/6874723271737728220' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/6874723271737728220'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/6874723271737728220'/><link rel='alternate' type='text/html' href='http://patcanny.blogspot.com/2012/10/pizza-delivery-routing-algorithm-pet.html' title='Pizza Delivery Routing Algorithm - A Pet Project'/><author><name>Pat</name><uri>http://www.blogger.com/profile/06278702331176564567</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4652888793139849030.post-6424607870291320308</id><published>2012-10-02T21:11:00.001-04:00</published><updated>2012-10-02T21:11:32.001-04:00</updated><title type='text'>The CN Turbo Train</title><content type='html'>Canadian rail was way ahead of its time.&lt;br /&gt;
&lt;br /&gt;
The &lt;a href=&quot;http://en.wikipedia.org/wiki/UAC_TurboTrain&quot;&gt;TurboTrain&lt;/a&gt; - a United Aircraft product.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;iframe allowfullscreen=&quot;allowfullscreen&quot; frameborder=&quot;0&quot; height=&quot;360&quot; src=&quot;http://www.youtube.com/embed/5-ght8Zzf3k?feature=player_detailpage&quot; width=&quot;640&quot;&gt;&lt;/iframe&gt;</content><link rel='replies' type='application/atom+xml' href='http://patcanny.blogspot.com/feeds/6424607870291320308/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4652888793139849030/6424607870291320308' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/6424607870291320308'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/6424607870291320308'/><link rel='alternate' type='text/html' href='http://patcanny.blogspot.com/2012/10/the-cn-turbo-train.html' title='The CN Turbo Train'/><author><name>Pat</name><uri>http://www.blogger.com/profile/06278702331176564567</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/5-ght8Zzf3k/default.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4652888793139849030.post-3968305625139420078</id><published>2012-09-30T09:52:00.000-04:00</published><updated>2012-09-30T09:55:04.280-04:00</updated><title type='text'>Customer Service and the Principal-Agent Problem</title><content type='html'>&lt;div style=&quot;text-align: justify;&quot;&gt;
A couple weeks ago, I read &lt;a href=&quot;http://www.freakonomics.com/2012/09/11/taxi-tipping-and-the-principal-agent-problem/&quot;&gt;a nice little piece&lt;/a&gt; that Stephen Dubner wrote on the &lt;i&gt;Freakonomics&lt;/i&gt; blog about the &lt;a href=&quot;http://en.wikipedia.org/wiki/Principal%E2%80%93agent_problem&quot;&gt;principal-agent problem&lt;/a&gt;. A cheap, but guilt-ridden, reader wrote in to &lt;i&gt;Freakonomics&lt;/i&gt; about an unfortunate transaction involving a cab ride in Las Vegas. The reader was charged $3 to use his credit card on a fare of $11.50, and decided to take it out on the cab driver, who was nonplussed and berate.&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
This is a familiar story to anyone in the food service industry, let alone anyone who works in customer service. Anyone who has had to deal with unruly customers who feel “cheated” by something, like a late delivery of their food, usually takes it out on the easiest target (pizza delivery guy, cashier, whomever) instead of those truly responsible for the wrong-doing (manager or store owner). In reality, the principal (the store owner) usually has the leverage (pizza delivery guys are usually just happy to be working) and would rather the customer take out their frustration on the messenger in most cases.&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
It has to do with misaligned incentives. Back in high school and during college term breaks, I worked at &lt;a href=&quot;http://www.yelp.com/biz/american-pie-monroe&quot;&gt;a pizza place&lt;/a&gt; that offered “fast free delivery.” My fellow drivers and I made most of our money (our wages were low – I left the place earning $7.50 an hour after starting at $5) through tips. The business benefitted from customers who were attracted to &lt;a href=&quot;http://danariely.com/tag/free/&quot;&gt;the “free” aspect&lt;/a&gt; of the delivery service. The rationale we were given as drivers was that the customers would tip us more than we would have received from a delivery fee. For the most part, this was true, and drivers benefitted from the “free delivery” protocol, but it didn’t shield us from dealing with disgruntled, and frequently rude, customers. Despite the root cause usually being out of the driver’s control (busy night, a mistake in the kitchen, etc.), customers usually exerted punishment on the drivers through reduced (or nonexistent) tips.&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
One approach I took was to grease the wheels a bit when I knew a fellow driver was going to take a hit for something like a delivery that left the store late (I’d usually wait a few minutes to give the driver some breathing room). While waiting for an order to take, I would call the customer and inform them that we’d been flooded with orders and the driver had just left. I can’t remember many times, save for perhaps a couple exceptions with some truly rude customers, when this didn’t benefit the driver. He’d arrive and be greeted by an understanding customer and the tip amount would usually be unaffected (sometimes it would be higher than expected!). My boss didn’t agree with this strategy because “it makes us look bad if we&#39;re slow,” but I continued the “honesty first” approach nonetheless because it didn&#39;t really affect the owner&#39;s bottom line since the food wasn&#39;t going to get there any faster if I called ahead or not.&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
Another approach, which got me in trouble a couple times, was only employed if I was the driver who arrived to a late order. If the customer complained and tipped poorly, I’d apologize and inform them of the following:&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
“Thank you for your business. I understand your concern, and would like to inform you that the free delivery service is not your only option in obtaining your order. Pick-up is always an option.”&amp;nbsp;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: justify;&quot;&gt;
One customer was visibly upset when I gave him such a disclaimer, and followed me back to the store to complain to the manager on duty. He approached the counter and loudly asked the girl behind the register to find the manager on duty. She looked over at me (the manager on duty) and said “Pat, this gentleman would like to speak to you.” I think the conversation lasted about a minute before he apologized for losing his head. I gave him a menu and told him to keep it handy if he felt like picking up a pizza from us again (words carefully chosen).
It’s all about aligning incentives, folks.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://patcanny.blogspot.com/feeds/3968305625139420078/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4652888793139849030/3968305625139420078' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/3968305625139420078'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/3968305625139420078'/><link rel='alternate' type='text/html' href='http://patcanny.blogspot.com/2012/09/customer-service-and-principal-agent.html' title='Customer Service and the Principal-Agent Problem'/><author><name>Pat</name><uri>http://www.blogger.com/profile/06278702331176564567</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4652888793139849030.post-8374362927915986667</id><published>2012-09-10T22:40:00.000-04:00</published><updated>2012-09-10T22:40:02.340-04:00</updated><title type='text'>&quot;Psycho Killer&quot; - The Ukulele Orchestra of Great Britain</title><content type='html'>&lt;iframe width=&quot;640&quot; height=&quot;360&quot; src=&quot;http://www.youtube.com/embed/dKpzCCuHDVY?feature=player_detailpage&quot; frameborder=&quot;0&quot; allowfullscreen&gt;&lt;/iframe&gt;</content><link rel='replies' type='application/atom+xml' href='http://patcanny.blogspot.com/feeds/8374362927915986667/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4652888793139849030/8374362927915986667' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/8374362927915986667'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/8374362927915986667'/><link rel='alternate' type='text/html' href='http://patcanny.blogspot.com/2012/09/psycho-killer-ukulele-orchestra-of.html' title='&quot;Psycho Killer&quot; - The Ukulele Orchestra of Great Britain'/><author><name>Pat</name><uri>http://www.blogger.com/profile/06278702331176564567</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/dKpzCCuHDVY/default.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4652888793139849030.post-2175146142415864629</id><published>2012-08-29T17:46:00.000-04:00</published><updated>2012-08-29T17:46:22.088-04:00</updated><title type='text'>Cooking Simulator</title><content type='html'>Try as I might, I cannot find the utility.&lt;br&gt;&lt;br&gt;


&lt;iframe width=&quot;640&quot; height=&quot;360&quot; src=&quot;http://www.youtube.com/embed/F565MHCfsSo?feature=player_detailpage&quot; frameborder=&quot;0&quot; allowfullscreen&gt;&lt;/iframe&gt;</content><link rel='replies' type='application/atom+xml' href='http://patcanny.blogspot.com/feeds/2175146142415864629/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/4652888793139849030/2175146142415864629' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/2175146142415864629'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4652888793139849030/posts/default/2175146142415864629'/><link rel='alternate' type='text/html' href='http://patcanny.blogspot.com/2012/08/cooking-simulator.html' title='Cooking Simulator'/><author><name>Pat</name><uri>http://www.blogger.com/profile/06278702331176564567</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://img.youtube.com/vi/F565MHCfsSo/default.jpg" height="72" width="72"/><thr:total>0</thr:total></entry></feed>