<commit_before>(ns clojurewerkz.statistiker.distribution
  (:import [org.apache.commons.math3.distribution
            NormalDistribution
            LogNormalDistribution
            PoissonDistribution]))

(defn- distribution
  [gen]
  ((fn sample []
     (cons (.sample gen) (lazy-seq (sample))))))

(defn normal-distribution
  [mean sd]
  (distribution (NormalDistribution. mean sd)))

(defn poisson-distribution
  [mean eps max-iter]
  (distribution (PoissonDistribution. (double mean) (double eps) (int max-iter))))

(defn log-normal-distribution
  [scale shape inverse-accuracy]
  (distribution (LogNormalDistribution. (double scale)
                                        (double shape)
                                        (double inverse-accuracy))))<commit_msg>Add binomial and multivariate distributions<commit_after>(ns clojurewerkz.statistiker.distribution
  (:import [org.apache.commons.math3.distribution
            NormalDistribution
            LogNormalDistribution
            MultivariateNormalDistribution
            PoissonDistribution
            BinomialDistribution]))

(defn- distribution
  ([gen]
     ((fn sample []
        (cons (.sample gen) (lazy-seq (sample))))))
  ([gen conv]
     ((fn sample []
        (cons (conv (.sample gen)) (lazy-seq (sample)))))))

(defn normal-distribution
  [mean sd]
  (distribution (NormalDistribution. mean sd)))

(defn poisson-distribution
  [mean eps max-iter]
  (distribution (PoissonDistribution. (double mean) (double eps) (int max-iter))))

(defn log-normal-distribution
  [scale shape inverse-accuracy]
  (distribution (LogNormalDistribution. (double scale)
                                        (double shape)
                                        (double inverse-accuracy))))

(defn binomial-distribution
  [trials p]
  (distribution (BinomialDistribution. (int trials)
                                       (double p))))

(defn multivariate-normal-distribution
  [means covariances]
  (distribution (MultivariateNormalDistribution. (double-array means)
                                                 (into-array (map double-array covariances)))
                vec))
{'fraction_non_alphanumeric': 0.10492107706592387, 'fraction_numerical': 0.0009285051067780873, 'mean_word_length': 2.377742946708464, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2268062', 'n_tokens_mistral': 594, 'n_tokens_neox': 533, 'n_words': 140}