# [SciPy-User] maping a float to a function value

nicky van foreest vanforeest@gmail....
Thu Dec 10 14:01:17 CST 2009

Dear Chris, Peter, and Rob,

Thanks for your suggestions. All in all it seems easiest to implement
my function as a subclass of a list, and in the initialization use a
grid on which I define the function's values. As I don't need any
other values than the ones on the predefined grid, I don't think I'll
need an interpolating function---but I'll remember it for a next time

Nicky

2009/12/10 Christopher Barker <Chris.Barker@noaa.gov>:
>  > I need the (numerical) solution of the  integral
>> equation
>>
>> gamma(x) = c(x) + \int_0^\infty gamma(x-y) G(y) dy,
>>
>> for given functions c(x) and G(x). (There are some technical
>> conditions on G and c such that I can prove that the integral equation
>> has a solution.)  Now I like to store the values gamma(x) as keys of
>> x, as it feels natural. Moreover, I need gamma in a second integral
>> equation. Sure I can store gamma as an array, but then I have to
>> convert the index i to the key x, and I dislike this, as it is less
>> elegant, and requires extra code.
>
> However, I think it's a more correct solution -- as you've pointed out
> real numbers to not map directly to floats, and, indeed, you are never
> going to have gamma(x) pre-calculated for all x in your range. Indeed,
> it's a bit absurd to try to have gamma(x) for all floats in your range,
> either. So you are going to have to compute and store a subset. As they
> are ordered, it sure makes sense to simply store them, and it's easy to
> calculate an index -- you could put a different api on it if you really
> want:
>
>
> class gamma:
>
>     def__get_item(self, value):
>         # compute index form value here
>         return self._gamma[index]
>
>
> but, as you are storing only a subset of your possible values, it seems
> that interpolation really is the best and most natural way to go anyway.
>
> In fact, the above is simply a nearest neighbor interpolator already, as
> is your proposed dict with keys of rounded floats.
>
> -Chris
>
>
>
>
>
>
>
> --
> Christopher Barker, Ph.D.
> Oceanographer
>
> Emergency Response Division
> NOAA/NOS/OR&R            (206) 526-6959   voice
> 7600 Sand Point Way NE   (206) 526-6329   fax
> Seattle, WA  98115       (206) 526-6317   main reception
>
> Chris.Barker@noaa.gov
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>