Limit Guessing Algorithm

ram.rachum at gmail.com ram.rachum at gmail.com
Sun Dec 2 20:14:30 EST 2007


On Dec 3, 1:33 am, Roberto Bonvallet <rbonv... at gmail.com> wrote:
> On Dec 2, 5:27 pm, "ram.rac... at gmail.com" <ram.rac... at gmail.com>
> wrote:
>
> > It will accept a few data points (x,f(x)) of a function
> > that converges to some finite value when x converges to infinity. I
> > need the algorithm to guess what that limit is.
>
> Since there are an infinity of ways to estimate the limit, I suggest
> sticking to the simplest one:
>
> def guess_limit(points):
>     x, y = max(points)
>     return y
>
> > [
> > [1,8],
> > [2,7.5],
> > [3,7.25],
> > [4,7.125]
> > ]
> > Then the output will be 7. Or at least something close.
>
> For this data set, my function will return 7.125.  Is it close enough?
> Finding a better estimation is more a math problem than a Python one.
>
> Best regards,
> --
> Roberto Bonvallet

Roberto, your Zen-Python wisdom is irresistible :)



More information about the Python-list mailing list