Skip to content

Commit

Permalink
bigml.sample => bigml.sampling
Browse files Browse the repository at this point in the history
  • Loading branch information
ashenfad committed Jan 2, 2013
1 parent 9703e92 commit eb1f4bc
Show file tree
Hide file tree
Showing 15 changed files with 40 additions and 40 deletions.
6 changes: 3 additions & 3 deletions project.clj
Original file line number Original file line Diff line number Diff line change
@@ -1,9 +1,9 @@
(defproject sample "2.1.0" (defproject sampling "2.1.0"
:description "Random Sampling in Clojure" :description "Random Sampling in Clojure"
:url "https://github.com/bigmlcom/sample" :url "https://github.com/bigmlcom/sampling"
:license {:name "Apache License, Version 2.0" :license {:name "Apache License, Version 2.0"
:url "http://www.apache.org/licenses/LICENSE-2.0"} :url "http://www.apache.org/licenses/LICENSE-2.0"}
:dependencies [[org.clojure/clojure "1.4.0"] :dependencies [[org.clojure/clojure "1.4.0"]
[incanter/parallelcolt "0.9.4"] [incanter/parallelcolt "0.9.4"]
[org.clojure/data.finger-tree "0.0.1"]] [org.clojure/data.finger-tree "0.0.1"]]
:aot [bigml.sample.reservoir.mergeable]) :aot [bigml.sampling.reservoir.mergeable])
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
;; Licensed under the Apache License, Version 2.0 ;; Licensed under the Apache License, Version 2.0
;; http://www.apache.org/licenses/LICENSE-2.0 ;; http://www.apache.org/licenses/LICENSE-2.0


(ns bigml.sample.occurrence (ns bigml.sampling.occurrence
"Provides functions for computing the number of occurrences to be "Provides functions for computing the number of occurrences to be
expected for an item in a population when sampled with expected for an item in a population when sampled with
replacement." replacement."
(:import (cern.jet.math.tdouble DoubleArithmetic)) (:import (cern.jet.math.tdouble DoubleArithmetic))
(:require (bigml.sample [random :as random]))) (:require (bigml.sampling [random :as random])))


