<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 26, 2016 at 2:13 PM, Stephan Hoyer <span dir="ltr"><<a href="mailto:shoyer@gmail.com" target="_blank">shoyer@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span class="">On Wed, Oct 26, 2016 at 11:03 AM, Mathew S. Madhavacheril <span dir="ltr"><<a href="mailto:mathewsyriac@gmail.com" target="_blank">mathewsyriac@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><span>On Wed, Oct 26, 2016 at 1:46 PM, Stephan Hoyer <span dir="ltr"><<a href="mailto:shoyer@gmail.com" target="_blank">shoyer@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">I wonder if the goals of this addition could be achieved by simply adding an optional `cov` argument</div></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">to np.corr, which would provide a pre-computed covariance.</div></blockquote><div><br></div></span><div>That's a fair suggestion which I'm happy to switch to. This eliminates the need for two new functions. </div><div>I'll add an optional `cov = False` argument to numpy.corrcoef that returns a tuple (corr, cov) instead.</div><span><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><br></div><div>Either way, `covcorr` feels like a helper function that could exist in user code rather than numpy proper.</div></div></blockquote><div><br></div></span><div>The user would have to re-implement the part that converts the covariance matrix to a correlation</div><div>coefficient. I made this PR to avoid that code duplication.</div></div></div></div></blockquote><div><br></div></span><div>With the API I was envisioning (or even your proposed API, for that matter), this function would only be a few lines, e.g.,</div><div><br></div><div>def covcorr(x):</div>    cov = np.cov(x)<br>    corr = np.corrcoef(x, cov=cov)</div><div class="gmail_quote">    return (cov, corr)</div><div class="gmail_quote"><br></div><div class="gmail_quote">Generally, functions this short should be provided as recipes (if at all) rather than be added to numpy proper, unless the need for them is extremely common.<br></div></div></div></blockquote><div><br></div><div>Ah, I see what you were suggesting now. I agree that a function like covcorr need not be provided </div><div>by numpy itself, but it would be tremendously useful if a pre-computed covariance could<br></div><div>be provided to np.corrcoef. I can update this PR to just add `cov = None` to numpy.corrcoef and</div><div>do an `if cov is not None` before calculating the covariance. Note however that in the case</div><div>that `cov` is specified for np.corrcoef, the non-optional `x` argument is redundant.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div><br></div></div></div></div>
<br>______________________________<wbr>_________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
<a href="https://mail.scipy.org/mailman/listinfo/numpy-discussion" rel="noreferrer" target="_blank">https://mail.scipy.org/<wbr>mailman/listinfo/numpy-<wbr>discussion</a><br>
<br></blockquote></div><br></div></div>