[R] Permutations
Peter Dalgaard BSA
p.dalgaard at biostat.ku.dk
Tue Sep 26 10:42:38 CEST 2000
Torsten Hothorn <Torsten.Hothorn at rzmail.uni-erlangen.de> writes:
> Hi,
>
> this is maybe not a real R problem but I want to solve this in R ;-)
>
> 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
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.
--
O__ ---- Peter Dalgaard Blegdamsvej 3
c/ /'_ --- Dept. of Biostatistics 2200 Cph. N
(*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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