(def default-probability-cutoff (def default-probability-cutoff
"The cumulative-probabilities fn will stop calculating occurrence "The cumulative-probabilities fn will stop calculating occurrence
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
;; Licensed under the Apache License, Version 2.0 ;; Licensed under the Apache License, Version 2.0
;; http://www.apache.org/licenses/LICENSE-2.0 ;; http://www.apache.org/licenses/LICENSE-2.0


(ns bigml.sample.random (ns bigml.sampling.random
"Functions for creating and using a random number generator." "Functions for creating and using a random number generator."
(:import (cern.jet.random.tdouble.engine MersenneTwister64) (:import (cern.jet.random.tdouble.engine MersenneTwister64)
(java.util Random))) (java.util Random)))
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
;; Licensed under the Apache License, Version 2.0 ;; Licensed under the Apache License, Version 2.0
;; http://www.apache.org/licenses/LICENSE-2.0 ;; http://www.apache.org/licenses/LICENSE-2.0


(ns bigml.sample.reservoir (ns bigml.sampling.reservoir
"Provides random sampling using reservoirs. This is useful when the "Provides random sampling using reservoirs. This is useful when the
original population can't be kept in memory but the sample set original population can't be kept in memory but the sample set
can." can."
(:require (bigml.sample.reservoir [efraimidis :as efraimidis] (:require (bigml.sampling.reservoir [efraimidis :as efraimidis]
[insertion :as insertion])) [insertion :as insertion]))
(:import (bigml.sample.reservoir.mergeable MergeableReservoir)) (:import (bigml.sampling.reservoir.mergeable MergeableReservoir))
(:refer-clojure :exclude [merge])) (:refer-clojure :exclude [merge]))


(def ^:private implementations (def ^:private implementations
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
;; Licensed under the Apache License, Version 2.0 ;; Licensed under the Apache License, Version 2.0
;; http://www.apache.org/licenses/LICENSE-2.0 ;; http://www.apache.org/licenses/LICENSE-2.0


(ns bigml.sample.reservoir.efraimidis (ns bigml.sampling.reservoir.efraimidis
"Provides weighted random sampling using reservoirs as described by "Provides weighted random sampling using reservoirs as described by
Efraimidis and Spirakis. Efraimidis and Spirakis.
http://utopia.duth.gr/~pefraimi/research/data/2007EncOfAlg.pdf" http://utopia.duth.gr/~pefraimi/research/data/2007EncOfAlg.pdf"
(:require (bigml.sample [random :as random] (:require (bigml.sampling [random :as random]
[util :as util]) [util :as util])
(clojure.data [finger-tree :as tree])) (clojure.data [finger-tree :as tree]))
(:import (bigml.sample.reservoir.mergeable MergeableReservoir))) (:import (bigml.sampling.reservoir.mergeable MergeableReservoir)))


(def ^:private compare-k (def ^:private compare-k
#(compare (:k %1) (:k %2))) #(compare (:k %1) (:k %2)))
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
;; Licensed under the Apache License, Version 2.0 ;; Licensed under the Apache License, Version 2.0
;; http://www.apache.org/licenses/LICENSE-2.0 ;; http://www.apache.org/licenses/LICENSE-2.0


(ns bigml.sample.reservoir.insertion (ns bigml.sampling.reservoir.insertion
"Provides random sampling using reservoirs. Uses an insertion "Provides random sampling using reservoirs. Uses an insertion
method that might originally be from Chao's 'A general purpose method that might originally be from Chao's 'A general purpose
unequal probability sampling plan'. It's behind a paywall, unequal probability sampling plan'. It's behind a paywall,
however, so that remains a mystery to me." however, so that remains a mystery to me."
(:require (bigml.sample [simple :as simple] (:require (bigml.sampling [simple :as simple]
[random :as random] [random :as random]
[occurrence :as occurrence])) [occurrence :as occurrence]))
(:import (bigml.sample.reservoir.mergeable MergeableReservoir))) (:import (bigml.sampling.reservoir.mergeable MergeableReservoir)))


(defmulti ^:private insert (defmulti ^:private insert
(fn [reservoir _] (fn [reservoir _]
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
;; Licensed under the Apache License, Version 2.0 ;; Licensed under the Apache License, Version 2.0
;; http://www.apache.org/licenses/LICENSE-2.0 ;; http://www.apache.org/licenses/LICENSE-2.0


(ns bigml.sample.reservoir.mergeable (ns bigml.sampling.reservoir.mergeable
"Provides the definition for mergeable reservoirs.") "Provides the definition for mergeable reservoirs.")


(defprotocol MergeableReservoir (defprotocol MergeableReservoir
Expand Down
6 changes: 3 additions & 3 deletions src/bigml/sample/simple.clj → src/bigml/sampling/simple.clj
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
;; Licensed under the Apache License, Version 2.0 ;; Licensed under the Apache License, Version 2.0
;; http://www.apache.org/licenses/LICENSE-2.0 ;; http://www.apache.org/licenses/LICENSE-2.0


(ns bigml.sample.simple (ns bigml.sampling.simple
"Provides simple random sampling. The original population is kept in "Provides simple random sampling. The original population is kept in
memory but the resulting sample set is produced as a lazy memory but the resulting sample set is produced as a lazy
sequence." sequence."
(:require (bigml.sample [random :as random] (:require (bigml.sampling [random :as random]
[util :as util]))) [util :as util])))


(defn- with-replacement [coll rnd] (defn- with-replacement [coll rnd]
(when-not (empty? coll) (when-not (empty? coll)
Expand Down
6 changes: 3 additions & 3 deletions src/bigml/sample/stream.clj → src/bigml/sampling/stream.clj
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
;; Licensed under the Apache License, Version 2.0 ;; Licensed under the Apache License, Version 2.0
;; http://www.apache.org/licenses/LICENSE-2.0 ;; http://www.apache.org/licenses/LICENSE-2.0


(ns bigml.sample.stream (ns bigml.sampling.stream
"Provides streaming sampling. Neither the input population or the "Provides streaming sampling. Neither the input population or the
resulting sample are kept in memory. The order of the sample is resulting sample are kept in memory. The order of the sample is
not randomized, but will be in the order of the input population." not randomized, but will be in the order of the input population."
(:require (bigml.sample [random :as random] (:require (bigml.sampling [random :as random]
[occurrence :as occurrence]))) [occurrence :as occurrence])))


(defn- rate-distribution [sample-size pop-size] (defn- rate-distribution [sample-size pop-size]
(apply sorted-map (apply sorted-map
Expand Down
2 changes: 1 addition & 1 deletion src/bigml/sample/util.clj → src/bigml/sampling/util.clj
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
;; Licensed under the Apache License, Version 2.0 ;; Licensed under the Apache License, Version 2.0
;; http://www.apache.org/licenses/LICENSE-2.0 ;; http://www.apache.org/licenses/LICENSE-2.0


(ns bigml.sample.util (ns bigml.sampling.util
"Provides utility functions.") "Provides utility functions.")


(defn validated-weigh (defn validated-weigh
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
;; Licensed under the Apache License, Version 2.0 ;; Licensed under the Apache License, Version 2.0
;; http://www.apache.org/licenses/LICENSE-2.0 ;; http://www.apache.org/licenses/LICENSE-2.0


(ns bigml.sample.test.occurrence (ns bigml.sampling.test.occurrence
(:use clojure.test) (:use clojure.test)
(:require (bigml.sample [occurrence :as occurrence]))) (:require (bigml.sampling [occurrence :as occurrence])))


(def big-result (def big-result
1498231660179642550080525374062985229379154060073454416056804436265250417504978421344703666672011193783194306251922106632531575096104465752579970958417306283423558722428981480592122380206679550814874547016793880384420005011964284022150602938812288536154567998961655336231440060094535026560416077739589623596000N) 1498231660179642550080525374062985229379154060073454416056804436265250417504978421344703666672011193783194306251922106632531575096104465752579970958417306283423558722428981480592122380206679550814874547016793880384420005011964284022150602938812288536154567998961655336231440060094535026560416077739589623596000N)
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
;; Licensed under the Apache License, Version 2.0 ;; Licensed under the Apache License, Version 2.0
;; http://www.apache.org/licenses/LICENSE-2.0 ;; http://www.apache.org/licenses/LICENSE-2.0


(ns bigml.sample.test.reservoir (ns bigml.sampling.test.reservoir
(:use clojure.test (:use clojure.test
bigml.sample.test.util) bigml.sampling.test.util)
(:require (bigml.sample [reservoir :as reservoir]))) (:require (bigml.sampling [reservoir :as reservoir])))


(deftest sample (deftest sample
(is (about-eq (reduce + (reservoir/sample (range 1000) 500)) (is (about-eq (reduce + (reservoir/sample (range 1000) 500))
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
;; Licensed under the Apache License, Version 2.0 ;; Licensed under the Apache License, Version 2.0
;; http://www.apache.org/licenses/LICENSE-2.0 ;; http://www.apache.org/licenses/LICENSE-2.0


(ns bigml.sample.test.simple (ns bigml.sampling.test.simple
(:use clojure.test (:use clojure.test
bigml.sample.test.util) bigml.sampling.test.util)
(:require (bigml.sample [simple :as simple] (:require (bigml.sampling [simple :as simple]
[random :as random]))) [random :as random])))


(deftest sample (deftest sample
(is (about-eq (reduce + (take 500 (simple/sample (range 1000)))) (is (about-eq (reduce + (take 500 (simple/sample (range 1000))))
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
;; Licensed under the Apache License, Version 2.0 ;; Licensed under the Apache License, Version 2.0
;; http://www.apache.org/licenses/LICENSE-2.0 ;; http://www.apache.org/licenses/LICENSE-2.0


(ns bigml.sample.test.stream (ns bigml.sampling.test.stream
(:use clojure.test (:use clojure.test
bigml.sample.test.util) bigml.sampling.test.util)
(:require (bigml.sample [stream :as stream]))) (:require (bigml.sampling [stream :as stream])))


(deftest sample (deftest sample
(is (about-eq (reduce + (stream/sample (range 1000) 500 1000)) (is (about-eq (reduce + (stream/sample (range 1000) 500 1000))
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
;; Licensed under the Apache License, Version 2.0 ;; Licensed under the Apache License, Version 2.0
;; http://www.apache.org/licenses/LICENSE-2.0 ;; http://www.apache.org/licenses/LICENSE-2.0


(ns bigml.sample.test.util) (ns bigml.sampling.test.util)


(defn about-eq (defn about-eq
"Returns true if the absolute value of the difference "Returns true if the absolute value of the difference
Expand Down

0 comments on commit eb1f4bc

Please sign in to comment.