1.2.3-SNAPSHOT permalink Arrow_down_16x16

permute

incanter.stats

  • (permute x)
  • (permute x y)
If provided a single argument, returns a permuted version of the
given collection. (perm x) is the same as (sample x).

If provided two arguments, returns two lists that are permutations
across the given collections. In other words, each of the new collections
will contain elements from both of the given collections. Useful for
permutation tests or randomization tests.

Examples:

(permute (range 10))
(permute (range 10) (range 10 20))


0 Examples top

Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source incanter/stats.clj:1875 top

(defn permute
" If provided a single argument, returns a permuted version of the
  given collection. (perm x) is the same as (sample x).

  If provided two arguments, returns two lists that are permutations
  across the given collections. In other words, each of the new collections
  will contain elements from both of the given collections. Useful for
  permutation tests or randomization tests.

  Examples:

    (permute (range 10))
    (permute (range 10) (range 10 20))


"
  ([x]
    (sample x))

  ([x y]
   (let [n1 (count x)
         samp (sample (concat x y) :replacement false)
         new-x (take n1 samp)
         new-y (drop n1 samp)]
     (list new-x new-y))))
Vars in incanter.stats/permute: defn let list
Used in 0 other vars

Comments top

1 comment(s) for permute.

Typo in documentation (perm x) should be (permute x)

Log in to add a comment.