Rank: 1574 based on 97 downloads (last 30 days) and 9 files submitted
photo

Peter Cotton

E-mail
Company/University
Benchmark Solutions

Personal Profile:

 

Watch this Author's files

 

Files Posted by Peter Cotton View all
Updated   File Tags Downloads
(last 30 days)
Comments Rating
16 Aug 2010 Screenshot intent.m Graphically display mfiles, and naive intent Author: Peter Cotton bioplot, files, functional, dir 10 0
  • 4.0
4.0 | 1 rating
16 Aug 2010 signature Parse function argument names from an mfile or anonymous function handle Author: Peter Cotton mfile, arguments, nargin, nargout, varargout, varargin 9 0
16 Aug 2010 Screenshot bernpdf Distribution of the sum of independent non-identical Bernoulli random variables using convolution Author: Peter Cotton statistics, probability, simulation, bernoulli, convolution, conv 12 0
15 Aug 2010 harville The Harville method for exacta, quinella and trifecta probabilities Author: Peter Cotton harville, statistics, probability, trifecta, exacta, quinella 14 0
15 Aug 2010 Screenshot ability ABILITY - Infer ability from probability of winning a competition Author: Peter Cotton statistics, probability, generalized, extreme value, gev, order statistics 4 0
Comments and Ratings by Peter Cotton View all
Updated File Comments Rating
29 Sep 2011 vecgcd Computes the GCD of the elements of the integer vector V. Author: Steven Gregory

typo on line 47?

28 Oct 2010 Automated composition of function handles Automatically compose function handles Author: Peter Cotton

I prefer and maintain functor.m (also on Matlab Central) rather than this code.

07 Sep 2010 xml_io_tools Read XML files into MATLAB struct and writes MATLAB data types to XML Author: Jaroslaw Tuszynski

Can I suggest a small modification to xml_read so that sparse matrices are returned as sparse matrices rather than a string describing their construction (to be passed to eval)?

16 Aug 2010 Non-Uniform Bernoulli Trials Exceedance Probability Calculates the probability of exceeding a given number of hits for a collection of Bernoulli trials Author: William

William,

I was looking for the same thing and ended up re-writing it myself (bernpdf.m). Let me know if you come across other analytic implementations (e.g. by Fourier transform).

I think you mean 'non-uniform p', for otherwise you can use binopdf.m in the stats toolbox.

Peter

ps: Sorry you find analytical statistics tiresome

04 Aug 2010 nsumk Returns the number and listing of n-tuples of non-negative integers adding up to k. Author: Peter Cotton

Hi Andy,

Apologies for my tardiness in replying and your suggestions are well intentioned. Small quibbles over timing are mere definitional (I need the right order - thus included sortrows) but potentially larger philosophical differences relate to the stability and maintainability of code (of which nsumk.m is a very tiny piece). I generally refrain from giving others style or programming advice but using a great honking general function might not always be the best decision when it can be accomplished either by three lines of code, or a teeny weeny function such as nsumk.m ... not that I knowingly made a conscious decision given my ignorance.

No justification is required for reducing code complexity but I leave the rants to others. I suggest googling "premature generalization", for example.

Regards,

Peter

Comments and Ratings on Peter Cotton's Files View all
Updated File Comment by Comments Rating
09 Nov 2014 intent.m Graphically display mfiles, and naive intent Author: Peter Cotton Chris FUNG

18 Aug 2010 nsumk Returns the number and listing of n-tuples of non-negative integers adding up to k. Author: Peter Cotton Rob Campbell

I have no use for this function but the above discussion is wonderful.

15 Aug 2010 nsumk Returns the number and listing of n-tuples of non-negative integers adding up to k. Author: Peter Cotton Peter Cotton

Thanks Jan,
I'll update the description
Peter

12 Aug 2010 nsumk Returns the number and listing of n-tuples of non-negative integers adding up to k. Author: Peter Cotton Sean

Ha ha ha! I thoroughly enjoyed this very entertaining discussion!

06 Aug 2010 nsumk Returns the number and listing of n-tuples of non-negative integers adding up to k. Author: Peter Cotton Jan Simon

VCHOOSEK is a Mex, which is > factor 100 faster than NCHOOSEK:
http://www.mathworks.com/matlabcentral/fileexchange/26190

You do not have to check twice, if n and k are scalars:
if ~isscalar(n) || ~isscalar(k); error(...); end
m = nchoosek(k+n-1,n-1);
if nargout == 2
dividers = [zeros(m,1), vchoosek((1:(k+n-1))',n-1),ones(m,1)*(k+n)];
x = diff(dividers,1,2)-1;
end
Congratulation for the great discussion! Jan

Contact us