Article View: pl.comp.lang.python
Article #27542Re: Interpolacja Liniowa
From: Piotr Chamera
Date: Fri, 25 Jun 2010 21:04
Date: Fri, 25 Jun 2010 21:04
32 lines
1678 bytes
1678 bytes
W dniu 2010-06-25 20:51, jcubic pisze: > Próbuje napisać funkcję do interpolacji liniowej, taką która przyjmuje > cztery parametry x1, y1, x2, y2 i zwracającą funkcję f(x). > > Próbowałem taki kod > > def get_interpolated(x1, y1, x2, y2): > 'function for linear interpolation.' > a = (y2 - y1) / (x2 - x1) > b = ((-x1) * (y2 - y1) - (x2 - x1) * (-y1)) / (x2 - x1) > def interpolated(x): > return a * x + b > return interpolated ale co nie działa? >>> f = get_interpolated(0, 0, 1, 1) >>> f <function interpolated at 0x00C57DB0> >>> f(2) 2 >>> f(3) 3 >>> g = get_interpolated(0, 0, 1, 2) >>> g(2) 4 >>> g(-23) -46 >>> get_interpolated(0, 1, 1, 2)(10) 11
Technical Details
Message-ID:
<i035le$ioj$1@news.onet.pl>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.rmf.pl!agh.edu.pl!news.agh.edu.pl!news.onet.pl!not-for-mailReferences:
<76da39d8-1875-4b7e-b66b-a1ef32499279@u26g2000yqu.googlegroups.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.rmf.pl!agh.edu.pl!news.agh.edu.pl!news.onet.pl!not-for-mail From: Piotr Chamera <piotr_chamera@poczta.onet.pl> Newsgroups: pl.comp.lang.python Subject: Re: Interpolacja Liniowa Date: Fri, 25 Jun 2010 23:04:36 +0200 Organization: http://onet.pl Lines: 33 Message-ID: <i035le$ioj$1@news.onet.pl> References: <76da39d8-1875-4b7e-b66b-a1ef32499279@u26g2000yqu.googlegroups.com> NNTP-Posting-Host: public45589.xdsl.centertel.pl Mime-Version: 1.0 X-Trace: news.onet.pl 1277499886 19219 79.163.178.21 (25 Jun 2010 21:04:46 GMT) X-Complaints-To: niusy@onet.pl NNTP-Posting-Date: Fri, 25 Jun 2010 21:04:46 +0000 (UTC) User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; pl; rv:1.9.1.10) Gecko/20100512 Lightning/1.0b1 Thunderbird/3.0.5 In-Reply-To: <76da39d8-1875-4b7e-b66b-a1ef32499279@u26g2000yqu.googlegroups.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit