<instructions>Your goal is to analyze the following comment and estimate how highly it will be upvoted by the Hacker News community.</instructions><comment><author>andrewla</author><text>Okay, someone with some Scala expertise needs to jump in here.  The code as written is _clearly_ incorrect.  q(n,mu) sums a distribution with mean mu n times.  The expected value of this is mu * n.  Then we run this 1000 times and average the results.  If this is not extremely close to mu*n then I will eat my hat.  In R, sum(replicate(1000,sum(rexp(3000,1/50)))) / 1000
returns ~150000 (using sum for clarity instead of mean).  Maybe scala is caching the seed or something?&lt;p&gt;I don&apos;t know what the &quot;par&quot; function does, but assuming it doesn&apos;t do anything crazy, the answer for all three of those expressions should be exactly 150,000, because they just reorder the order of summation.</text><parent_chain><item><author>dxbydt</author><text>scala&amp;#62; import org.apache.commons.math.distribution.{ExponentialDistributionImpl=&amp;#62;expo}&lt;p&gt;//pc = process customer, with a mean time mu per customer&lt;p&gt;scala&amp;#62; def pc(mu:Int):Double= new expo(mu).sample&lt;p&gt;// q = queue of n customers with mean process time mu&lt;p&gt;scala&amp;#62; def q(n:Int,mu:Int):Double=(1 to n).map(_=&amp;#62;pc(mu)).sum&lt;p&gt;scala&amp;#62; // put 3000 people in 1 queue with mean process time 50&lt;p&gt;scala&amp;#62; (1 to 1000).map(_=&amp;#62;q(3000,50)).sum/1000&lt;p&gt;res43: Double = 83107.37275937156&lt;p&gt;scala&amp;#62; //now put 1000 people each in 3 separate queues with the same mean process time as before&lt;p&gt;scala&amp;#62; (1 to 1000).map(_=&amp;#62;(1 to 3).par.map(_=&amp;#62;q(1000,50)).sum).sum/1000&lt;p&gt;res45: Double = 200010.29627921886&lt;p&gt;200010 = ~3x83107, so yeah, single line to 3 cashiers is ~3x faster than a separate line for each cashier.&lt;p&gt;// Now make 1 queue that feeds into shortest of the 3 queues&lt;p&gt;scala&amp;#62; def qq(n:Int,mu:Int)=(1 to 3).par.map(_=&amp;#62;{(1 to n/3).map(_=&amp;#62;pc(mu)).sum}).sum&lt;p&gt;scala&amp;#62; (1 to 10000).map(_=&amp;#62;qq(3000,50)).sum/10000&lt;p&gt;res70: Double = 141824.974765643&lt;p&gt;So our single queue feeding into 3 separate queues still beats 3 separate independent queues.&lt;p&gt;edited to address MaysonL&apos;s question.</text></item></parent_chain></comment><story><title>A single line to 3 cashiers is ~3x faster than a separate line for each cashier</title><url>http://online.wsj.com/article/SB10001424052970204770404577082933921432686.html</url></story>
<instructions>Your goal is to analyze the following comment and estimate how highly it will be upvoted by the Hacker News community.</instructions><comment><author>MaysonL</author><text>But of course this is BS, because the three queues are not independent. Try it with 1 queue which feeds into whichever of the three queues is currently shortest. And of course, in grocery stores, where one can unload one&apos;s cart while the person ahead is being processed, there&apos;s an advantage to multiple lines.</text><parent_chain><item><author>dxbydt</author><text>scala&amp;#62; import org.apache.commons.math.distribution.{ExponentialDistributionImpl=&amp;#62;expo}&lt;p&gt;//pc = process customer, with a mean time mu per customer&lt;p&gt;scala&amp;#62; def pc(mu:Int):Double= new expo(mu).sample&lt;p&gt;// q = queue of n customers with mean process time mu&lt;p&gt;scala&amp;#62; def q(n:Int,mu:Int):Double=(1 to n).map(_=&amp;#62;pc(mu)).sum&lt;p&gt;scala&amp;#62; // put 3000 people in 1 queue with mean process time 50&lt;p&gt;scala&amp;#62; (1 to 1000).map(_=&amp;#62;q(3000,50)).sum/1000&lt;p&gt;res43: Double = 83107.37275937156&lt;p&gt;scala&amp;#62; //now put 1000 people each in 3 separate queues with the same mean process time as before&lt;p&gt;scala&amp;#62; (1 to 1000).map(_=&amp;#62;(1 to 3).par.map(_=&amp;#62;q(1000,50)).sum).sum/1000&lt;p&gt;res45: Double = 200010.29627921886&lt;p&gt;200010 = ~3x83107, so yeah, single line to 3 cashiers is ~3x faster than a separate line for each cashier.&lt;p&gt;// Now make 1 queue that feeds into shortest of the 3 queues&lt;p&gt;scala&amp;#62; def qq(n:Int,mu:Int)=(1 to 3).par.map(_=&amp;#62;{(1 to n/3).map(_=&amp;#62;pc(mu)).sum}).sum&lt;p&gt;scala&amp;#62; (1 to 10000).map(_=&amp;#62;qq(3000,50)).sum/10000&lt;p&gt;res70: Double = 141824.974765643&lt;p&gt;So our single queue feeding into 3 separate queues still beats 3 separate independent queues.&lt;p&gt;edited to address MaysonL&apos;s question.</text></item></parent_chain></comment><story><title>A single line to 3 cashiers is ~3x faster than a separate line for each cashier</title><url>http://online.wsj.com/article/SB10001424052970204770404577082933921432686.html</url></story>