[R] Permutations

Torsten Hothorn Torsten.Hothorn at rzmail.uni-erlangen.de
Tue Sep 26 10:53:06 CEST 2000


> > Consider the set of all permutations of 1:N (=: S, say) and a fixed
> > element a from S. I now need to compute the number of permutations s from
> > S which are elementwise less or equal to a: | { s \in S | s <= a } |
> > 
> > Of cource, backtracking using a tree structure is possible. Does anyone
> > know an efficient way?
> 
> Er, "elementwise less than or equal"? Maybe I got off on the wrong
> foot today, but if you mean what I think you mean, I get

No, I got off on the wrong foot today:

> 
> N can only be where it is in  a  or it would replace something smaller
> N-1 could be where it is or where N was, but N mustn't move
> ...
> 
> I.e. I'd get the answer to be 1, namely a itself.
> 

1 is right. 

Torsten

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list