Database Reference
In-Depth Information
Getting ready
For this recipe, we'll use these dependencies in out project.clj ile:
(defproject statim "0.1.0"
:dependencies [[org.clojure/clojure "1.6.0"]
[incanter "1.5.5"]])
We'll also use these namespaces in our script or REPL:
(require
'[incanter.core :as i]
'[incanter.stats :as s]
'incanter.io
'[incanter.charts :as c])
For data, we'll use the same census data that we did in the Working with changes in
values recipe:
(def data-file "data/all_160_in_51.P3.csv")
How to do it…
This is a simple recipe. Here, we'll use Incanter's bootstrapping functions to estimate the
median of the census population:
1.
We'll read in the data:
(def data (incanter.io/read-dataset data-file :header true))
2.
Then we'll pull out the population column and resample it for the median using the
incanter.stats/bootstrap function:
(def pop100 (i/sel data :cols :POP100))
(def samples (s/bootstrap pop100 s/median :size 2000))
3.
Now let's look at a histogram of the samples to see what the distribution of the
median looks like:
(i/view (c/histogram samples))
 
Search WWH ::




Custom Search