<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'>
<font class="Apple-style-span" face="sans-serif"><span class="Apple-style-span" style="line-height: 20px;"><span class="Apple-style-span" style="font-size: 16px; "><p class="first" style="margin-top: 0px !important; text-align: justify; line-height: 20px; ">Quoting from the&nbsp;<a href="http://docs.python.org/dev/py3k/whatsnew/3.2.html">http://docs.python.org/dev/py3k/whatsnew/3.2.html</a>&nbsp;page:</p><p class="first" style="margin-top: 0px !important; text-align: justify; line-height: 20px; "><br></p><p class="first" style="margin-top: 0px !important; text-align: justify; line-height: 20px; "><p class="first" style="text-indent: 0px !important; margin-top: 0px !important; margin-right: 0px !important; margin-bottom: 0px !important; margin-left: 0px !important; padding-top: 0px !important; padding-right: 0px !important; padding-bottom: 0px !important; padding-left: 0px !important; text-align: justify; line-height: 20px; ">The&nbsp;<a class="reference internal" href="http://docs.python.org/dev/py3k/library/itertools.html#module-itertools" title="itertools: Functions creating iterators for efficient looping." style="text-indent: 0px !important; color: rgb(53, 95, 124); text-decoration: none; "><tt class="xref py py-mod docutils literal" style="text-indent: 0px !important; background-color: transparent; padding-top: 0px; padding-right: 1px; padding-bottom: 0px; padding-left: 1px; font-size: 0.95em; font-weight: bold; "><span class="pre" style="text-indent: 0px !important; ">itertools</span></tt></a>&nbsp;module has a new function,&nbsp;<a class="reference internal" href="http://docs.python.org/dev/py3k/library/itertools.html#itertools.accumulate" title="itertools.accumulate" style="text-indent: 0px !important; color: rgb(53, 95, 124); text-decoration: none; "><tt class="xref py py-func docutils literal" style="text-indent: 0px !important; background-color: transparent; padding-top: 0px; padding-right: 1px; padding-bottom: 0px; padding-left: 1px; font-size: 0.95em; font-weight: bold; "><span class="pre" style="text-indent: 0px !important; ">accumulate()</span></tt></a>&nbsp;modeled on APL’s&nbsp;<em style="text-indent: 0px !important; ">scan</em>&nbsp;operator and on Numpy’s&nbsp;<em style="text-indent: 0px !important; ">accumulate</em>&nbsp;function:</p><div class="highlight-python3" style="text-indent: 0px !important; "><div class="highlight" style="text-indent: 0px !important; background-color: rgb(238, 255, 204); background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; "><pre style="text-indent: 0px !important; overflow-x: auto; overflow-y: hidden; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; background-color: rgb(238, 255, 204); color: rgb(51, 51, 51); line-height: 15px; border-top-width: 1px; border-bottom-width: 1px; border-top-style: solid; border-bottom-style: solid; border-top-color: rgb(170, 204, 153); border-bottom-color: rgb(170, 204, 153); border-left-style: none; border-left-width: initial; border-left-color: initial; border-right-style: none; border-right-width: initial; border-right-color: initial; "><span class="gp" style="text-indent: 0px !important; color: rgb(198, 93, 9); font-weight: bold; ">&gt;&gt;&gt; </span><span class="nb" style="text-indent: 0px !important; color: rgb(0, 112, 32); ">list</span><span class="p" style="text-indent: 0px !important; ">(</span><span class="n" style="text-indent: 0px !important; ">accumulate</span><span class="p" style="text-indent: 0px !important; ">(</span><span class="mi" style="text-indent: 0px !important; color: rgb(32, 128, 80); ">8</span><span class="p" style="text-indent: 0px !important; ">,</span> <span class="mi" style="text-indent: 0px !important; color: rgb(32, 128, 80); ">2</span><span class="p" style="text-indent: 0px !important; ">,</span> <span class="mi" style="text-indent: 0px !important; color: rgb(32, 128, 80); ">50</span><span class="p" style="text-indent: 0px !important; ">))</span>
<span class="go" style="text-indent: 0px !important; color: rgb(48, 48, 48); ">[8, 10, 60]</span>
</pre></div></div><div class="highlight-python3" style="text-indent: 0px !important; "><div class="highlight" style="text-indent: 0px !important; background-color: rgb(238, 255, 204); background-image: initial; background-attachment: initial; background-origin: initial; background-clip: initial; "><pre style="text-indent: 0px !important; overflow-x: auto; overflow-y: hidden; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; background-color: rgb(238, 255, 204); color: rgb(51, 51, 51); line-height: 15px; border-top-width: 1px; border-bottom-width: 1px; border-top-style: solid; border-bottom-style: solid; border-top-color: rgb(170, 204, 153); border-bottom-color: rgb(170, 204, 153); border-left-style: none; border-left-width: initial; border-left-color: initial; border-right-style: none; border-right-width: initial; border-right-color: initial; "><span class="gp" style="text-indent: 0px !important; color: rgb(198, 93, 9); font-weight: bold; ">&gt;&gt;&gt; </span><span class="n" style="text-indent: 0px !important; ">prob_dist</span> <span class="o" style="text-indent: 0px !important; color: rgb(102, 102, 102); ">=</span> <span class="p" style="text-indent: 0px !important; ">[</span><span class="mf" style="text-indent: 0px !important; color: rgb(32, 128, 80); ">0.1</span><span class="p" style="text-indent: 0px !important; ">,</span> <span class="mf" style="text-indent: 0px !important; color: rgb(32, 128, 80); ">0.4</span><span class="p" style="text-indent: 0px !important; ">,</span> <span class="mf" style="text-indent: 0px !important; color: rgb(32, 128, 80); ">0.2</span><span class="p" style="text-indent: 0px !important; ">,</span> <span class="mf" style="text-indent: 0px !important; color: rgb(32, 128, 80); ">0.3</span><span class="p" style="text-indent: 0px !important; ">]</span>
<span class="gp" style="text-indent: 0px !important; color: rgb(198, 93, 9); font-weight: bold; ">&gt;&gt;&gt; </span><span class="nb" style="text-indent: 0px !important; color: rgb(0, 112, 32); ">list</span><span class="p" style="text-indent: 0px !important; ">(</span><span class="n" style="text-indent: 0px !important; ">accumulate</span><span class="p" style="text-indent: 0px !important; ">(</span><span class="n" style="text-indent: 0px !important; ">prob_dist</span><span class="p" style="text-indent: 0px !important; ">))</span>      <span class="c" style="text-indent: 0px !important; color: rgb(64, 128, 144); font-style: italic; "># cumulative probability distribution</span>
<span class="go" style="text-indent: 0px !important; color: rgb(48, 48, 48); ">[0.1, 0.5, 0.7, 1.0]                                                                       </span></pre></div></div></p><p class="first" style="margin-top: 0px !important; text-align: justify; line-height: 20px; ">I'm not sure if this is a bug as I'm not sure if this is how the function actually behaves. Should the first function not take a list? For example:</p><p class="first" style="margin-top: 0px !important; text-align: justify; line-height: 20px; "><pre style="text-indent: 0px !important; overflow-x: auto; overflow-y: hidden; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; background-color: rgb(238, 255, 204); color: rgb(51, 51, 51); line-height: 15px; border-top-width: 1px; border-bottom-width: 1px; border-top-style: solid; border-bottom-style: solid; border-top-color: rgb(170, 204, 153); border-bottom-color: rgb(170, 204, 153); border-left-style: none; border-left-width: initial; border-left-color: initial; border-right-style: none; border-right-width: initial; border-right-color: initial; "><span class="gp" style="text-indent: 0px !important; color: rgb(198, 93, 9); font-weight: bold; ">&gt;&gt;&gt; </span><span class="nb" style="text-indent: 0px !important; color: rgb(0, 112, 32); ">list</span><span class="p" style="text-indent: 0px !important; ">(</span><span class="n" style="text-indent: 0px !important; ">accumulate</span><span class="p" style="text-indent: 0px !important; ">([</span><span class="mi" style="text-indent: 0px !important; color: rgb(32, 128, 80); ">8</span><span class="p" style="text-indent: 0px !important; ">,</span> <span class="mi" style="text-indent: 0px !important; color: rgb(32, 128, 80); ">2</span><span class="p" style="text-indent: 0px !important; ">,</span> <span class="mi" style="text-indent: 0px !important; color: rgb(32, 128, 80); ">50]</span><span class="p" style="text-indent: 0px !important; ">))</span>
<span class="go" style="text-indent: 0px !important; color: rgb(48, 48, 48); ">[8, 10, 60]</span></pre></p><p class="first" style="margin-top: 0px !important; text-align: justify; line-height: 20px; ">Notice the square brackets. I have not actually tested the function personally but it seems like something worth noting.</p><p class="first" style="margin-top: 0px !important; text-align: justify; line-height: 20px; "><br></p><p class="first" style="margin-top: 0px !important; text-align: justify; line-height: 20px; "><br></p><p class="first" style="margin-top: 0px !important; text-align: justify; line-height: 20px; "><br></p><p class="first" style="margin-top: 0px !important; text-align: justify; line-height: 20px; "><br></p><p class="first" style="margin-top: 0px !important; text-align: justify; line-height: 20px; "><br></p><p class="first" style="margin-top: 0px !important; text-align: justify; line-height: 20px; "><br></p><p class="first" style="margin-top: 0px !important; text-align: justify; line-height: 20px; "><br></p></span></span></font>                                               </body>
</html>