On Thu, 10 Jun 2021, Sven Schreiber wrote:
Am 10.06.2021 um 17:55 schrieb Riccardo (Jack) Lucchetti:
> On Thu, 10 Jun 2021, Sven Schreiber wrote:
>> Am 10.06.2021 um 10:57 schrieb Riccardo (Jack) Lucchetti:
>>> package. Note: for large input vectors (n > 5) the recursion approach
>>> really is much slower than direct calculation, so there is quite a lot
>>> of room for optimisation.
>>>
>>> Opinions?
>>
>> OK, so what's the use case?
> I had written this in the context of a loop where I was comparing
> models of size k chosen from a set of n regressors. But of course this
> is more general than this. By the way, Octave has a similar function
> (nchoosek, IIRC).
Right, a couple of remarks:
-
https://de.mathworks.com/help/matlab/ref/nchoosek.html
- in gretl we have the closely related native bincoeff() function
- The bincoeff(n,k) doc says that k>n leads to NA, but actually
bincoeff(2,3) resuls in an invalid argument error, so I guess the doc
must be adjusted. (Same for k<0.)
I'd say so too: the doc, and not the behavior, should be adjusted.
You simply can't select n+1 or more, or a negative number, of
objects from an array of n objects so I think an error is called
for.
Am I missing some reason to the contrary?
Allin