Re: interpolate large numbers [message #76475 is a reply to message #76474] |
Tue, 07 June 2011 17:41   |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
On Jun 7, 5:35 pm, ece <ecekile...@gmail.com> wrote:
> Hi,
> I have a problem. i want to interpolate linearly some large numbers
> such as:
>
> frequency L
> 6.28865e+14 8.2654538e+28
> 1.66951e+15 4.0936348e+28
> 1.75106e+15 3.9580807e+28
> 2.05175e+15 3.4878620e+28
> 2.31700e+15 3.0611352e+28
> 4.90883e+17 1.0399752e+25
> 1.47366e+18 1.2454723e+24
> 2.44933e+18 4.6650308e+23
>
> First I created the interval for the interpolation :
> range=maken(6.28865E+14,2.44933E+18,1000)
> I used the interpol:
> Lum=interpol(L,frequency,range)
>
> But when I plot the result it does not look a linear interpolation,
> there are gaps and curves between data points. Do you have a
> suggestion?
>
> My aim is to integrate this data points and get L. If I di it same way
> in the alog10(freq) and alog10(L) values the intepolation looks nice,
> but I couldn't figure out how to convert integral result in alog10
> values to normal scale.
As Paolo points out, your range is 6e14 to 2e18, or a factor of
3333x. Therefore, your interpolation grid has to have at least 3333
samples, but you would be better off using 33333 instead (a factor of
10x more).
You would probably be better off starting with logarithmically spaced
grid points instead of linear. That is a little harder to do since
the "bin" size is variable.
;; Sample logarithmically
alog10_range=maken(alog10(6.28865E+14),alog10(2.44933E+18),1 000)
alog10_Lum=interpol(alog10(L),alog10(frequency),range)
;; Convert to linear space
range = 10^(alog10_range)
Lum = 10^(alog10_Lum)
binsize = (range[1:*] - range)
binsize = [binsize[0], binsize]
;; Then integrate ...
It looks like you might have an astronomical spectrum. Some care
needs to be taken that the units are correct. Sometimes for example
the "L" values of your table might already be expressed as "per
logarithmic frequency interval."
Craig
|
|
|