Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Compute a bivariate probability mass function on a predefined grid without loops
Replies: 10   Last Post: Apr 22, 2012 2:43 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Bruno Luong

Posts: 8,464
Registered: 7/26/08
Re: Compute a bivariate probability mass function on a predefined grid without loops
Posted: Apr 22, 2012 4:47 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

"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



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2013. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.