🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.python
Article #27541

Interpolacja Liniowa

#27541
From: jcubic
Date: Fri, 25 Jun 2010 18:51
22 lines
1860 bytes
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

i taki

def get_interpolated(x1, y1, x2, y2):
    'function for linear interpolation.'
    def interpolated(x):
        return y1 + (((y2 - y1) / (x2 - x1)) * (x - x1))
    return interpolated

ale żaden nie działa.
Technical Details
Message-ID: <76da39d8-1875-4b7e-b66b-a1ef32499279@u26g2000yqu.googlegroups.com>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!news.nask.pl!news.nask.org.pl!news.uni-stuttgart.de!news.belwue.de!newsfeed01.sul.t-online.de!t-online.de!proxad.net!feeder1-2.proxad.net!74.125.46.134.MISMATCH!postnews.google.com!u26g2000yqu.googlegroups.com!not-for-mail

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!news.nask.pl!news.nask.org.pl!news.uni-stuttgart.de!news.belwue.de!newsfeed01.sul.t-online.de!t-online.de!proxad.net!feeder1-2.proxad.net!74.125.46.134.MISMATCH!postnews.google.com!u26g2000yqu.googlegroups.com!not-for-mail
From: jcubic <jcubic@onet.pl>
Newsgroups: pl.comp.lang.python
Subject: Interpolacja Liniowa
Followup-To: pl.comp.lang.python
Date: Fri, 25 Jun 2010 11:51:10 -0700 (PDT)
Organization: http://groups.google.com
Lines: 23
Message-ID: <76da39d8-1875-4b7e-b66b-a1ef32499279@u26g2000yqu.googlegroups.com>
NNTP-Posting-Host: 79.185.253.177
Mime-Version: 1.0
X-Trace: posting.google.com 1277491870 576 127.0.0.1 (25 Jun 2010 18:51:10 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Fri, 25 Jun 2010 18:51:10 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: u26g2000yqu.googlegroups.com; posting-host=79.185.253.177;  posting-account=vNJYPwoAAADS62q2La3KfvKT1ecTRahv
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; pl-PL; rv:1.9.2.3)  Gecko/20100423 Ubuntu/10.04 (lucid) Firefox/3.6.3 GTB7.1,gzip(gfe)
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit