<div dir="ltr"><br><div class="gmail_extra"><div class="gmail_quote">On Mon, Mar 4, 2013 at 4:53 PM, Aron Ahmadia <span dir="ltr"><<a href="mailto:aron@ahmadia.net" target="_blank">aron@ahmadia.net</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">Interesting, that question would probably have gotten a different response on scicomp, it is a pity we are not attracting more questions there!<div>
<br></div><div>I know there are two polyfit modules in numpy, one in numpy.polyfit, the other in numpy.polynomial, the functionality you are suggesting seems to fit in either.</div>
<div><br></div><div>What parameters/functionality are you considering adding?</div></div></blockquote><div><br></div><div style>Well, you need two more array-likes, x_fixed and y_fixed, which could probably be fed to polyfit as an optional tuple parameter:</div>
<div style><br></div><div style>polyfit(x, y, deg, fixed_points=(x_fixed, y_fixed))</div><div style><br></div><div style>The standard return would still be the deg + 1 coefficients of the fitted polynomial, so the workings would be perfectly backwards compatible.</div>
<div style><br></div><div style>An optional return, either when full=True, or by setting an additional lagrange_mult=True flag, could include the values of the Lagrange multipliers calculated during the fit.</div><div style>
<br></div><div style>Jaime</div><div style><br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div></div><div>A</div></div><div class="gmail_extra">
<br><br><div class="gmail_quote"><div><div class="h5">On Mon, Mar 4, 2013 at 7:23 PM, Jaime Fernández del Río <span dir="ltr"><<a href="mailto:jaime.frio@gmail.com" target="_blank">jaime.frio@gmail.com</a>></span> wrote:<br>

</div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr">A couple of days back, answering a question in StackExchange (<a href="http://stackoverflow.com/a/15196628/110026" target="_blank">http://stackoverflow.com/a/15196628/110026</a>), I found myself using Lagrange multipliers to fit a polynomial with least squares to data, making sure it went through some fixed points. This time it was relatively easy, because some 5 years ago I came across the same problem in real life, and spent the better part of a week banging my head against it. Even knowing what you are doing, it is far from simple, and in my own experience very useful: I think the only time ever I have fitted a polynomial to data with a definite purpose, it required that some points were fixed.<div>


<br></div><div>Seeing that polyfit is entirely coded in python, it would be relatively straightforward to add support for fixed points. It is also something I feel capable, and willing, of doing.</div><div><br></div><div>


 * Is such an additional feature something worthy of investigating, or will it never find its way into numpy.polyfit?</div><div> * Any ideas on the best syntax for the extra parameters?</div><div><br></div><div>
Thanks,</div><div><br></div><div>Jaime</div><span><font color="#888888"><div><br></div><div><div>-- <br>(\__/)<br>( O.o)<br>( > <) Este es Conejo. Copia a Conejo en tu firma y ayúdale en sus planes de dominación mundial.
</div></div></font></span></div>
<br></div></div>_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org" target="_blank">NumPy-Discussion@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
<br></blockquote></div><br></div>
<br>_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br>(\__/)<br>( O.o)<br>( > <) Este es Conejo. Copia a Conejo en tu firma y ayúdale en sus planes de dominación mundial.
</div></div>