|
|
Re: Compute a bivariate probability mass function on a predefined grid without loops
Posted:
Apr 22, 2012 4:47 AM
|
|
"Roger Stafford" wrote in message <jmum1d$pfn$1@newscl01ah.mathworks.com>... > - - - - - - - - - - - > In my mind the question is whether there might be an actual disadvantage in calling on 'interp1' with such large numbers as Massimo's N = 10000. Or in other words, does 'interp1' check for uniform spacing in k and m before proceeding with its interpolation? If not, then I would think it would be forced into an order(N*log(N)) complexity algorithm, as compared with only the necessary order(N).
Roger,
I test INTERP1 with various size and time it, and it looks like it does not check for uniform grid, meaning the run time seems to depends on the number of (known) grid points.
Now here is an interesting: The doc of the function INTERP2 mention that users can signal the input grid is uniform (by adding the '*' in front of the method string) for "faster interpolation". However my timing still show the run time still depends on the input grids.
I'm not sure what is the reason that the run time does not become independent with the '*' methods (I expect otherwise).
Back to direct vs interp1
The question I wonder is : does the direct calculation
p = (Sk-k(1))*((N-1)/(k(N)-k(1)))+1
always lead to the correct index from an input vector generated by LINSPACE due to numerical accuracy.
We have discussed in the past the discrepancy between LINSPACE and COLON-generated vectors. Similarly I guess in some vary extreme cases, p could return a wrong interval (?), whereas dichotomy search will always return the "right" interval, thus more robust. Your opinion?
Bruno
|
|