Namespaces [ Expand All ] [ Collapse All ]

incanter.bayes incanter.censored incanter.charts incanter.chrono incanter.classification incanter.core incanter.datasets incanter.incremental-stats incanter.information-theory incanter.io incanter.optimize incanter.probability incanter.stats incanter.transformations- sample-model-params
- fn ([size linear-model])Returns a sample of the given size of the the parameters (coefficients anderror variance) of the given linear-model. The sample is generated usingGibbs sampling.See also:incanter.stats/linear-modelExamples:(use '(incanter core datasets stats charts bayes))(def ols-data (to-matrix (get-dataset :survey)))(def x (sel ols-data (range 0 2313) (range 1 10)))(def y (sel ols-data (range 0 2313) 10))(def lm (linear-model y x :intercept false))(def param-samp (sample-model-params 5000 lm));; view trace plots(view (trace-plot (:var param-samp )))(view (trace-plot (sel (:coefs param-samp) :cols 0)));; view histograms(view (histogram (:var param-samp)))(view (histogram (sel (:coefs param-samp) :cols 0)));; calculate statistics(map mean (trans (:coefs param-samp)))(map median (trans (:coefs param-samp)))(map sd (trans (:coefs param-samp)));; show the 95% bayesian confidence interval for the firt coefficient(quantile (sel (:coefs param-samp) :cols 0) :probs [0.025 0.975])

- sample-multinomial-params
- fn ([size counts])Returns a sample of multinomial proportion parameters.The counts are assumed to have a multinomial distribution.A uniform prior distribution is assigned to the multinomial vectortheta, then the posterior distribution of theta isproportional to a dirichlet distribution with parameters(plus counts 1).Examples:(use '(incanter core stats bayes charts))(def samp-props (sample-multinomial-params 1000 [727 583 137]));; view means, 95% CI, and histograms of the proportion parameters(mean (sel samp-props :cols 0))(quantile (sel samp-props :cols 0) :probs [0.0275 0.975])(view (histogram (sel samp-props :cols 0)))(mean (sel samp-props :cols 1))(quantile (sel samp-props :cols 1) :probs [0.0275 0.975])(view (histogram (sel samp-props :cols 1)))(mean (sel samp-props :cols 2))(quantile (sel samp-props :cols 2) :probs [0.0275 0.975])(view (histogram (sel samp-props :cols 2)));; view a histogram of the difference in proportions between the first;; two candidates(view (histogram (minus (sel samp-props :cols 0) (sel samp-props :cols 1))))

- sample-proportions
- fn ([size counts])sample-proportions has been renamed sample-multinomial-params

censored-mean-lower censored-mean-two-sided censored-mean-upper censored-variance-lower censored-variance-two-sided censored-variance-upper truncated-variance

- censored-mean-lower
- fn ([a mu sigma])Returns the mean of a normal distribution (with mean mu and standarddeviation sigma) with the lower tail censored at 'a'

- censored-mean-two-sided
- fn ([a b mu sigma])Returns the mean of a normal distribution (with mean mu and standarddeviation sigma) with the lower tail censored at 'a' and the uppertail censored at 'b'

- censored-mean-upper
- fn ([b mu sigma])Returns the mean of a normal distribution (with mean mu and standarddeviation sigma) with the upper tail censored at 'b'

- censored-variance-lower
- fn ([a mu sigma])Returns the variance of a normal distribution (with mean mu and standarddeviation sigma) with the lower tail censored at 'a'

- censored-variance-two-sided
- fn ([a b mu sigma])Returns the variance of a normal distribution (with mean mu and standarddeviation sigma) with the lower tail censored at 'a' and the uppertail censored at 'b'

- censored-variance-upper
- fn ([b mu sigma])Returns the variance of a normal distribution (with mean mu and standarddeviation sigma) with the upper tail censored at 'b'

- truncated-variance
- fn ([& options])Returns the variance of a normal distribution truncated at a and b.Options::mean (default 0) mean of untruncated normal distribution:sd (default 1) standard deviation of untruncated normal distribution:a (default -infinity) lower truncation point:b (default +infinity) upper truncation pointExamples:(use '(incanter core stats))(truncated-variance :a -1.96 :b 1.96)(truncated-variance :a 0)(truncated-variance :b 0)(use 'incanter.charts)(def x (range -3 3 0.1))(def plot (xy-plot x (map #(truncated-variance :a %) x)))(view plot)(add-lines plot x (map #(truncated-variance :b %) x))(def samp (sample-normal 10000))(add-lines plot x (map #(variance (filter (fn [s] (> s %)) samp)) x))(add-lines plot x (map #(variance (mult samp (indicator (fn [s] (> s %)) samp))) x))References:DeMaris, A. (2004) Regression with social data: modeling continuous and limited response variables.Wiley-IEEE.http://en.wikipedia.org/wiki/Truncated_normal_distribution

add-box-plot add-categories add-function add-histogram add-lines add-pointer add-points add-polygon add-text bar-chart bland-altman-plot box-plot clear-background function-plot histogram line-chart line-plot qq-plot scatter-plot set-alpha set-background-alpha set-title set-x-label set-y-label trace-plot xy-plot

- add-box-plot
- macro ([chart x & options])Adds an additional box to an existing box-plot, returns the modified chart object.Options::series-label (default x expression)Examples:(use '(incanter core charts stats))(doto (box-plot (sample-normal 1000) :legend true)view(add-box-plot (sample-normal 1000 :sd 2))(add-box-plot (sample-gamma 1000)))References:http://www.jfree.org/jfreechart/api/javadoc/http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/JFreeChart.html

- add-categories
- macro ([chart categories values & options])Adds an additional categories to an existing bar-chart or line-chart, returns the modified chart object.Options::group-byExamples:(use '(incanter core charts stats))(def seasons (mapcat identity (repeat 3 ["winter" "spring" "summer" "fall"])))(def years (mapcat identity (repeat 4 [2007 2008 2009])))(def x (sample-uniform 12 :integers true :max 100))(def plot (bar-chart years x :group-by seasons :legend true))(view plot)(add-category-line plot (plus 3 years) (sample-uniform 12 :integers true :max 100) :group-by seasons)(def plot2 (line-chart years x :group-by seasons :legend true))(view plot2)(add-category-line plot2 (plus 3 years) (sample-uniform 12 :integers true :max 100) :group-by seasons)References:http://www.jfree.org/jfreechart/api/javadoc/http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/JFreeChart.html

- add-function
- macro ([chart function min-range max-range & options])Adds a xy-plot of the given function to the given chart, returninga modified version of the chart.Options::series-label (default x expression):step-size (default (/ (- max-range min-range) 500))See also:function-plot, view, save, add-function, add-points, add-linesExamples:(use '(incanter core stats charts));; plot the sine and cosine functions(doto (function-plot sin (- Math/PI) Math/PI)(add-function cos (- Math/PI) Math/PI)view);; plot two normal pdf functions(doto (function-plot pdf-normal -3 3 :legend true)(add-function (fn [x] (pdf-normal x :mean 0.5 :sd 0.5)) -3 3)view);; plot a user defined function and its derivative(use '(incanter core charts optimize));; define the function, x^3 + 2x^2 + 2x + 3(defn cubic [x] (+ (* x x x) (* 2 x x) (* 2 x) 3));; use the derivative function to get a function;; that approximates its derivative(def deriv-cubic (derivative cubic));; plot the cubic function and its derivative(doto (function-plot cubic -10 10)(add-function deriv-cubic -10 10)view)

- add-histogram
- macro ([chart x & options])Adds a histogram to an existing histogram plot, returns the modifiedchart object.Options::nbins (default 10) number of bins for histogram:series-label (default x expression)Examples:(use '(incanter core charts stats))(doto (histogram (sample-normal 1000):legend true)view(add-histogram (sample-normal 1000 :sd 0.5)))References:http://www.jfree.org/jfreechart/api/javadoc/http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/JFreeChart.html

- add-lines
- macro ([chart x y & options])Plots lines on the given scatter or line plot of the (x,y) points.Equivalent to R's lines function, returns the modified chart object.Options::series-label (default x expression)Examples:(use '(incanter core stats io datasets charts))(def cars (to-matrix (get-dataset :cars)))(def y (sel cars :cols 0))(def x (sel cars :cols 1))(def plot1 (scatter-plot x y :legend true))(view plot1);; add regression line to scatter plot(def lm1 (linear-model y x))(add-lines plot1 x (:fitted lm1));; model the data without an intercept(def lm2 (linear-model y x :intercept false))(add-lines plot1 x (:fitted lm2));; Clojure's doto macro can be used to build a chart(doto (xy-plot x (pdf-normal x))viewclear-background(add-lines x (pdf-normal x :sd 1.5))(add-lines x (pdf-normal x :sd 0.5)))References:http://www.jfree.org/jfreechart/api/javadoc/http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/JFreeChart.html

- add-pointer
- fn ([chart x y & options])Adds an arrow annotation to the given chart.Arguments:chart -- the chart to annotatex, y -- the coordinate to add the annotationOptions::text -- (default "") text to include at the end of the arrow:angle -- (default :nw) either a number indicating the angle of the arrow,or a keyword indicating a direction (:north :nw :west :sw :south:se :east :ne)Examples:(use '(incanter core charts))(def x (range (* -2 Math/PI) (* 2 Math/PI) 0.01))(def plot (xy-plot x (sin x)))(view plot);; annotate the plot(doto plot(add-pointer (- Math/PI) (sin (- Math/PI)) :text "(-pi, (sin -pi))")(add-pointer Math/PI (sin Math/PI) :text "(pi, (sin pi))" :angle :ne)(add-pointer (* 1/2 Math/PI) (sin (* 1/2 Math/PI)) :text "(pi/2, (sin pi/2))" :angle :south));; try the different angle options(add-pointer plot 0 0 :text "north" :angle :north)(add-pointer plot 0 0 :text "nw" :angle :nw)(add-pointer plot 0 0 :text "ne" :angle :ne)(add-pointer plot 0 0 :text "west" :angle :west)(add-pointer plot 0 0 :text "east" :angle :east)(add-pointer plot 0 0 :text "south" :angle :south)(add-pointer plot 0 0 :text "sw" :angle :sw)(add-pointer plot 0 0 :text "se" :angle :se)

- add-points
- macro ([chart x y & options])Plots points on the given scatter-plot or xy-plot of the (x,y) points.Equivalent to R's lines function, returns the modified chart object.Options::series-label (default x expression)Examples:(use '(incanter core stats io datasets charts))(def cars (to-matrix (get-dataset :cars)))(def y (sel cars :cols 0))(def x (sel cars :cols 1));; add regression line to scatter plot(def lm1 (linear-model y x));; model the data without an intercept(def lm2 (linear-model y x :intercept false))(doto (xy-plot x (:fitted lm1) :legend true)view(add-points x y)(add-lines x (:fitted lm2)))References:http://www.jfree.org/jfreechart/api/javadoc/http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/JFreeChart.html

- add-polygon
- fn ([chart coords & options])Adds a polygon outline defined by a given coordinates. The last coordinate willclose with the first. If only two points are given, it will plot a line.Arguments:chart -- the chart to add the polygon to.coords -- a list of coords (an n-by-2 matrix can also be used)Examples:(use '(incanter core stats charts))(def x (range -3 3 0.01))(def plot (xy-plot x (pdf-normal x)))(view plot);; add polygon to the chart(add-polygon plot [[-1.96 0] [1.96 0] [1.96 0.4] [-1.96 0.4]]);; the coordinates can also be passed in a matrix;; (def points (matrix [[-1.96 0] [1.96 0] [1.96 0.4] [-1.96 0.4]]));; (add-polygon plot points);; add a text annotation(add-text plot -1.25 0.35 "95% Conf Interval");; PCA chart example(use '(incanter core stats charts datasets));; load the iris dataset(def iris (to-matrix (get-dataset :iris)));; run the pca(def pca (principal-components (sel iris :cols (range 4))));; extract the first two principal components(def pc1 (sel (:rotation pca) :cols 0))(def pc2 (sel (:rotation pca) :cols 1));; project the first four dimension of the iris data onto the first;; two principal components(def x1 (mmult (sel iris :cols (range 4)) pc1))(def x2 (mmult (sel iris :cols (range 4)) pc2));; now plot the transformed data, coloring each species a different color(def plot (scatter-plot x1 x2:group-by (sel iris :cols 4):x-label "PC1" :y-label "PC2" :title "Iris PCA"))(view plot);; put box around the first group(add-polygon plot [[-3.2 -6.3] [-2 -6.3] [-2 -3.78] [-3.2 -3.78]]);; add some text annotations(add-text plot -2.5 -6.5 "Setosa")(add-text plot -5 -5.5 "Versicolor")(add-text plot -8 -5.5 "Virginica")

- add-text
- fn ([chart x y text & options])Adds a text annotation centered at the given coordinates.Arguments:chart -- the chart to annotatex, y -- the coordinates to center the texttext -- the text to addExamples:;; PCA chart example(use '(incanter core stats charts datasets));; load the iris dataset(def iris (to-matrix (get-dataset :iris)));; run the pca(def pca (principal-components (sel iris :cols (range 4))));; extract the first two principal components(def pc1 (sel (:rotation pca) :cols 0))(def pc2 (sel (:rotation pca) :cols 1));; project the first four dimension of the iris data onto the first;; two principal components(def x1 (mmult (sel iris :cols (range 4)) pc1))(def x2 (mmult (sel iris :cols (range 4)) pc2));; now plot the transformed data, coloring each species a different color(def plot (scatter-plot x1 x2:group-by (sel iris :cols 4):x-label "PC1" :y-label "PC2" :title "Iris PCA"))(view plot);; add some text annotations(add-text plot -2.5 -6.5 "Setosa")(add-text plot -5 -5.5 "Versicolor")(add-text plot -8 -5.5 "Virginica")

- bar-chart
- macro ([categories values & options])Returns a JFreeChart object representing a bar-chart of the given data.Use the 'view' function to display the chart, or the 'save' functionto write it to a file.Arguments:categories -- a sequence of categoriesvalues -- a sequence of numeric valuesOptions::title (default 'Histogram') main title:x-label (default 'Categories'):y-label (default 'Value'):legend (default false) prints legend:vertical (default true) the orientation of the plot:group-by (default nil) -- a vector of values used to group the values intoseries within each category.See also:view and saveExamples:(use '(incanter core stats charts datasets))(def data (get-dataset :co2))(def grass-type (sel data :cols 1))(def treatment-type (sel data :cols 2))(def uptake (sel data :cols 4))(view (bar-chart grass-type uptake:title "CO2 Uptake":group-by treatment-type:x-label "Grass Types" :y-label "Uptake":legend true))(def data (get-dataset :airline-passengers))(def years (sel data :cols 0))(def months (sel data :cols 2))(def passengers (sel data :cols 1))(view (bar-chart years passengers :group-by months :legend true))(view (bar-chart months passengers :group-by years :legend true))(def data (get-dataset :austres))(view data)(def plot (bar-chart (sel data :cols 0) (sel data :cols 1):group-by (sel data :cols 2) :legend true))(view plot)(save plot "/tmp/austres_plot.png" :width 1000)(view "file:///tmp/austres_plot.png")(def seasons (mapcat identity (repeat 3 ["winter" "spring" "summer" "fall"])))(def years (mapcat identity (repeat 4 [2007 2008 2009])))(def values (sample-uniform 12 :integers true :max 100))(view (bar-chart years values :group-by seasons :legend true))(view (bar-chart ["a" "b" "c"] [10 20 30]))(view (bar-chart ["a" "a" "b" "b" "c" "c" ] [10 20 30 10 40 20]:legend true:group-by ["I" "II" "I" "II" "I" "II"]))(view (bar-chart (sample "abcdefghij" :size 10 :replacement true)(sample-uniform 10 :max 50) :legend true))References:http://www.jfree.org/jfreechart/api/javadoc/http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/JFreeChart.html

- bland-altman-plot
- fn ([x1 x2])Examples:(use '(incanter core datasets charts))(def flow-meter (to-matrix (get-dataset :flow-meter)))(def x1 (sel flow-meter :cols 1))(def x2 (sel flow-meter :cols 3))(view (bland-altman-plot x1 x2))References:http://en.wikipedia.org/wiki/Bland-Altman_plothttp://www-users.york.ac.uk/~mb55/meas/ba.htm

- box-plot
- macro ([x & options])Returns a JFreeChart object representing a box-plot of the given data.Use the 'view' function to display the chart, or the 'save' functionto write it to a file.Options::title (default 'Histogram') main title:x-label (default x expression):y-label (default 'Frequency'):legend (default false) prints legend:series-label (default x expression):group-by (default nil) -- a vector of values used to group the x values into series.See also:view and saveExamples:(use '(incanter core stats charts))(def gamma-box-plot (box-plot (sample-gamma 1000 :shape 1 :rate 2):title "Gamma Boxplot":legend true))(view gamma-box-plot)(add-box-plot gamma-box-plot (sample-gamma 1000 :shape 2 :rate 2))(add-box-plot gamma-box-plot (sample-gamma 1000 :shape 3 :rate 2));; use the group-by options(use '(incanter core stats datasets charts))(def iris (to-matrix (get-dataset :iris)))(view (box-plot (sel iris :cols 0) :group-by (sel iris :cols 4) :legend true));; see INCANTER_HOME/examples/probability_plots.clj for more examples of plotsReferences:http://www.jfree.org/jfreechart/api/javadoc/http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/JFreeChart.html

- clear-background
- fn ([chart])Sets the alpha level (transparancy) of the plot's background to zero,removing the default grid, returns the modified chart object.References:http://www.jfree.org/jfreechart/api/javadoc/http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/JFreeChart.html

- function-plot
- macro ([function min-range max-range & options])Returns a xy-plot object of the given function over the range indicatedby the min-range and max-range arguments. Use the 'view' function todisplay the chart, or the 'save' function to write it to a file.Options::title (default 'Histogram') main title:x-label (default x expression):y-label (default 'Frequency'):legend (default false) prints legend:series-label (default x expression):step-size (default (/ (- max-range min-range) 500))See also:view, save, add-points, add-linesExamples:(use '(incanter core stats charts))(view (function-plot sin (- Math/PI) Math/PI))(view (function-plot pdf-normal -3 3))(defn cubic [x] (+ (* x x x) (* 2 x x) (* 2 x) 3))(view (function-plot cubic -10 10))

- histogram
- macro ([x & options])Returns a JFreeChart object representing the histogram of the given data.Use the 'view' function to display the chart, or the 'save' functionto write it to a file.Options::nbins (default 10) number of bins:density (default false) if false, plots frequency, otherwise density:title (default 'Histogram') main title:x-label (default x expression):y-label (default 'Frequency'):legend (default false) prints legend:series-label (default x expression)See also:view, save, add-histogramExamples:(use '(incanter core charts stats))(view (histogram (sample-normal 1000)))# plot a density histogram(def hist (histogram (sample-normal 1000) :density true))(view hist)# add a normal density line to the plot(def x (range -4 4 0.01))(add-lines hist x (pdf-normal x))# plot some gamma data(def gam-hist (histogram (sample-gamma 1000) :density true :nbins 30))(view gam-hist)(def x (range 0 8 0.01))(add-lines gam-hist x (pdf-gamma x));; see INCANTER_HOME/examples/probability_plots.clj for more examples of plotsReferences:http://www.jfree.org/jfreechart/api/javadoc/http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/JFreeChart.html

- line-chart
- macro ([categories values & options])Returns a JFreeChart object representing a line-chart of the given values and categories.Use the 'view' function to display the chart, or the 'save' functionto write it to a file.Arguments:categories -- a sequence of categoriesvalues -- a sequence of numeric valuesOptions::title (default 'Histogram') main title:x-label (default 'Categories'):y-label (default 'Value'):legend (default false) prints legend:group-by (default nil) -- a vector of values used to group the values intoseries within each category.See also:view and saveExamples:(use '(incanter core stats charts datasets))(def data (get-dataset :airline-passengers))(def years (sel data :cols 0))(def months (sel data :cols 2))(def passengers (sel data :cols 1))(view (line-chart years passengers :group-by months :legend true))(view (line-chart months passengers :group-by years :legend true))(def seasons (mapcat identity (repeat 3 ["winter" "spring" "summer" "fall"])))(def years (mapcat identity (repeat 4 [2007 2008 2009])))(def x (sample-uniform 12 :integers true :max 100))(view (line-chart years x :group-by seasons :legend true))(view (line-chart ["a" "b" "c" "d" "e" "f"] [10 20 30 10 40 20]))(view (line-chart (sample "abcdefghij" :size 10 :replacement true)(sample-uniform 10 :max 50) :legend true))References:http://www.jfree.org/jfreechart/api/javadoc/http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/JFreeChart.html

- line-plot
- fn ([x y & options])WARNING: line-plot has been renamed xy-plot.

- qq-plot
- fn ([x & options])Returns a QQ-Plot object. Use the 'view' function to display it.References:http://en.wikipedia.org/wiki/QQ_plotExamples:(use '(incanter core stats charts))(view (qq-plot (sample-normal 100)))(view (qq-plot (sample-exp 100)))(view (qq-plot (sample-gamma 100)))

- scatter-plot
- macro ([x y & options])Returns a JFreeChart object representing a scatter-plot of the given data.Use the 'view' function to display the chart, or the 'save' functionto write it to a file.Options::title (default 'Histogram') main title:x-label (default x expression):y-label (default 'Frequency'):legend (default false) prints legend:series-label (default x expression):group-by (default nil) -- a vector of values used to group the x and y values into series.See also:view, save, add-points, add-linesExamples:(use '(incanter core stats charts));; create some data(def mvn-samp (sample-multivariate-normal 1000 :mean [7 5] :sigma (matrix [[2 1.5] [1.5 3]])));; create scatter-plot of points(def mvn-plot (scatter-plot (sel mvn-samp :cols 0) (sel mvn-samp :cols 1)))(view mvn-plot);; add regression line to scatter plot(def x (sel mvn-samp :cols 0))(def y (sel mvn-samp :cols 1))(def lm (linear-model y x))(add-lines mvn-plot x (:fitted lm));; use :group-by option(use '(incanter core stats datasets charts));; load the :iris dataset(def iris (to-matrix (get-dataset :iris)));; plot the first two columns grouped by the fifth column(view (scatter-plot (sel iris :cols 0) (sel iris :cols 1) :group-by (sel iris :cols 4)));; see INCANTER_HOME/examples/probability_plots.clj for more examples of plotsReferences:http://www.jfree.org/jfreechart/api/javadoc/http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/JFreeChart.html

- set-alpha
- fn ([chart alpha])Sets the alpha level (transparancy) of the plot's foreground,returns the modified chart object.References:http://www.jfree.org/jfreechart/api/javadoc/http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/JFreeChart.html

- set-background-alpha
- fn ([chart alpha])Sets the alpha level (transparancy) of the plot's background,returns the modified chart object.References:http://www.jfree.org/jfreechart/api/javadoc/http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/JFreeChart.html

- set-title
- fn ([chart title])Sets the main title of the plot, returns the modified chart object.References:http://www.jfree.org/jfreechart/api/javadoc/http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/JFreeChart.html

- set-x-label
- fn ([chart label])Sets the label of the x-axis, returns the modified chart object.References:http://www.jfree.org/jfreechart/api/javadoc/http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/JFreeChart.html

- set-y-label
- fn ([chart label])Sets the label of the y-axis, returns the modified chart object.References:http://www.jfree.org/jfreechart/api/javadoc/http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/JFreeChart.html

- trace-plot
- fn ([x & options])Returns a trace-plot object, use the 'view' function to display it.Examples:(use '(incanter core datasets stats bayes charts))(def ols-data (to-matrix (get-dataset :survey)))(def x (sel ols-data (range 0 2313) (range 1 10)))(def y (sel ols-data (range 0 2313) 10))(def sample-params (sample-model-params 5000 (linear-model y x :intercept false)))(view (trace-plot (:var sample-params)))(view (trace-plot (sel (:coefs sample-params) :cols 0)))

- xy-plot
- macro ([x y & options])Returns a JFreeChart object representing a xy-plot of the given data.Use the 'view' function to display the chart, or the 'save' functionto write it to a file.Options::title (default 'Histogram') main title:x-label (default x expression):y-label (default 'Frequency'):legend (default false) prints legend:series-label (default x expression):group-by (default nil) -- a vector of values used to group the x and y values into series.See also:view, save, add-points, add-linesExamples:(use '(incanter core stats charts));; plot the cosine function(def x (range -1 5 0.01))(def y (cos (mult 2 Math/PI x)))(view (xy-plot x y));; plot gamma pdf with different parameters(def x2 (range 0 20 0.1))(def gamma-plot (xy-plot x2 (pdf-gamma x2 :shape 1 :rate 2):legend true:title "Gamma PDF":y-label "Density"))(view gamma-plot)(add-lines gamma-plot x2 (pdf-gamma x2 :shape 2 :rate 2))(add-lines gamma-plot x2 (pdf-gamma x2 :shape 3 :rate 2))(add-lines gamma-plot x2 (pdf-gamma x2 :shape 5 :rate 1))(add-lines gamma-plot x2 (pdf-gamma x2 :shape 9 :rate 0.5));; use :group-by option(use '(incanter core charts datasets))(def data (to-matrix (get-dataset :chick-weight)))(let [[weight time chick] (trans data)](view (xy-plot time weight :group-by chick)));; see INCANTER_HOME/examples/probability_plots.clj for more examples of plotsReferences:http://www.jfree.org/jfreechart/api/javadoc/http://www.jfree.org/jfreechart/api/javadoc/org/jfree/chart/JFreeChart.html

are-overlapping? before? beginning-of date date-seq date-time date> def-date-format def-date-parser def-simple-date-format earlier earlier? end-of format-date hours-around hours-between hours-from is-within? joda-date joda-guard joda-proxy joda-str later later? minutes-between minutes-from now parse-date time-between time-zone today units-in-seconds units-to-calendar-units valid-range?

- are-overlapping?
- fn ([[s e] [s1 e1]])

- before?
- fn ([start end])

- beginning-of
- fn ([the-date unit])Return a date at the beginning of the month, year, day, etc. from the-date.

- date
- fn ([& args])Returns a new date object. Takes year, month, and day as args aswell as optionally hours, minutes, and seconds.

- date-seq
- fn ([units from to] [units from])Returns a lazy seq of dates starting with from up until to inincrements of units. If to is omitted, returns an infinite seq.

- date-time
- fn ([d t])

- date>
- fn ([d])

- def-date-format
- macro ([fname [arg] & body])

- def-date-parser
- macro ([fname [arg] & body])

- def-simple-date-format
- macro ([fname form])

- earlier
- fn ([the-date amount units] [the-date units])Returns a date that is earlier than the-date by amount units.Amount is one if not specified.

- earlier?
- fn ([date-a date-b])

- end-of
- fn ([the-date unit])Return a date at the end of the month, year, day, etc. from the-date.

- format-date
- multiTake in a date and a format (either a keyword or a string) andreturn a string with the formatted date.

- hours-around
- fn ([r d])

- hours-between
- fn ([start end])

- hours-from
- fn ([d h])

- is-within?
- fn ([d [s e]])

- joda-date
- fn ([str-d] [y m d h min sec mill zone])

- joda-guard
- fn ([d])

- joda-proxy
- fn ([& args])joda-date object wraped in a proxy of goodness.

- joda-str
- fn ([d])

- later
- fn ([the-date amount units] [the-date units])Returns a date that is later than the-date by amount units.Amount is one if not specified.

- later?
- fn ([date-a date-b])

- minutes-between
- fn ([start end])

- minutes-from
- fn ([d m])

- now
- fn ([])Returns a new date object with the current date and time.

- parse-date
- multiTake in a string with a formatted date and a format (either akeyword or a string) and return a parsed date.

- time-between
- fn ([date-a date-b] [date-a date-b units])How many units between date-a and date-b? Units defaults to seconds.

- time-zone
- fn ([offset])

- today
- fn ([])Returns a new date object with only the current date. The timefields will be set to 0.

- units-in-seconds
- varNumber of seconds in each unit

- units-to-calendar-units
- varConversion of unit keywords to Calendar units

- valid-range?
- fn ([[start end]])

categorical-classifiers category-classifier category-map-classifier classification-workflow classifier classifier-macro classify-one-to-all classify-one-to-each classify-one-to-one collect-vals confusion-matrix confusion-matrix-by-time confusion-matrix-from-counts cross-validation-confusion-matrix equivalence-classes heterogenious-group-by map-of-vectors merge-counts merge-equivalence-classes merge-levels model-from-maps most-likely n-times-k-fold-cross-validation-confusion-matrix numerical-classifiers percent-of-total-predictions-by-time precision prob-map-tuples-by-time probs-only process-prob-map recall recall-by-time vectorize wrapper-classifiers

- categorical-classifiers
- fn ([features])makes a categorical classifier for use with |each.

- category-classifier
- fn ([x])

- category-map-classifier
- fn ([x] [s x])

- classification-workflow
- fn ([transformer classifier count-all])composes a classification workflow from a classifier a counter and a transformer.note that count-all has been abstracted due to the fact taht you may count with reduce or merge-with depending on wheter you ahve vectors or maps.

- classifier
- fn ([fns classify])

- classifier-macro
- macro ([classify classify-one-to-one])

- classify-one-to-all
- fn ([fns data])takes a map of fns and a map of features, apply each classifer fn to the entire feature map.usage:(classify-one-to-each{:a (present-when #(and(> (:a %) 9)(< (:b %) 6)))}{:a 10 :b 5})-> {:a 1}

- classify-one-to-each
- fn ([fns data])takes a map of fns and a map of features, apply each classifer fn to each feature in the data map individually.usage:(classify-one-to-each{:a (present-when (gt 5)) :b (present-when (lt 5))}{:a 10 :b 5})-> {:a {:a 1 :b 0} :b {:a 0 :b 0}}

- classify-one-to-one
- fn ([fns data])takes a map of fns and a map of features, where there is one classifier fn per feature and they share the same key names in the classifier and feature maps. apply each classifer fn to the corresponding feature.usage:(classify-one-to-one{:a (present-when (gt 5)) :b (present-when (lt 5))}{:a 10 :b 5})-> {:a 1 :b 0}

- collect-vals
- fn ([maps])

- confusion-matrix
- fn ([trd tst])

- confusion-matrix-by-time
- fn ([results])

- confusion-matrix-from-counts
- fn ([test & train])produces a confusion matrix from teh joint distributions of test and train data.right now the tests and train data are con-prob-tuples this may change if we store only the joint PMFs

- cross-validation-confusion-matrix
- fn ([& xs])takes a set of n joint PMFs, and holds each joint PMF out in turn as the test set.merges the resulting n cross-validation matrices into a single matrix.

- equivalence-classes
- fn ([class-mappings])takes a map where key is class and value is a set of equivalence classes to the key class. it then inverts the mapping so that you can look up classes that are equivalence classes of a new larger class.usage:(equivalence-classes {0 #{0 1}, 1 #{2, 3, 4}, 2 #{5 6}})-> {0 0, 1 0, 2 1, 3 1, 4 1, 5 2, 6 2}

- heterogenious-group-by
- fn ([f coll])Returns a sorted map of the elements of coll keyed by the result off on each element. The value at each key will be a vector of thecorresponding elements, in the order they appeared in coll.

- map-of-vectors
- fn ([keys])

- merge-counts
- fn ([x])

- merge-equivalence-classes
- fn ([class-mappings x])(defn merge-classes-time-before-dep [model]"take in [[{modelcounts} {totalcounts}] [{} {}]]";;starting with 2 becasue 1 is the first slot, which is time before departure for the metrics(let [model-merger {2 bucket-eq-classes3 bucket-eq-classes6 bucket-eq-classes}count-merger {2 bucket-eq-classes3 bucket-eq-classes}](map (fn [[modelcnts totalcnts]] [(merge-equivalence-classes model-merger modelcnts)(merge-equivalence-classes count-merger totalcnts)]) model)))

- merge-levels
- fn ([class-mappings coll])

- model-from-maps
- fn ([prob-map])creates a model from probability report maps.

- most-likely
- fn ([m])computes the most likely class from a map of classes to class probability.usage:(most-likely {:a 0.6 :b 0.4}) -> :a

- n-times-k-fold-cross-validation-confusion-matrix
- fn ([list-of-lists])

- numerical-classifiers
- fn ([ranges])makes a bucketing classifier out of each range for use with |each.

- percent-of-total-predictions-by-time
- fn ([counts])

- precision
- fn ([m])

- prob-map-tuples-by-time
- fn ([prob-map-tuple])

- probs-only
- fn ([k a b] [a b])compute probability from computed counts.this is division, you have to count up the proper numerator and denominator in your counting step.

- process-prob-map
- fn ([[a-and-b b] report])process probability maps using a provided report function.beware: can't pass keys to reporter our you get double nested final level in map.

- recall
- fn ([m])

- recall-by-time
- fn ([confustion-matrix])

- vectorize
- fn ([maps])

- wrapper-classifiers
- fn ([features])makes a wrapping classifier like categortical but with wrapper fn.

abs acos asin atan atan2 beta bind-columns bind-rows categorical-var choose condition copy cos cumulative-sum dataset dataset? decomp-cholesky decomp-eigenvalue decomp-lu decomp-qr decomp-svd det diag dim div exp factorial gamma group-by half-vectorize identity-matrix incomplete-beta kronecker length log log10 log2 matrix matrix? minus mmult mult ncol nrow plus pow prod quit rank regularized-beta save sel sin solve solve-quadratic sq sqrt sum sum-of-squares symmetric-matrix tan to-dummies to-labels to-levels to-list to-matrix to-vect trace trans vectorize view

- abs
- fn ([A])Returns the absolute value of the elements in the given matrix, sequence or number.Equivalent to R's abs function.

- acos
- fn ([A])Returns the arc cosine of the elements in the given matrix, sequence or number.Equivalent to R's acos function.

- asin
- fn ([A])Returns the arc sine of the elements in the given matrix, sequence or number.Equivalent to R's asin function.

- atan
- fn ([A])Returns the arc tangent of the elements in the given matrix, sequence or number.Equivalent to R's atan function.

- atan2
- fn ([& args])Returns the atan2 of the elements in the given matrices, sequences or numbers.Equivalent to R's atan2 function.

- beta
- fn ([a b])Equivalent to R's beta function.References:http://incanter.org/docs/parallelcolt/api/cern/jet/stat/tdouble/Gamma.html

- bind-columns
- fn ([& args])Returns the matrix resulting from concatenating the given matricesand/or sequences by their columns. Equivalent to R's cbind.Examples:(def A (matrix [[1 2 3][4 5 6][7 8 9]]))(def B (matrix [10 11 12]))(bind-columns A B)(bind-columns [1 2 3 4] [5 6 7 8])

- bind-rows
- fn ([& args])Returns the matrix resulting from concatenating the given matricesand/or sequences by their rows. Equivalent to R's rbind.Examples:(def A (matrix [[1 2 3][4 5 6][7 8 9]]))(def B (matrix [[10 11 12][13 14 15]]))(bind-rows A B)(bind-rows [1 2 3 4] [5 6 7 8])

- categorical-var
- fn ([& args])Returns a categorical variable based on the values in the given collection.Equivalent to R's factor function.Options::data (default nil) factors will be extracted from the given data.:ordered? (default false) indicates that the variable is ordinal.:labels (default (sort (into #{} data))):levels (range (count labels))Examples:(categorical-var :data [:a :a :c :b :a :c :c])(categorical-var :labels [:a :b :c])(categorical-var :labels [:a :b :c] :levels [10 20 30])(categorical-var :levels [1 2 3])

- choose
- fn ([n k])Returns number of k-combinations (each of size k) from a set S withn elements (size n), which is the binomial coefficient (also knownas the 'choose function') [wikipedia]choose = n!/(k!(n - k)!)Equivalent to R's choose function.Examples:(choose 25 6) ; => 2,598,960References:http://incanter.org/docs/parallelcolt/api/cern/jet/math/tdouble/DoubleArithmetic.htmlhttp://en.wikipedia.org/wiki/Combination

- condition
- fn ([mat])Returns the two norm condition number, which is max(S) / min(S), where S is the diagonal matrix of singular values from an SVD decomposition.Examples:(use 'incanter.core)(def foo (matrix (range 9) 3))(condition foo)References:http://en.wikipedia.org/wiki/Condition_numberhttp://incanter.org/docs/parallelcolt/api/cern/colt/matrix/tdouble/algo/decomposition/DoubleSingularValueDecompositionDC.html

- copy
- fn ([mat])Returns a copy of the given matrix.

- cos
- fn ([A])Returns the cosine of the elements in the given matrix, sequence or number.Equivalent to R's cos function.

- cumulative-sum
- fn ([coll])Returns a sequence of cumulative sum for the given collection. For instanceThe first value equals the first value of the argument, the second value isthe sum of the first two arguments, the third is the sum of the first threearguments, etc.Examples:(use 'incanter.core)(cumulative-sum (range 100))

- dataset
- fn ([column-names & data])Returns a map of type ::dataset constructed from the given column-names anddata. The data is a sequence of sequences.

- dataset?
- fn ([obj])Determines if obj is of type ::dataset.

- decomp-cholesky
- fn ([mat])Returns the Cholesky decomposition of the given matrix. Equivalent to R'schol function.Returns:a matrix of the triangular factor (note: the result fromcern.colt.matrix.linalg.CholeskyDecomposition is transposed sothat it matches the result return from R's chol function.Examples:(use '(incanter core stats charts datasets));; load the iris dataset(def iris (to-matrix (get-dataset :iris)));; take the Cholesky decompostion of the correlation matrix of the iris data.(decomp-cholesky (correlation iris))References:http://incanter.org/docs/parallelcolt/api/cern/colt/matrix/tdouble/algo/decomposition/DoubleCholeskyDecomposition.htmlhttp://en.wikipedia.org/wiki/Cholesky_decomposition

- decomp-eigenvalue
- fn ([mat])Returns the Eigenvalue Decomposition of the given matrix. Equivalent to R's eig function.Returns:a map containing::values -- vector of eigenvalues:vectors -- the matrix of eigenvectorsExamples:(use 'incanter.core)(def foo (matrix (range 9) 3))(decomp-eigenvalue foo)References:http://en.wikipedia.org/wiki/Eigenvalue_decompositionhttp://incanter.org/docs/parallelcolt/api/cern/colt/matrix/tdouble/algo/decomposition/DoubleEigenvalueDecomposition.html

- decomp-lu
- fn ([mat])Returns the LU decomposition of the given matrix.Examples:(use 'incanter.core)(def foo (matrix (range 9) 3))(decomp-lu foo)Returns:a map containing::L -- the lower triangular factor:U -- the upper triangular factorReferences:http://en.wikipedia.org/wiki/LU_decompositionhttp://incanter.org/docs/parallelcolt/api/cern/colt/matrix/tdouble/algo/decomposition/DoubleLUDecomposition.html

- decomp-qr
- fn ([mat])Returns the QR decomposition of the given matrix. Equivalent to R's qr function.Examples:(use 'incanter.core)(def foo (matrix (range 9) 3))(decomp-qr foo)Returns:a map containing::Q -- orthogonal factor:R -- the upper triangular factorReferences:http://en.wikipedia.org/wiki/QR_decompositionhttp://incanter.org/docs/parallelcolt/api/cern/colt/matrix/tdouble/algo/decomposition/DoubleQRDecomposition.html

- decomp-svd
- fn ([mat])Returns the Singular Value Decomposition (SVD) of the given matrix. Equivalent toR's svd function.Returns:a map containing::S -- the diagonal matrix of singular values:U -- the left singular vectors U:V -- the right singular vectors VExamples:(use 'incanter.core)(def foo (matrix (range 9) 3))(decomp-foo foo)References:http://en.wikipedia.org/wiki/Singular_value_decompositionhttp://incanter.org/docs/parallelcolt/api/cern/colt/matrix/tdouble/algo/decomposition/DoubleSingularValueDecompositionDC.html

- det
- fn ([mat])Returns the determinant of the given matrix using LU decomposition. Equivalentto R's det function.References:http://en.wikipedia.org/wiki/LU_decompositionhttp://incanter.org/docs/parallelcolt/api/cern/colt/matrix/tdouble/algo/decomposition/DoubleLUDecomposition.html

- diag
- fn ([m])If given a matrix, diag returns a sequence of its diagonal elements.If given a sequence, it returns a matrix with the sequence's elementson its diagonal. Equivalent to R's diag function.Examples:(diag [1 2 3 4])(def A (matrix [[1 2 3][4 5 6][7 8 9]]))(diag A)

- dim
- fn ([mat])Returns a vector with the number of rows and columns of the given matrix.

- div
- fn ([& args])Performs element-by-element division on multiple matrices, sequences,and/or numbers. Equivalent to R's / operator.Examples:(def A (matrix [[1 2 3][4 5 6][7 8 9]]))(div A A A)(div A 2)(div 2 A)(div [1 2 3] [1 2 3])(div [1 2 3] 2)(div 2 [1 2 3])(div [1 2 3]) ; returns [1 1/2 13]

- exp
- fn ([A])Returns the exponential of the elements in the given matrix, sequence or number.Equivalent to R's exp function.

- factorial
- fn ([k])Returns the factorial of k (k must be a positive integer). Equivalent to R'sfactorial function.Examples:(factorial 6)References:http://incanter.org/docs/parallelcolt/api/cern/jet/math/tdouble/DoubleArithmetic.htmlhttp://en.wikipedia.org/wiki/Factorial

- gamma
- fn ([x])Equivalent to R's gamma function.References:http://incanter.org/docs/parallelcolt/api/cern/jet/stat/tdouble/Gamma.html

- group-by
- fn ([mat on-cols & options])Groups the given matrix by the values in the columns indicated by the'on-cols' argument, returning a sequence of matrices. The returnedmatrices are sorted by the value of the group column ONLY when thereis only a single (non-vector) on-col argument.Examples:(use '(incanter core datasets))(def plant-growth (to-matrix (get-dataset :plant-growth)))(group-by plant-growth 1);; only return the first column(group-by plant-growth 1 :cols 0);; don't return the second column(group-by plant-growth 1 :except-cols 1)(def plant-growth-dummies (to-matrix (get-dataset :plant-growth) :dummies true))(group-by plant-growth-dummies [1 2]);; return only the first column(group-by plant-growth-dummies [1 2] :cols 0);; don't return the last two columns(group-by plant-growth-dummies [1 2] :except-cols [1 2]);; plot the plant groups(use 'incanter.charts);; can use destructuring if you know the number of groups,;; groups are sorted only if the group is based on a single column value(let [[ctrl trt1 trt2] (group-by plant-growth 1 :cols 0)](doto (box-plot ctrl)(add-box-plot trt1)(add-box-plot trt2)view))

- half-vectorize
- fn ([mat])Returns the half-vectorization (i.e. vech) of the given matrix.The half-vectorization, vech(A), of a symmetric nxn matrix Ais the n(n+1)/2 x 1 column vector obtained by vectorizing onlythe upper triangular part of A.For instance:(= (half-vectorize (matrix [[a b] [b d]])) (matrix [a b d]))Examples:(def A (matrix [[1 2] [2 4]]))(half-vectorize A)References:http://en.wikipedia.org/wiki/Vectorization_(mathematics)

- identity-matrix
- fn ([n])Returns an n-by-n identity matrix.Examples:(identity-matrix 4)

- incomplete-beta
- fn ([x a b])Returns the non-regularized incomplete beta value.References:http://incanter.org/docs/parallelcolt/api/cern/jet/stat/tdouble/Gamma.html

- kronecker
- fn ([& args])Returns the Kronecker product of the given arguments.Examples:(def x (matrix (range 6) 2))(def y (matrix (range 4) 2))(kronecker 4 x)(kronecker x 4)(kronecker x y)

- length
- fn ([coll])A version of count that works on collections, matrices, and numbers.The length of a number is one, the length of a collection is its count,and the length of a matrix is the number of elements it contains (nrow*ncol).Equivalent to R's length function.

- log
- fn ([A])Returns the natural log of the elements in the given matrix, sequence or number.Equvalent to R's log function.

- log10
- fn ([A])Returns the log base 10 of the elements in the given matrix, sequence or number.Equivalent to R's log10 function.

- log2
- fn ([A])Returns the log base 2 of the elements in the given matrix, sequence or number.Equivalent to R's log2 function.

- matrix
- fn ([data] [data ncol] [init-val rows cols])Returns an instance of an incanter.Matrix, which is an extension ofcern.colt.matrix.tdouble.impl.DenseColDoubleMatrix2D that implements the Clojureinterface clojure.lang.ISeq. Therefore Clojure sequence operations canbe applied to matrices. A matrix consists of a sequence of rows, whereeach row is a one-dimensional row matrix. One-dimensional matrices are,in turn, sequences of numbers. Equivalent to R's matrix function.Examples:(def A (matrix [[1 2 3] [4 5 6] [7 8 9]])) ; produces a 3x3 matrix(def A2 (matrix [1 2 3 4 5 6 7 8 9] 3)) ; produces the same 3x3 matrix(def B (matrix [1 2 3 4 5 6 7 8 9])) ; produces a 9x1 column vector(first A) ; produces a row matrix [1 2 3](rest A) ; produces a sub matrix [[4 5 6] [7 8 9]](first (first A)) ; produces 1.0(rest (first A)) ; produces a row matrix [2 3]; since (plus row1 row2) adds the two rows element-by-element,(reduce plus A) ; produces the sums of the columns,; and since (sum row1) sums the elements of the row,(map sum A) ; produces the sums of the rows,; you can filter the rows using Clojure's filter function(filter #(> (nth % 1) 4) A) ; returns the rows where the second column is greater than 4.References:http://incanter.org/docs/parallelcolt/api/cern/colt/matrix/tdouble/DoubleMatrix2D.html

- matrix?
- fn ([obj])Test if obj is 'derived' incanter.Matrix.

- minus
- fn ([& args])Performs element-by-element subtraction on multiple matrices, sequences,and/or numbers. If only a single argument is provided, returns thenegative of the given matrix, sequence, or number. Equivalent to R's - operator.Examples:(def A (matrix [[1 2 3][4 5 6][7 8 9]]))(minus A)(minus A A A)(minus A 2)(minus 2 A)(minus [1 2 3] [1 2 3])(minus [1 2 3] 2)(minus 2 [1 2 3])(minus [1 2 3])

- mmult
- fn ([& args])Returns the matrix resulting from the matrix multiplication of thethe given arguments. Equivalent to R's %*% operator.Examples:(def A (matrix [[1 2 3][4 5 6][7 8 9]]))(mmult A (trans A))(mmult A (trans A) A)References:http://en.wikipedia.org/wiki/Matrix_multiplicationhttp://incanter.org/docs/parallelcolt/api/cern/colt/matrix/tdouble/DoubleMatrix2D.html

- mult
- fn ([& args])Performs element-by-element multiplication on multiple matrices, sequences,and/or numbers. Equivalent to R's * operator.Examples:(def A (matrix [[1 2 3][4 5 6][7 8 9]]))(mult A A A)(mult A 2)(mult 2 A)(mult [1 2 3] [1 2 3])(mult [1 2 3] 2)(mult 2 [1 2 3])

- ncol
- fn ([mat])Returns the number of columns in the given matrix. Equivalent to R's ncol function.

- nrow
- fn ([mat])Returns the number of rows in the given matrix. Equivalent to R's nrow function.

- plus
- fn ([& args])Performs element-by-element addition on multiple matrices, sequences,and/or numbers. Equivalent to R's + operator.Examples:(def A (matrix [[1 2 3][4 5 6][7 8 9]]))(plus A A A)(plus A 2)(plus 2 A)(plus [1 2 3] [1 2 3])(plus [1 2 3] 2)(plus 2 [1 2 3])

- pow
- fn ([& args])This is an element-by-element exponent function, raising the first argument,by the exponents in the remaining arguments. Equivalent to R's ^ operator.

- prod
- fn ([x])Returns the product of the given sequence.

- quit
- fn ([])Exits the Clojure shell.

- rank
- fn ([mat])Returns the effective numerical matrix rank, which is the number of nonnegligible singular values.Examples:(use 'incanter.core)(def foo (matrix (range 9) 3))(rank foo)References:http://en.wikipedia.org/wiki/Matrix_rankhttp://incanter.org/docs/parallelcolt/api/cern/colt/matrix/tdouble/algo/decomposition/DoubleSingularValueDecompositionDC.html

- regularized-beta
- fn ([x a b])Returns the regularized incomplete beta value. Equivalent to R's pbeta function.References:http://incanter.org/docs/parallelcolt/api/cern/jet/stat/tdouble/Gamma.htmlhttp://en.wikipedia.org/wiki/Regularized_incomplete_beta_functionhttp://mathworld.wolfram.com/RegularizedBetaFunction.html

- save
- multiSave is a multi-function that is used to write matrices, datasets andcharts (in png format) to a file.Arguments:obj -- is a matrix, dataset, or chart objectfilename -- the filename to create.Matrix and dataset options::delim (default \,) column delimiter:header (default nil) an sequence of strings to be used as header line,for matrices the default value is nil, for datasets, the default isthe dataset's column-names array.:append (default false) determines whether this given file should beappended to. If true, a header will not be written to the file again.Chart options::width (default 500):height (default 400)Matrix Examples:(use '(incanter core io))(def A (matrix (range 12) 3)) ; creates a 3x4 matrix(save A "A.dat") ; writes A to the file A.dat, with no header and comma delimited(save A "A.dat" :delim \tab) ; writes A to the file A.dat, with no header and tab delimited;; writes A to the file A.dat, with a header and tab delimited(save A "A.dat" :delim \, :header ["col1" "col2" "col3"])Dataset Example:(use '(incanter core io datasets));; read the iris sample dataset, and save it to a file.(def iris (get-dataset :iris))(save iris "iris.dat")Chart Example:(use '(incanter core io stats charts))(save (histogram (sample-normal 1000)) "hist.png");; chart example using java.io.OutputStream instead of filename(use '(incanter core stats charts))(import 'java.io.FileOutputStream)(def fos (FileOutputStream. "/tmp/hist.png"))(def hist (histogram (sample-normal 1000)))(save hist fos)(.close fos)(view "file:///tmp/hist.png")

- sel
- multiReturns an element or subset of the given matrix, or dataset.Argument:a matrix object or dataset.Options::rows (default true)returns all rows by default, can pass a row index or sequence of row indices:cols (default true)returns all columns by default, can pass a column index or sequence of column indices:except-rows (default nil) can pass a row index or sequence of row indices to exclude:except-cols (default nil) can pass a column index or sequence of column indices to exclude:filter (default nil)a function can be provided to filter the rows of the matrixExamples:(use 'incanter.datasets)(def iris (to-matrix (get-dataset :iris)))(sel iris 0 0) ; first element(sel iris :rows 0 :cols 0) ; also first element(sel iris :cols 0) ; first column of all rows(sel iris :cols [0 2]) ; first and third column of all rows(sel iris :rows (range 10) :cols (range 2)) ; first two columns of the first 10 rows(sel iris :rows (range 10)) ; all columns of the first 10 rows;; exclude rows or columns(sel iris :except-rows (range 10)) ; all columns of all but the first 10 rows(sel iris :except-cols 1) ; all columns except the second;; return only the first 10 even rows(sel iris :rows (range 10) :filter #(even? (int (nth % 0))));; select rows where distance (third column) is greater than 50(sel iris :filter #(> (nth % 2) 4));; examples with datasets(use 'incanter.datasets)(def us-arrests (get-dataset :us-arrests))(sel us-arrests :cols "State")(sel us-arrests :cols ["State" "Murder"])

- sin
- fn ([A])Returns the sine of the elements in the given matrix, sequence or number.Equivalent to R's sin function.

- solve
- fn ([A & B])Returns a matrix solution if A is square, least squares solution otherwise.Equivalent to R's solve function.Examples:(solve (matrix [[2 0 0] [0 2 0] [0 0 2]]))References:http://en.wikipedia.org/wiki/Matrix_inverse

- solve-quadratic
- fn ([a b c])Returns a vector with the solution to x from the quadraticequation, a*x^2 + b*x + c.Arguments:a, b, c: coefficients of a qaudratic equation.Examples:;; -2*x^2 + 7*x + 15(quadratic-formula -2 7 15);; x^2 + -2*x + 1(quadratic-formula 1 -2 1)References:http://en.wikipedia.org/wiki/Quadratic_formula

- sq
- fn ([A])Returns the square of the elements in the given matrix, sequence or number.Equivalent to R's sq function.

- sqrt
- fn ([A])Returns the square-root of the elements in the given matrix, sequence or number.Equivalent to R's sqrt function.

- sum
- fn ([x])Returns the sum of the given sequence.

- sum-of-squares
- fn ([x])Returns the sum-of-squares of the given sequence.

- symmetric-matrix
- fn ([data & options])Returns a symmetric matrix from the given data, which represents the lower triangular elementsordered by row. This is not the inverse of half-vectorize which returns a vector of the upper-triangularvalues, unless the :lower option is set to false.Options::lower (default true) -- lower-triangular. Set :lower to false to reverse the half-vectorize function.Examples:(use 'incanter.core)(symmetric-matrix [12 34 5 67 8 9 10])(half-vectorize(symmetric-matrix [12 34 5 67 8 9 10] :lower false))

- tan
- fn ([A])Returns the tangent of the elements in the given matrix, sequence or number.Equivalent to R's tan function.

- to-dummies
- fn ([coll])

- to-labels
- fn ([coll cat-var])

- to-levels
- fn ([coll & options])

- to-list
- fn ([mat])Returns a list-of-lists if the given matrix is two-dimensional,and a flat list if the matrix is one-dimensional.

- to-matrix
- fn ([dataset & options])Converts a dataset into a matrix. Equivalent to R's as.matrix functionfor datasets.Options::dummies (default false) -- if true converts non-numeric variables into setsof binary dummy variables, otherwise convertsthem into numeric codes.

- to-vect
- fn ([mat])Returns a vector-of-vectors if the given matrix is two-dimensional,and a flat vector if the matrix is one-dimensional. This is a bitslower than the to-list function.

- trace
- fn ([mat])Returns the trace of the given matrix.References:http://en.wikipedia.org/wiki/Matrix_tracehttp://incanter.org/docs/parallelcolt/api/cern/colt/matrix/tdouble/algo/DoubleAlgebra.html

- trans
- fn ([mat])Returns the transpose of the given matrix. Equivalent to R's t functionExamples:(def A (matrix [[1 2 3][4 5 6][7 8 9]]))(trans A)

- vectorize
- fn ([mat])Returns the vectorization (i.e. vec) of the given matrix.The vectorization of an m-by-n matrix A, denoted by vec(A),is the m*n-by-1 column vector obtain by stacking the columnsof the matrix A on top of one another.For instance:(= (vectorize (matrix [[a b] [c d]])) (matrix [a c b d]))Examples:(def A (matrix [[1 2] [3 4]]))(vectorize A)References:http://en.wikipedia.org/wiki/Vectorization_(mathematics)

- view
- multiThis is a general 'view' function. When given an Incanter matrix/datasetor a Clojure numeric collection, it will display it in a Java SwingJTable. When given an Incanter chart object, it will display it in a newwindow. When given a URL string, it will open the location with theplatform's default web browser.Examples:(use '(incanter core stats datasets charts));; view matrices(def rand-mat (matrix (sample-normal 100) 4))(view rand-mat);; view numeric collections(view [1 2 3 4 5])(view (sample-normal 100));; view Incanter datasets(view (get-dataset :iris));; convert dataset to matrix, changing Species names to numeric codes(view (to-matrix (get-dataset :iris)));; convert dataset to matrix, changing Species names to dummy variables(view (to-matrix (get-dataset :iris) :dummies true));; view a chart(view (histogram (sample-normal 1000)));; view a URL(view "http://incanter.org");; view a PNG file(save (histogram (sample-normal 1000)) "/tmp/norm_hist.png")(view "file:///tmp/norm_hist.png")

- **datasets**
- var

- get-dataset
- fn ([dataset-key & options])Returns the sample dataset associated with the given key. Most datasetsare from R's sample data sets, as are the descriptions below.Options::incanter-home -- if the incanter.home property is not set when the JVM isstarted, use the :incanter-home options to provide theparent directory of the sample data directory.Datasets::iris -- the Fisher's or Anderson's Iris data set gives themeasurements in centimeters of the variables sepallength and width and petal length and width,respectively, for 50 flowers from each of 3 speciesof iris.:cars -- The data give the speed of cars and the distances takento stop. Note that the data were recorded in the 1920s.:survey -- survey data used in Scott Lynch's 'Introduction to Applied Bayesian Statisticsand Estimation for Social Scientists':us-arrests -- This data set contains statistics, in arrests per 100,000residents for assault, murder, and rape in each of the 50 USstates in 1973. Also given is the percent of the population livingin urban areas.:flow-meter -- flow meter data used in Bland Altman Lancet paper.:co2 -- has 84 rows and 5 columns of data from an experiment on the cold toleranceof the grass species _Echinochloa crus-galli_.:chick-weight -- has 578 rows and 4 columns from an experiment on the effect of dieton early growth of chicks.:plant-growth -- Results from an experiment to compare yields (as measured by driedweight of plants) obtained under a control and two differenttreatment conditions.:pontius -- These data are from a NIST study involving calibration of load cells.The response variable (y) is the deflection and the predictor variable(x) is load.See http://www.itl.nist.gov/div898/strd/lls/data/Pontius.shtml:filip -- NIST data set for linear regression certification,see http://www.itl.nist.gov/div898/strd/lls/data/Filip.shtml:longely -- This classic dataset of labor statistics was one of the first used totest the accuracy of least squares computations. The response variable(y) is the Total Derived Employment and the predictor variables are GNPImplicit Price Deflator with Year 1954 = 100 (x1), Gross National Product(x2), Unemployment (x3), Size of Armed Forces (x4), Non-InstitutionalPopulation Age 14 & Over (x5), and Year (x6).See http://www.itl.nist.gov/div898/strd/lls/data/Longley.shtml:Chwirut -- These data are the result of a NIST study involving ultrasonic calibration.The response variable is ultrasonic response, and the predictor variable ismetal distance.See http://www.itl.nist.gov/div898/strd/nls/data/LINKS/DATA/Chwirut1.dat:thurstone -- test data for non-linear least squares.:austres -- Quarterly Time Series of the Number of Australian Residents:hair-eye-color -- Hair and eye color of sample of students:airline-passengers -- Monthly Airline Passenger Numbers 1949-1960:math-prog -- Pass/fail results for a high school mathematics assessment testand a freshmen college programming course.:iran-election -- Vote counts for 30 provinces from the 2009 Iranian election.

- entropy
- fn ([counts])takes a map of class label to counts

- gain
- fn ([data])computes information gain from count matrix of feature class labels to predicted class labels.example: (gain {:weak {:positive 6 :negative 2}:strong {:positive 3 :negative 3}})

- gini-impurity
- fn ([counts])Gini impurity is measure of how often a randoincanter. chosen element from the set would be incorrectly labelled if it were randoincanter. labelled according to the distribution of labels in the subset. Gini impurity can be computed by summing the probability of each item being chosen times the probability of a mistake in categorizing that item. It reaches its minimum (zero) when all cases in the node fall into a single target category.

- kl-divergence
- fn ([p-counts q-counts])http://en.wikipedia.org/wiki/Kullback%E2%80%93Leibler_divergenceIn probability theory and information theory, the Kullback–Leibler divergence (also information divergence, information gain, or relative entropy) is a non-symmetric measure of the difference between two probability distributions P and Q. KL measures the expected number of extra bits required to code samples from P when using a code based on Q, rather than using a code based on P. Typically P represents the true distribution of data, observations, or a precise calculated theoretical distribution. The measure Q typically represents a theory, model, description, or approximation of P.takes a map of class label to counts.note the (> p 0) predicate defines (* 0 (log2 0)) as 0 rather than NaNassumes you pass in distributions as nested maps and flattens them before applying the algorithm.

- mutual-information
- fn ([joint individuals])mutual information is the Kullback-Leibler divergence between the product of the marginal distributions of two random variables, p(x)p(y), and the the random variables' joint distribution, p(x,y).see: http://en.wikipedia.org/wiki/Mutual_information

- total-correlation
- fn ([joint individuals])total correlation is a multivariate generalization of mutual information. it is the Kullback-Leibler divergence between the joint distribution of a set and its maximum entropy product approximation.see: http://en.wikipedia.org/wiki/Total_correlation

clj-to-json-file columns csv-line csv-table into-file json-from-classpath load-resource package-model query random-row read-dataset read-from-classpath read-json-file read-json-lines read-map report-model sql-from sql-limit sql-order-by sql-query sql-select sql-unique sql-where string-date-read-map unpackage-model with-mysql-results

- clj-to-json-file
- fn ([c f])

- columns
- fn ([& x])

- csv-line
- fn ([v])

- csv-table
- fn ([m])

- into-file
- fn ([filename stuff])

- json-from-classpath
- fn ([f])

- load-resource
- fn ([f])

- package-model
- fn ([file prob-map-tuple])

- query
- fn ([table sample & columns])

- random-row
- var

- read-dataset
- fn ([filename & options])Returns a dataset read from a file or a URL.Options::delim (default \,), other options (\tab \space \| etc):quote (default \") character used for quoting strings:skip (default 0) the number of lines to skip at the top of the file.:header (default false) indicates the file has a header line

- read-from-classpath
- fn ([f])

- read-json-file
- fn ([f])

- read-json-lines
- fn ([f])

- read-map
- fn ([& keys])

- report-model
- fn

- sql-from
- fn

- sql-limit
- fn

- sql-order-by
- fn ([c])

- sql-query
- fn ([d q])

- sql-select
- fn ([& x])

- sql-unique
- fn

- sql-where
- fn ([pred])

- string-date-read-map
- fn ([& keys])

- unpackage-model
- fn ([file])

- with-mysql-results
- fn ([dbinfo query f])takes dbinfo, query and a fn and applys the fn to query results.example dbinfo:{:host "localhost":port 3306:name "testimport":classname "com.mysql.jdbc.Driver":subprotocol "mysql":user "root":password "12345"}

- derivative
- fn ([f & options])Returns a function that approximates the derivative of the given function.Options::dx (default 0.0001)Examples:(use '(incanter core optimize charts stats))(defn cube [x] (* x x x))(def cube-deriv (derivative cube))(cube-deriv 2) ; value: 12.000600010022566(cube-deriv 3) ; value: 27.00090001006572(cube-deriv 4) ; value: 48.00120000993502(def x (range -3 3 0.1))(def plot (xy-plot x (map cube x)))(view plot)(add-lines plot x (map cube-deriv x));; get the second derivative function(def cube-deriv2 (derivative cube-deriv))(add-lines plot x (map cube-deriv2 x));; plot the normal pdf and its derivatives(def plot (xy-plot x (pdf-normal x)))(view plot)(def pdf-deriv (derivative pdf-normal))(add-lines plot x (pdf-deriv x));; plot the second derivative function(def pdf-deriv2 (derivative pdf-deriv))(add-lines plot x (pdf-deriv2 x))

- gradient
- fn ([f start & options])Returns a function that calculates a 5-point approximation tothe gradient of the given function. The vector of start values areused to determine the number of parameters required by the function, andto scale the step-size. The generated function accepts a vector ofparameter values and a vector of x data points and returns a matrix,where each row is the gradient evaluated at the corresponding x value.Examples:(use '(incanter core optimize datasets charts))(defn f [theta x](+ (nth theta 0)(div (* x (- (nth theta 1) (nth theta 0)))(+ (nth theta 2) x))))(def start [20 200 100])(def data (to-matrix (get-dataset :thurstone)))(def x (sel data :cols 1))(def y (sel data :cols 0));; view the data(view (scatter-plot x y))(def grad (gradient f start))(time (doall (grad start x)))

- hessian
- fn ([f start & options])Returns a function that calculates an approximation to the Hessian matrixof the given function. The vector of start values are used to determinethe number of parameters required by the function, and to scale thestep-size. The generated function accepts a vector ofparameter values and a vector of x data points and returns a matrix,where each row with p*(p+1)/2 columns, one for each unique entry inthe Hessian evaluated at the corresponding x value.Examples:(use '(incanter core optimize datasets charts))(defn f [theta x](+ (nth theta 0)(div (* x (- (nth theta 1) (nth theta 0)))(+ (nth theta 2) x))))(def start [20 200 100])(def data (to-matrix (get-dataset :thurstone)))(def x (sel data :cols 1))(def y (sel data :cols 0));; view the data(view (scatter-plot x y))(time (def hess (hessian f start)))(time (doall (hess start x)))

- integrate
- fn ([f a b])Integrate a function f from a to bExamples:(defn f1 [x] 1)(defn f2 [x] (Math/pow x 2))(defn f3 [x] (* x (Math/exp (Math/pow x 2))))(integrate f1 0 5)(integrate f2 0 1)(integrate f3 0 1);; normal distribution(def std 1)(def mu 0)(defn normal [x](/ 1(* (* std (Math/sqrt (* 2 Math/PI)))(Math/exp (/ (Math/pow (- (- x mu)) 2)(* 2 (Math/pow std 2)))))))(integrate normal 1.96 10)Reference:http://jng.imagine27.com/articles/2009-04-09-161839_integral_calculus_in_lambda_calculus_lisp.htmlhttp://iam.elbenshira.com/archives/151_integral-calculus-in-haskell/

- non-linear-model
- fn ([f y x start & options])Determine the nonlinear least-squares estimates of theparameters of a nonlinear model.Based on R's nls (non-linear least squares) function.Arguments:f -- model function, takes two argumetns the first a list of parametersthat are to be estimated, and an x value.y -- sequence of dependent datax -- sequence of independent datastart -- start values for the parameters to be estimatedOptions::method (default :gauss-newton) other option :newton-raphson:tol (default 1E-5):max-iter (default 200)Returns: a hash-map containing the following fields::method -- the method used:coefs -- the parameter estimates:gradient -- the estimated gradient:hessian -- the estimated hessian, if available:iterations -- the number of iterations performed:fitted -- the fitted values of y (i.e. y-hat):rss -- the residual sum-of-squares:x -- the independent data values:y -- the dependent data valuesExamples:;; example 1(use '(incanter core optimize datasets charts));; define the Michaelis-Menton model function;; y = a + (b - a)*x/(c + x)(defn f [theta x](let [[a b c] theta](plus a (div (mult x (minus b a)) (plus c x)))))(def start [20 200 100])(def data (to-matrix (get-dataset :thurstone)))(def x (sel data :cols 1))(def y (sel data :cols 0));; view the data(def plot (scatter-plot x y))(view plot)(def nlm (non-linear-model f y x start))(add-lines plot x (:fitted nlm));; example 2(use '(incanter core optimize datasets charts));; Chwirut data set from NIST;; http://www.itl.nist.gov/div898/strd/nls/data/LINKS/DATA/Chwirut1.dat(def data (to-matrix (get-dataset :chwirut)))(def x (sel data :cols 1))(def y (sel data :cols 0));; define model function: y = exp(-b1*x)/(b2+b3*x) + e(defn f [theta x](let [[b1 b2 b3] theta](div (exp (mult (minus b1) x)) (plus b2 (mult b3 x)))))(def plot (scatter-plot x y :legend true))(view plot);; the newton-raphson algorithm fails to converge to the correct solution;; using first set of start values from NIST, but the default gauss-newton;; algorith converges to the correct solution.(def start1 [0.1 0.01 0.02])(add-lines plot x (f start1 x))(def nlm1 (non-linear-model f y x start1))(add-lines plot x (:fitted nlm1));; both algorithms converges with second set of start values from NIST(def start2 [0.15 0.008 0.010])(add-lines plot x (f start2 x))(def nlm2 (non-linear-model f y x start2))(add-lines plot x (:fitted nlm2))

+cond-prob-tuples P always-false any binary bucket bucket-negative? comb-merge cond-prob-tuple constrain count-missing eq gt label-cond-prob-dependent lt map-counter marginals missing? n-sided-die ne pred present-when range-classifier rolling-windows summate summate-level vector-counter | |each

- +cond-prob-tuples
- fn ([[x y] [p q]] [x])adds two conditional probability tuples. [[{}{}][{}{}]] -> [{}{}]passes through a single conditional probability tuple. [[{}{}] -> [{}{}]

- P
- fn ([a given b & bs] [a given b])

- always-false
- fn ([x])

- any
- fn ([x])

- binary
- fn ([pred])a function for binary classification that takes a booleavn value and returns 1 for true and 0 for false.

- bucket
- fn ([f r] [f t r] [f t r p])

- bucket-negative?
- fn ([x])

- comb-merge
- fn ([f x y])combinatorial merge takes two maps and a fn and and merges all combinations fo keys between the two maps using the fn.

- cond-prob-tuple
- fn ([a b])build [a&b b] count tuples for calculating conditional probabilities p(a | b)

- constrain
- fn ([k f v])

- count-missing
- fn ([exp act])

- eq
- fn ([y])

- gt
- fn ([y])

- label-cond-prob-dependent
- fn ([a & bs])

- lt
- fn ([y])

- map-counter
- fn ([f])wraps a counting function for maps in apply and deep-merge-with, curreid fn expects a seq of maps to count.

- marginals
- fn ([j])computes the marginal PMFs from the joint PMF.of the form: {a {b n}} where n is the nubmer of co-occurances of a and b.for summation note that a variable, suppose it is x, is represented as a level of depth in the nested maps, so summation for margianl of x occurs on all branches stemming from maps at the level corresponding with x.

- missing?
- fn ([x])

- n-sided-die
- fn ([n])

- ne
- fn ([y])

- pred
- fn ([f arg])

- present-when
- fn ([f] [f & keys])

- range-classifier
- fn ([range item])classify one item based on what interval in a range the item falls into.

- rolling-windows
- fn ([len])

- summate
- fn ([m])summate all counts in a deeply nested map of counts.

- summate-level
- fn ([j])

- vector-counter
- fn ([f])wraps a counting function for vectors in apply and deep-merge-with, curreid fn expects a seq of vectors to count.

- |
- fn ([a b])this is the core of the conditional probability based classification model. this model takes a & bs in the form a given bs. a and bs are all functions, and the conditional probability classification model composes a new classifier function that ultimately returns the cond-prob-tuple: [{a's counts}{b's counts}].

- |each
- fn ([a bs])conditional probability where the bs are taken to be a map of feature->classifier-function paris, where we want to compute the conditional probability between a and each b independently.

bigrams bootstrap cdf-beta cdf-binomial cdf-chisq cdf-empirical cdf-exp cdf-f cdf-gamma cdf-neg-binomial cdf-normal cdf-poisson cdf-t cdf-uniform chebyshev-distance chisq-test concordant? correlation correlation-linearity-test correlation-ratio cosine-similarity covariance cumulative-mean damerau-levenshtein-distance detabulate dice-coefficient dice-coefficient-str discordant-pairs discordant? euclidean-distance gamma-coefficient hamming-distance indicator jaccard-distance jaccard-index kendalls-tau kendalls-tau-distance kendalls-w kurtosis lee-distance levenshtein-distance linear-model mahalanobis-distance manhattan-distance mean median minkowski-distance n-grams normalized-kendall-tau-distance odds-ratio pairings pairs pdf-beta pdf-binomial pdf-chisq pdf-exp pdf-f pdf-gamma pdf-neg-binomial pdf-normal pdf-poisson pdf-t pdf-uniform permute predict principal-components product-marginal-test quantile quantile-normal quantile-t rank-index sample sample-beta sample-binomial sample-chisq sample-dirichlet sample-exp sample-gamma sample-inv-wishart sample-mvn sample-neg-binomial sample-normal sample-permutations sample-poisson sample-t sample-uniform sample-wishart sd simple-regression skewness smooth-discrete-probs sorensen-index spearmans-rho square-devs-from-mean sum-of-square-devs-from-mean sum-variance-test sweep t-test tabulate tanimoto-coefficient variance within

- bigrams
- fn ([s])

- bootstrap
- fn ([data statistic & options])Returns a bootstrap sample of the given statistic on the given data.Arguments:data -- vector of data to resample fromstatistic -- a function that returns a value given a vector of dataOptions::size -- the number of bootstrap samples to return:smooth -- (default false) smoothing option:smooth-sd -- (default (/ (sqrt (count data)))) determines the standarddeviation of the noise to use for smoothing:replacement -- (default true) determines if sampling of the datashould be done with replacementReferences:1. Clifford E. Lunneborg, Data Analysis by Resampling Concepts and Applications, 2000, pages 105-1172. http://en.wikipedia.org/wiki/Bootstrapping_(statistics)Examples:;; example from Data Analysis by Resampling Concepts and Applications;; Clifford E. Lunneborg (pages 119-122)(use '(incanter core stats charts));; weights (in grams) of 50 randoincanter. sampled bags of preztels(def weights [464 447 446 454 450 457 450 442433 452 449 454 450 438 448 449457 451 456 452 450 463 464 453452 447 439 449 468 443 433 460452 447 447 446 450 459 466 433445 453 454 446 464 450 456 456447 469]);; calculate the sample median, 450(median weights);; generate bootstrap sample(def t* (bootstrap weights median :size 2000));; view histogram of bootstrap histogram(view (histogram t*));; calculate the mean of the bootstrap median ~ 450.644(mean t*);; calculate the standard error ~ 1.083(def se (sd t*));; 90% standard normal CI ~ (448.219 451.781)(plus (median weights) (mult (quantile-normal [0.05 0.95]) se));; 90% symmetric percentile CI ~ (449.0 452.5)(quantile t* :probs [0.05 0.95]);; 90% non-symmetric percentile CI ~ (447.5 451.0)(minus (* 2 (median weights)) (quantile t* :probs [0.95 0.05]));; calculate bias(- (mean t*) (median weights)) ;; ~ 0.644;; example with smoothing;; Newcomb's speed of light data(use '(incanter core stats charts));; A numeric vector giving the Third Series of measurements of the;; passage time of light recorded by Newcomb in 1882. The given;; values divided by 1000 plus 24 give the time in millionths of a;; second for light to traverse a known distance. The 'true' value is;; now considered to be 33.02.(def speed-of-light [28 -44 29 30 24 28 37 32 36 27 26 28 2926 27 22 23 20 25 25 36 23 31 32 24 2733 16 24 29 36 21 28 26 27 27 32 25 2824 40 21 31 32 28 26 30 27 26 24 32 2934 -2 25 19 36 29 30 22 28 33 39 25 16 23]);; view histogram of data to see outlier observations(view (histogram speed-of-light :nbins 30))(def samp (bootstrap speed-of-light median :size 10000))(view (histogram samp :density true :nbins 30))(mean samp)(quantile samp :probs [0.025 0.975])(def smooth-samp (bootstrap speed-of-light median :size 10000 :smooth true))(view (histogram smooth-samp :density true :nbins 30))(mean smooth-samp)(quantile smooth-samp :probs [0.025 0.975])

- cdf-beta
- fn ([x & options])Returns the Beta cdf of the given value of x. It will return a sequenceof values, if x is a sequence. This is equivalent to R's pbeta function.Options::alpha (default 1):beta (default 1):lower-tail (default true)See also:pdf-beta and sample-betaReferences:http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/Beta.htmlhttp://en.wikipedia.org/wiki/Beta_distributionhttp://en.wikipedia.org/wiki/Cumulative_distribution_functionExample:(cdf-beta 0.5 :alpha 1 :beta 2)(cdf-beta 0.5 :alpha 1 :beta 2 :lower-tail false)

- cdf-binomial
- fn ([x & options])Returns the Bionomial cdf of the given value of x. It will return a sequenceof values, if x is a sequence. Same as R's pbinomOptions::size (default 1):prob (default 1/2):lower-tail (default true)See also:pdf-binomial and sample-binomialReferences:http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/Binomial.htmlhttp://en.wikipedia.org/wiki/Binomial_distributionhttp://en.wikipedia.org/wiki/Cumulative_distribution_functionExample:(cdf-binomial 10 :prob 1/4 :size 20)

- cdf-chisq
- fn ([x & options])Returns the Chi Square cdf of the given value of x. It will return a sequenceof values, if x is a sequence. Same as R's pchisq function.Options::df (default 1):lower-tail (default true)See also:pdf-chisq and sample-chisqReferences:http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/ChiSquare.htmlhttp://en.wikipedia.org/wiki/Chi_square_distributionhttp://en.wikipedia.org/wiki/Cumulative_distribution_functionExample:(cdf-chisq 5.0 :df 2)(cdf-chisq 5.0 :df 2 :lower-tail false)

- cdf-empirical
- fn ([x])Returns a step-function representing the empirical cdf of the given data.Equivalent to R's ecdf function.The following description is from the ecdf help in R: The e.c.d.f.(empirical cumulative distribution function) Fn is a step functionwith jumps i/n at observation values, where i is the number of tiedobservations at that value. Missing values are ignored.For observations 'x'= (x1,x2, ... xn), Fn is the fraction ofobservations less or equal to t, i.e.,Fn(t) = #{x_i <= t} / n = 1/n sum(i=1,n) Indicator(xi <= t).Examples:(use '(incanter core stats charts))(def exam1 [192 160 183 136 162 165 181 188 150 163 192 164 184189 183 181 188 191 190 184 171 177 125 192 149 188154 151 159 141 171 153 169 168 168 157 160 190 166 150]);; the ecdf function returns an empirical cdf function for the given data(def ecdf (cdf-empirical exam1));; plot the data's empircal cdf(view (scatter-plot exam1 (map ecdf exam1)))

- cdf-exp
- fn ([x & options])Returns the Exponential cdf of the given value of x. It will return a sequenceof values, if x is a sequence. Same as R's pexpOptions::rate (default 1)See also:pdf-exp and sample-expReferences:http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/Exponential.htmlhttp://en.wikipedia.org/wiki/Exponential_distributionhttp://en.wikipedia.org/wiki/Cumulative_distribution_functionExample:(cdf-exp 2.0 :rate 1/2)

- cdf-f
- fn ([x & options])Returns the F-distribution cdf of the given value, x. It will return a sequenceof values, if x is a sequence. This is equivalent to R's pf function.Options::df1 (default 1):df2 (default 1)See also:pdf-f and quantile-fReferences:http://en.wikipedia.org/wiki/F_distributionhttp://mathworld.wolfram.com/F-Distribution.htmlhttp://en.wikipedia.org/wiki/Cumulative_distribution_functionExample:(cdf-f 1.0 :df1 5 :df2 2)

- cdf-gamma
- fn ([x & options])Returns the Gamma cdf for the given value of x. It will return a sequenceof values, if x is a sequence. This is equivalent to R's pgamma function.Options::shape (default 1):rate (default 1):lower-tail (default true)See also:pdf-gamma and sample-gammaReferences:http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/Gamma.htmlhttp://en.wikipedia.org/wiki/Gamma_distributionhttp://en.wikipedia.org/wiki/Cumulative_distribution_functionExample:(cdf-gamma 10 :shape 1 :rate 2)(cdf-gamma 3 :shape 1 :lower-tail false)

- cdf-neg-binomial
- fn ([x & options])Returns the Negative Binomial cdf of the given value of x. It will return a sequenceof values, if x is a sequence. Same as R's dnbinomOptions::size (default 10):prob (default 1/2)See also:cdf-neg-binomial and sample-neg-binomialReferences:http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/NegativeBinomial.htmlhttp://en.wikipedia.org/wiki/Negative_binomial_distributionhttp://en.wikipedia.org/wiki/Cumulative_distribution_functionExample:(cdf-neg-binomial 10 :prob 1/2 :size 20)

- cdf-normal
- fn ([x & options])Returns the Normal cdf of the given value, x. It will return a sequenceof values, if x is a sequence. This is equivalent to R's pnorm function.Options::mean (default 0):sd (default 1)See also:pdf-normal, quantile-normal, sample-normalReferences:http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/Normal.htmlhttp://en.wikipedia.org/wiki/Normal_distributionhttp://en.wikipedia.org/wiki/Cumulative_distribution_functionExample:(cdf-normal 1.96 :mean -2 :sd (sqrt 0.5))

- cdf-poisson
- fn ([x & options])Returns the Poisson cdf of the given value of x. It will return a sequenceof values, if x is a sequence. Same as R's ppoisOptions::lambda (default 1):lower-tail (default true)See also:cdf-poisson and sample-poissonReferences:http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/Poisson.htmlhttp://en.wikipedia.org/wiki/Poisson_distributionhttp://en.wikipedia.org/wiki/Cumulative_distribution_functionExample:(cdf-poisson 5 :lambda 10)

- cdf-t
- fn ([x & options])Returns the Student's t cdf for the given value of x. It will return a sequenceof values, if x is a sequence. Same as R's pt function.Options::df (default 1)See also:pdf-t, quantile-t, and sample-tReferences:http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/StudentT.htmlhttp://en.wikipedia.org/wiki/Student-t_distributionhttp://en.wikipedia.org/wiki/Cumulative_distribution_functionExample:(cdf-t 1.2 :df 10)

- cdf-uniform
- fn ([x & options])Returns the Uniform cdf of the given value of x. It will return a sequenceof values, if x is a sequence. This is equivalent to R's punif function.Options::min (default 0):max (default 1)See also:pdf-uniform and sample-uniformReferences:http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/DoubleUniform.htmlhttp://en.wikipedia.org/wiki/Uniform_distributionhttp://en.wikipedia.org/wiki/Cumulative_distribution_functionExample:(cdf-uniform 5)(cdf-uniform 5 :min 1 :max 10)

- chebyshev-distance
- fn ([a b])In the limiting case of Lp reaching infinity we obtain the Chebyshev distance.

- chisq-test
- fn ([& options])Performs chi-squared contingency table tests and goodness-of-fit tests.If the optional argument :y is not provided then a goodness-of-fit testis performed. In this case, the hypothesis tested is whether thepopulation probabilities equal those in :probs, or are all equal if:probs is not given.If :y is provided, it must be a sequence of integers that is thesame length as x. A contingency table is computed from x and :y.Then, Pearson's chi-squared test of the null hypothesis that the jointdistribution of the cell counts in a 2-dimensional contingencytable is the product of the row and column marginals is performed.By default the Yates' continuity correction for 2x2 contingencytables is performed, this can be disabled by setting the :correctoption to false.Options::x -- a sequence of numbers.:y -- a sequence of numbers:table -- a contigency table. If one dimensional, the test is a goodness-of-fit:probs (when (nil? y) -- (repeat n-levels (/ n-levels))):freq (default nil) -- if given, these are rescaled to probabilities:correct (default true) -- use Yates' correction for continuity for 2x2 contingency tablesReturns::X-sq -- the Pearson X-squared test statistics:p-value -- the p-value for the test statistic:df -- the degress of freedomExamples:(use '(incanter core stats))(chisq-test :x [1 2 3 2 3 2 4 3 5]) ;; X-sq 2.6667;; create a one-dimensional table of this data(def table (matrix [1 3 3 1 1]))(chisq-test :table table) ;; X-sq 2.6667(chisq-test :table (trans table)) ;; throws exception(chisq-test :x [1 0 0 0 1 1 1 0 0 1 0 0 1 1 1 1]) ;; 0.25(use '(incanter core stats datasets))(def math-prog (to-matrix (get-dataset :math-prog)))(def x (sel math-prog :cols 1))(def y (sel math-prog :cols 2))(chisq-test :x x :y y) ;; X-sq = 1.24145, df=1, p-value = 0.26519(chisq-test :x x :y y :correct false) ;; X-sq = 2.01094, df=1, p-value = 0.15617(def table (matrix [[31 12] [9 8]]))(chisq-test :table table) ;; X-sq = 1.24145, df=1, p-value = 0.26519(chisq-test :table table :correct false) ;; X-sq = 2.01094, df=1, p-value = 0.15617;; use the detabulate function to create data rows corresponding to the table(def detab (detabulate :table table))(chisq-test :x (sel detab :cols 0) :y (sel detab :cols 1));; look at the hair-eye-color data;; turn the count data for males into a contigency table(def male (matrix (sel (get-dataset :hair-eye-color) :cols 3 :rows (range 16)) 4))(chisq-test :table male) ;; X-sq = 41.280, df = 9, p-value = 4.44E-6;; turn the count data for females into a contigency table(def female (matrix (sel (get-dataset :hair-eye-color) :cols 3 :rows (range 16 32)) 4))(chisq-test :table female) ;; X-sq = 106.664, df = 9, p-value = 7.014E-19,;; supply probabilities to goodness-of-fit test(def table [89 37 30 28 2])(def probs [0.40 0.20 0.20 0.19 0.01])(chisq-test :table table :probs probs) ;; X-sq = 5.7947, df = 4, p-value = 0.215;; use frequencies instead of probabilities(def freq [40 20 20 15 5])(chisq-test :table table :freq freq) ;; X-sq = 9.9901, df = 4, p-value = 0.04059References:http://www.itl.nist.gov/div898/handbook/eda/section3/eda35f.htmhttp://en.wikipedia.org/wiki/Pearson's_chi-square_testhttp://en.wikipedia.org/wiki/Yates'_chi-square_test

- concordant?
- fn ([[[a1 b1] [a2 b2]]])

- correlation
- fn ([x y] [mat])Returns the sample correlation of x and y, or the correlationmatrix of the given matrix.Examples:References:http://incanter.org/docs/parallelcolt/api/cern/jet/stat/tdouble/DoubleDescriptive.htmlhttp://en.wikipedia.org/wiki/Correlation

- correlation-linearity-test
- fn ([a b])http://en.wikipedia.org/wiki/Correlation_ratioIt is worth noting that if the relationship between values of and values of overline y_x is linear (which is certainly true when there are only two possibilities for x) this will give the same result as the square of the correlation coefficient, otherwise the correlation ratio will be larger in magnitude. It can therefore be used for judging non-linear relationships.

- correlation-ratio
- fn ([& xs])http://en.wikipedia.org/wiki/Correlation_ratioIn statistics, the correlation ratio is a measure of the relationship between the statistical dispersion within individual categories and the dispersion across the whole population or sample. i.e. the weighted variance of the category means divided by the variance of all samples.ExampleSuppose there is a distribution of test scores in three topics (categories):* Algebra: 45, 70, 29, 15 and 21 (5 scores)* Geometry: 40, 20, 30 and 42 (4 scores)* Statistics: 65, 95, 80, 70, 85 and 73 (6 scores).Then the subject averages are 36, 33 and 78, with an overall average of 52.The sums of squares of the differences from the subject averages are 1952 for Algebra, 308 for Geometry and 600 for Statistics, adding to 2860, while the overall sum of squares of the differences from the overall average is 9640. The difference between these of 6780 is also the weighted sum of the square of the differences between the subject averages and the overall average:5(36 − 52)2 + 4(33 − 52)2 + 6(78 − 52)2 = 6780This giveseta^2 =6780/9640=0.7033suggesting that most of the overall dispersion is a result of differences between topics, rather than within topics. Taking the square rooteta = sqrt 6780/9640=0.8386Observe that for η = 1 the overall sample dispersion is purely due to dispersion among the categories and not at all due to dispersion within the individual categories. For a quick comprehension simply imagine all Algebra, Geometry, and Statistics scores being the same respectively, e.g. 5 times 36, 4 times 33, 6 times 78.

- cosine-similarity
- fn ([a b])http://en.wikipedia.org/wiki/Cosine_similarityhttp://www.appliedsoftwaredesign.com/cosineSimilarityCalculator.phpThe Cosine Similarity of two vectors a and b is the ratio: a dot b / ||a|| ||b||Let d1 = {2 4 3 1 6}Let d2 = {3 5 1 2 5}Cosine Similarity (d1, d2) = dot(d1, d2) / ||d1|| ||d2||dot(d1, d2) = (2)*(3) + (4)*(5) + (3)*(1) + (1)*(2) + (6)*(5) = 61||d1|| = sqrt((2)^2 + (4)^2 + (3)^2 + (1)^2 + (6)^2) = 8.12403840464||d2|| = sqrt((3)^2 + (5)^2 + (1)^2 + (2)^2 + (5)^2) = 8Cosine Similarity (d1, d2) = 61 / (8.12403840464) * (8)= 61 / 64.9923072371= 0.938572618717

- covariance
- fn ([x y] [mat])Returns the sample covariance of x and y.Examples:;; create some data that covaries(def x (sample-normal 100))(def err (sample-normal 100))(def y (plus (mult 5 x) err));; estimate the covariance of x and y(covariance x y)References:http://incanter.org/docs/parallelcolt/api/cern/jet/stat/tdouble/DoubleDescriptive.htmlhttp://en.wikipedia.org/wiki/Covariance

- cumulative-mean
- fn ([coll])Returns a sequence of cumulative means for the given collection. For instanceThe first value equals the first value of the argument, the second value isthe mean of the first two arguments, the third is the mean of the first threearguments, etc.Examples:(cumulative-mean (sample-normal 100))

- damerau-levenshtein-distance
- fn ([a b])

- detabulate
- fn ([& options])Take a contingency table of counts and returns a matrix of observations.Examples:(use '(incanter core stats datasets))(def by-gender (group-by (get-dataset :hair-eye-color) 2))(def table (matrix (sel (first by-gender) :cols 3) 4))(detabulate :table table)(tabulate (detabulate :table table));; example 2(def data (matrix [[1 0][1 1][1 1][1 0][0 0][1 1][1 1][1 0][1 1]]))(tabulate data)(tabulate (detabulate :table (:table (tabulate data))))

- dice-coefficient
- fn ([a b])http://en.wikipedia.org/wiki/Dice%27s_coefficientDice's coefficient (also known as the Dice coefficient) is a similarity measure related to the Jaccard index.

- dice-coefficient-str
- fn ([a b])http://en.wikipedia.org/wiki/Dice%27s_coefficientWhen taken as a string similarity measure, the coefficient may be calculated for two strings, x and y using bigrams. here nt is the number of character bigrams found in both strings, nx is the number of bigrams in string x and ny is the number of bigrams in string y. For example, to calculate the similarity between:nightnachtWe would find the set of bigrams in each word:{ni,ig,gh,ht}{na,ac,ch,ht}Each set has four elements, and the intersection of these two sets has only one element: ht.Plugging this into the formula, we calculate, s = (2 · 1) / (4 + 4) = 0.25.

- discordant-pairs
- fn ([a b])http://en.wikipedia.org/wiki/Discordant_pairs

- discordant?
- fn

- euclidean-distance
- fn ([a b])http://en.wikipedia.org/wiki/Euclidean_distancethe Euclidean distance or Euclidean metric is the ordinary distance between two points that one would measure with a ruler, and is given by the Pythagorean formula. By using this formula as distance, Euclidean space (or even any inner product space) becomes a metric space. The associated norm is called the Euclidean norm. Older literature refers to the metric as Pythagorean metric.

- gamma-coefficient
- fn ([])http://www.statsdirect.com/help/nonparametric_methods/kend.htmThe gamma coefficient is given as a measure of association that is highly resistant to tied data (Goodman and Kruskal, 1963):

- hamming-distance
- fn ([a b])http://en.wikipedia.org/wiki/Hamming_distanceIn information theory, the Hamming distance between two strings of equal length is the number of positions at which the corresponding symbols are different. Put another way, it measures the minimum number of substitutions required to change one string into the other, or the number of errors that transformed one string into the other.

- indicator
- fn ([pred coll])Returns a sequence of ones and zeros, where onesare returned when the given predicate is true forcorresponding element in the given collection, andzero otherwise.Examples:(use 'incanter.stats)(indicator #(neg? %) (sample-normal 10));; return the sum of the positive values in a normal sample(def x (sample-normal 100))(sum (mult x (indicator #(pos? %) x)))

- jaccard-distance
- fn ([a b])http://en.wikipedia.org/wiki/Jaccard_indexThe Jaccard distance, which measures dissimilarity between sample sets, is complementary to the Jaccard coefficient and is obtained by subtracting the Jaccard coefficient from 1, or, equivalently, by dividing the difference of the sizes of the union and the intersection of two sets by the size of the union.

- jaccard-index
- fn ([a b])http://en.wikipedia.org/wiki/Jaccard_indexThe Jaccard index, also known as the Jaccard similarity coefficient (originally coined coefficient de communauté by Paul Jaccard), is a statistic used for comparing the similarity and diversity of sample sets.The Jaccard coefficient measures similarity between sample sets, and is defined as the size of the intersection divided by the size of the union of the sample sets.

- kendalls-tau
- fn ([a b])http://en.wikipedia.org/wiki/Kendall_tau_rank_correlation_coefficienthttp://www.statsdirect.com/help/nonparametric_methods/kend.htmhttp://mail.scipy.org/pipermail/scipy-dev/2009-March/011589.htmlbest explanation and example is in "cluster analysis for researchers" page 165.http://www.amazon.com/Cluster-Analysis-Researchers-Charles-Romesburg/dp/1411606175

- kendalls-tau-distance
- fn

- kendalls-w
- fn ([])http://en.wikipedia.org/wiki/Kendall%27s_Whttp://faculty.chass.ncsu.edu/garson/PA765/friedman.htmSuppose that object i is given the rank ri,j by judge number j, where there are in total n objects and m judges. Then the total rank given to object i isRi = sum Rijand the mean value of these total ranks isRbar = 1/2 m (n + 1)The sum of squared deviations, S, is defined asS=sum1-n (Ri - Rbar)and then Kendall's W is defined as[1]W= 12S / m^2(n^3-n)If the test statistic W is 1, then all the survey respondents have been unanimous, and each respondent has assigned the same order to the list of concerns. If W is 0, then there is no overall trend of agreement among the respondents, and their responses may be regarded as essentially random. Intermediate values of W indicate a greater or lesser degree of unanimity among the various responses.Legendre[2] discusses a variant of the W statistic which accommodates ties in the rankings and also describes methods of making significance tests based on W.[{:observation [1 2 3]} {} ... {}] -> W

- kurtosis
- fn ([x])Returns the kurtosis of the data, x. "Kurtosis is a measure of the "peakedness"of the probability distribution of a real-valued random variable. Higher kurtosismeans more of the variance is due to infrequent extreme deviations, as opposed tofrequent modestly-sized deviations." (Wikipedia)Examples:(kurtosis (sample-normal 100000)) ;; approximately 0(kurtosis (sample-gamma 100000)) ;; approximately 6References:http://incanter.org/docs/parallelcolt/api/cern/jet/stat/tdouble/DoubleDescriptive.htmlhttp://en.wikipedia.org/wiki/Kurtosis

- lee-distance
- fn ([a b q])http://en.wikipedia.org/wiki/Lee_distanceIn coding theory, the Lee distance is a distance between two strings x1x2...xn and y1y2...yn of equal length n over the q-ary alphabet {0,1,…,q-1} of size q >= 2. It is metric.If q = 2 or q = 3 the Lee distance coincides with the Hamming distance.The metric space induced by the Lee distance is a discrete analog of the elliptic space.

- levenshtein-distance
- fn ([a b])http://en.wikipedia.org/wiki/Levenshtein_distanceinternal representation is a table d with m+1 rows and n+1 columnswhere m is the length of a and m is the length of b.In information theory and computer science, the Levenshtein distance is a metric for measuring the amount of difference between two sequences (i.e., the so called edit distance). The Levenshtein distance between two strings is given by the minimum number of operations needed to transform one string into the other, where an operation is an insertion, deletion, or substitution of a single character.For example, the Levenshtein distance between "kitten" and "sitting" is 3, since the following three edits change one into the other, and there is no way to do it with fewer than three edits:1. kitten → sitten (substitution of 's' for 'k')2. sitten → sittin (substitution of 'i' for 'e')3. sittin → sitting (insert 'g' at the end).The Levenshtein distance has several simple upper and lower bounds that are useful in applications which compute many of them and compare them. These include:* It is always at least the difference of the sizes of the two strings.* It is at most the length of the longer string.* It is zero if and only if the strings are identical.* If the strings are the same size, the Hamming distance is an upper bound on the Levenshtein distance.

- linear-model
- fn ([y x & options])Returns the results of performing a OLS linear regression of y on x.Arguments:y is a vector (or sequence) of values for the dependent variablex is a vector or matrix of values for the independent variablesOptions::intercept (default true) indicates weather an intercept term should be includedReturns:a map, of type ::linear-model, containing::design-matrix -- a matrix containing the independent variables, and an intercept columns:coefs -- the regression coefficients:t-tests -- t-test values of coefficients:t-probs -- p-values for t-test values of coefficients:coefs-ci -- 95% percentile confidence interval:fitted -- the predicted values of y:residuals -- the residuals of each observation:std-errors -- the standard errors of the coeffients:sse -- the sum of squared errors, also called the residual sum of squares:ssr -- the regression sum of squares, also called the explained sum of squares:sst -- the total sum of squares (proportional to the sample variance):r-square -- coefficient of determinationExamples:(use '(incanter core stats datasets charts))(def iris (to-matrix (get-dataset :iris) :dummies true))(def y (sel iris :cols 0))(def x (sel iris :cols (range 1 6)))(def iris-lm (linear-model y x)) ; with intercept term(keys iris-lm) ; see what fields are included(:coefs iris-lm)(:sse iris-lm)(quantile (:residuals iris-lm))(:r-square iris-lm)(:adj-r-square iris-lm)(:f-stat iris-lm)(:f-prob iris-lm)(:df iris-lm)(def x1 (range 0.0 3 0.1))(view (xy-plot x1 (cdf-f x1 :df1 4 :df2 144)))References:http://en.wikipedia.org/wiki/OLS_Regressionhttp://en.wikipedia.org/wiki/Coefficient_of_determination

- mahalanobis-distance
- fn ([x & options])Returns the Mahalanobis distance between x, which iseither a vector or matrix of row vectors, and thecentroid of the observations in the matrix :y.Arguments:x -- either a vector or a matrix of row vectorsOptions::y -- Defaults to x, must be a matrix of row vectors which will be used to calculate a centroid:W -- Defaults to (solve (covariance y)), if an identity matrix is provided, the mahalanobis-distancefunction will be equal to the Euclidean distance.:centroid -- Defaults to (map mean (trans y))References:http://en.wikipedia.org/wiki/Mahalanobis_distanceExamples:(use '(incanter core stats charts));; generate some multivariate normal data with a single outlier.(def data (bind-rows(bind-columns(sample-mvn 100:sigma (matrix [[1 0.9][0.9 1]])))[-1.75 1.75]));; view a scatter plot of the data(let [[x y] (trans data)](doto (scatter-plot x y)(add-points [(mean x)] [(mean y)])(add-pointer -1.75 1.75 :text "Outlier")(add-pointer (mean x) (mean y) :text "Centroid")view));; calculate the distances of each point from the centroid.(def dists (mahalanobis-distance data));; view a bar-chart of the distances(view (bar-chart (range 102) dists));; Now contrast with the Euclidean distance.(def dists (mahalanobis-distance data :W (matrix [[1 0] [0 1]])));; view a bar-chart of the distances(view (bar-chart (range 102) dists));; another example(mahalanobis-distance [-1.75 1.75] :y data)(mahalanobis-distance [-1.75 1.75]:y data:W (matrix [[1 0][0 1]]))

- manhattan-distance
- fn ([a b])http://en.wikipedia.org/wiki/Manhattan_distanceusual metric of Euclidean geometry is replaced by a new metric in which the distance between two points is the sum of the (absolute) differences of their coordinates. The taxicab metric is also known as rectilinear distance, L1 distance or l1 norm (see Lp space), city block distance, Manhattan distance, or Manhattan length

- mean
- fn ([x])Returns the mean of the data, x.Examples:(mean (sample-normal 100))References:http://incanter.org/docs/parallelcolt/api/cern/jet/stat/tdouble/DoubleDescriptive.htmlhttp://en.wikipedia.org/wiki/Mean

- median
- fn ([x])Returns the median of the data, x.Examples:(median (sample-normal 100))References:http://incanter.org/docs/parallelcolt/api/cern/jet/stat/tdouble/DoubleDescriptive.htmlhttp://en.wikipedia.org/wiki/Median

- minkowski-distance
- fn ([a b p])http://en.wikipedia.org/wiki/Minkowski_distancehttp://en.wikipedia.org/wiki/Lp_spaceThe Minkowski distance is a metric on Euclidean space which can be considered as a generalization of both the Euclidean distance and the Manhattan distance.Minkowski distance is typically used with p being 1 or 2. The latter is the Euclidean distance, while the former is sometimes known as the Manhattan distance.In the limiting case of p reaching infinity we obtain the Chebyshev distance.

- n-grams
- fn ([n s])returns a set of the unique n-grams in a string.this is using actual sets here, discards dupicate n-grams?

- normalized-kendall-tau-distance
- fn ([a b])http://en.wikipedia.org/wiki/Kendall_tau_distanceKendall tau distance is the total number of discordant pairs.

- odds-ratio
- fn ([p1 p2])http://en.wikipedia.org/wiki/Odds_ratioDefinition in terms of group-wise oddsThe odds ratio is the ratio of the odds of an event occurring in one group to the odds of it occurring in another group, or to a sample-based estimate of that ratio.Suppose that in a sample of 100 men, 90 have drunk wine in the previous week, while in a sample of 100 women only 20 have drunk wine in the same period. The odds of a man drinking wine are 90 to 10, or 9:1, while the odds of a woman drinking wine are only 20 to 80, or 1:4 = 0.25:1. The odds ratio is thus 9/0.25, or 36, showing that men are much more likely to drink wine than women.Relation to statistical independenceIf X and Y are independent, their joint probabilities can be expressed in terms of their marginal probabilities. In this case, the odds ratio equals one, and conversely the odds ratio can only equal one if the joint probabilities can be factored in this way. Thus the odds ratio equals one if and only if X and Y are independent.

- pairings
- fn ([a b])confusing ass name.

- pairs
- fn ([a b])returns unique pairs of a and b where members of a and b can not be paired with the correspoding slot in the other list.

- pdf-beta
- fn ([x & options])Returns the Beta pdf of the given value of x. It will return a sequenceof values, if x is a sequence. This is equivalent to R's dbeta function.Options::alpha (default 1):beta (default 1)See also:cdf-beta and sample-betaReferences:http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/Beta.htmlhttp://en.wikipedia.org/wiki/Beta_distributionhttp://en.wikipedia.org/wiki/Probability_density_functionExample:(pdf-beta 0.5 :alpha 1 :beta 2)

- pdf-binomial
- fn ([x & options])Returns the Bionomial pdf of the given value of x. It will return a sequenceof values, if x is a sequence. Same as R's dbinomOptions::size (default 1):prob (default 1/2)See also:cdf-binomial and sample-binomialReferences:http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/Binomial.htmlhttp://en.wikipedia.org/wiki/Binomial_distributionhttp://en.wikipedia.org/wiki/Probability_density_functionExample:(pdf-binomial 10 :prob 1/4 :size 20)

- pdf-chisq
- fn ([x & options])Returns the Chi Square pdf of the given value of x. It will return a sequenceof values, if x is a sequence. Same as R's dchisq function.Options::df (default 1)See also:cdf-chisq and sample-chisqReferences:http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/ChiSquare.htmlhttp://en.wikipedia.org/wiki/Chi_square_distributionhttp://en.wikipedia.org/wiki/Probability_density_functionExample:(pdf-chisq 5.0 :df 2)

- pdf-exp
- fn ([x & options])Returns the Exponential pdf of the given value of x. It will return a sequenceof values, if x is a sequence. Same as R's dexpOptions::rate (default 1)See also:cdf-exp and sample-expReferences:http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/Exponential.htmlhttp://en.wikipedia.org/wiki/Exponential_distributionhttp://en.wikipedia.org/wiki/Probability_density_functionExample:(pdf-exp 2.0 :rate 1/2)

- pdf-f
- fn ([x & options])Returns the F pdf of the given value, x. It will return a sequenceof values, if x is a sequence. This is equivalent to R's df function.Options::df1 (default 1):df2 (default 1)See also:cdf-f and quantile-fReferences:http://en.wikipedia.org/wiki/F_distributionhttp://mathworld.wolfram.com/F-Distribution.htmlhttp://en.wikipedia.org/wiki/Probability_density_functionExample:(pdf-f 1.0 :df1 5 :df2 2)

- pdf-gamma
- fn ([x & options])Returns the Gamma pdf for the given value of x. It will return a sequenceof values, if x is a sequence. This is equivalent to R's dgamma function.Options::shape (default 1):rate (default 1)See also:cdf-gamma and sample-gammaReferences:http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/Gamma.htmlhttp://en.wikipedia.org/wiki/Gamma_distributionhttp://en.wikipedia.org/wiki/Probability_density_functionExample:(pdf-gamma 10 :shape 1 :rate 2)

- pdf-neg-binomial
- fn ([x & options])Returns the Negative Binomial pdf of the given value of x. It will return a sequenceof values, if x is a sequence. Same as R's dnbinomOptions::size (default 10):prob (default 1/2)See also:cdf-neg-binomial and sample-neg-binomialReferences:http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/NegativeBinomial.htmlhttp://en.wikipedia.org/wiki/Negative_binomial_distributionhttp://en.wikipedia.org/wiki/Probability_density_functionExample:(pdf-neg-binomial 10 :prob 1/2 :size 20)

- pdf-normal
- fn ([x & options])Returns the Normal pdf of the given value, x. It will return a sequenceof values, if x is a sequence. This is equivalent to R's dnorm function.Options::mean (default 0):sd (default 1)See also:cdf-normal, quantile-normal, sample-normalReferences:http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/Normal.htmlhttp://en.wikipedia.org/wiki/Normal_distributionhttp://en.wikipedia.org/wiki/Probability_density_functionExample:(pdf-normal 1.96 :mean -2 :sd (sqrt 0.5))

- pdf-poisson
- fn ([x & options])Returns the Poisson pdf of the given value of x. It will return a sequenceof values, if x is a sequence. Same as R's dpoisOptions::lambda (default 1)See also:cdf-poisson and sample-poissonReferences:http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/Poisson.htmlhttp://en.wikipedia.org/wiki/Poisson_distributionhttp://en.wikipedia.org/wiki/Probability_density_functionExample:(pdf-poisson 5 :lambda 10)

- pdf-t
- fn ([x & options])Returns the Student's t pdf for the given value of x. It will return a sequenceof values, if x is a sequence. Same as R's dt function.Options::df (default 1)See also:cdf-t, quantile-t, and sample-tReferences:http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/StudentT.htmlhttp://en.wikipedia.org/wiki/Student-t_distributionhttp://en.wikipedia.org/wiki/Probability_density_functionExample:(pdf-t 1.2 :df 10)

- pdf-uniform
- fn ([x & options])Returns the Uniform pdf of the given value of x. It will return a sequenceof values, if x is a sequence. This is equivalent to R's dunif function.Options::min (default 0):max (default 1)See also:cdf-uniform and sample-uniformReferences:http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/DoubleUniform.htmlhttp://en.wikipedia.org/wiki/Uniform_distributionhttp://en.wikipedia.org/wiki/Probability_density_functionExample:(pdf-uniform 5)(pdf-uniform 5 :min 1 :max 10)

- permute
- fn ([x] [x y])If provided a single argument, returns a permuted version of thegiven collection. (perm x) is the same as (sample x).If provided two arguments, returns two lists that are permutationsacross the given collections. In other words, each of the new collectionswill contain elements from both of the given collections. Useful forpermutation tests or randomization tests.Examples:(permute (range 10))(permute (range 10) (range 10 20))

- predict
- fn ([model x])Takes a linear-model and an x value (either a scalar or vector)and returns the predicted value based on the linear-model.

- principal-components
- fn ([x & options])Performs a principal components analysis on the given data matrix.Equivalent to R's prcomp function.Returns:A map with the following fields::std-dev -- the standard deviations of the principal compoenents(i.e. the square roots of the eigenvalues of the correlationmatrix, though the calculation is actually done with thesingular values of the data matrix.:rotation -- the matrix of variable loadings (i.e. a matrixwhose columns contain the eigenvectors).Examples:(use '(incanter core stats charts datasets));; load the iris dataset(def iris (to-matrix (get-dataset :iris)));; run the pca(def pca (principal-components (sel iris :cols (range 4))));; extract the first two principal components(def pc1 (sel (:rotation pca) :cols 0))(def pc2 (sel (:rotation pca) :cols 1));; project the first four dimension of the iris data onto the first;; two principal components(def x1 (mmult (sel iris :cols (range 4)) pc1))(def x2 (mmult (sel iris :cols (range 4)) pc2));; now plot the transformed data, coloring each species a different color(doto (scatter-plot (sel x1 :rows (range 50)) (sel x2 :rows (range 50)):x-label "PC1" :y-label "PC2" :title "Iris PCA")(add-points (sel x1 :rows (range 50 100)) (sel x2 :rows (range 50 100)))(add-points (sel x1 :rows (range 100 150)) (sel x2 :rows (range 100 150)))view);; alternatively, the :group-by option can be used in scatter-plot(view (scatter-plot x1 x2:group-by (sel iris :cols 4):x-label "PC1" :y-label "PC2" :title "Iris PCA"))References:http://en.wikipedia.org/wiki/Principal_component_analysis

- product-marginal-test
- fn ([j])the joint PMF of independent variables is equal to the product of their marginal PMFs.

- quantile
- fn ([x & options])Returns the quantiles of the data, x. By default it returns the min,25th-percentile, 50th-percentile, 75th-percentile, and max value.Options::probs (default [0.0 0.25 0.5 0.75 1.0])Examples:(quantile (sample-normal 100))(quantile (sample-normal 100) :probs [0.025 0.975])(quantile (sample-normal 100) :probs 0.975)References:http://incanter.org/docs/parallelcolt/api/cern/jet/stat/tdouble/DoubleDescriptive.htmlhttp://en.wikipedia.org/wiki/Quantile

- quantile-normal
- fn ([probability & options])Returns the inverse of the Normal CDF for the given probability.It will return a sequence of values, if given a sequence ofprobabilities. This is equivalent to R's qnorm function.Options::mean (default 0):sd (default 1)Returns:a value x, where (cdf-normal x) = probabilitySee also:pdf-normal, cdf-normal, and sample-normalReferences:http://incanter.org/docs/parallelcolt/api/cern/jet/stat/tdouble/Probability.htmlhttp://en.wikipedia.org/wiki/Normal_distributionhttp://en.wikipedia.org/wiki/QuantileExample:(quantile-normal 0.975)(quantile-normal [0.025 0.975] :mean -2 :sd (sqrt 0.5))

- quantile-t
- fn ([probability & options])Returns the inverse of the Student's t CDF for the given probability(i.e. the quantile). It will return a sequence of values, if x isa sequence of probabilities. This is equivalent to R's qt function.Options::df (default 1)Returns:a value x, where (cdf-t x) = probabilitySee also:pdf-t, cdf-t, and sample-tReferences:http://incanter.org/docs/parallelcolt/api/cern/jet/stat/tdouble/Probability.htmlhttp://en.wikipedia.org/wiki/Student-t_distributionhttp://en.wikipedia.org/wiki/QuantileExample:(quantile-t 0.975)(quantile-t [0.025 0.975] :df 25)(def df [1 2 3 4 5 6 7 8 9 10 20 50 100 1000])(map #(quantile-t 0.025 :df %) df)

- rank-index
- fn ([x])given a seq, returns a map where the keys are the values of the seq and the values are the positional rank of each member o the seq.

- sample
- fn ([x & options])Returns a sample of the given size from the given collection. If replacementis set to false it returns a set, otherwise it returns a list.Arguments:x -- collection to be sampled fromOptions::size -- (default (count x) sample size:replacement (default true) -- sample with replacementExamples:(sample (range 10)) ; permutation of numbers zero through ten(sample [:red :green :blue] :size 10) ; choose 10 items that are either :red, :green, or :blue.(sample (seq "abcdefghijklmnopqrstuvwxyz") :size 4 :replacement false) ; choose 4 random letters.

- sample-beta
- fn ([size & options])Returns a sample of the given size from a Beta distribution.This is equivalent to R's rbeta function.Options::alpha (default 1):beta (default 1)These default values produce a Uniform distribution.See also:pdf-beta and cdf-betaReferences:http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/Beta.htmlhttp://en.wikipedia.org/wiki/Beta_distributionExample:(sample-beta 1000 :alpha 1 :beta 2)

- sample-binomial
- fn ([size & options])Returns a sample of the given size from a Binomial distribution.Same as R's rbinomOptions::size (default 1):prob (default 1/2)See also:cdf-binomial and sample-binomialReferences:http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/Binomial.htmlhttp://en.wikipedia.org/wiki/Binomial_distributionExample:(sample-binomial 1000 :prob 1/4 :size 20)

- sample-chisq
- fn ([size & options])Returns a sample of the given size from a Chi Square distributionSame as R's rchisq function.Options::df (default 1)See also:pdf-chisq and cdf-chisqReferences:http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/ChiSquare.htmlhttp://en.wikipedia.org/wiki/Chi_square_distributionExample:(sample-chisq 1000 :df 2)

- sample-dirichlet
- fn ([size alpha])Examples:(use '(incanter core stats charts));; a total of 1447 adults were polled to indicate their preferences for;; candidate 1 (y1=727), candidate 2 (y2=583), or some other candidate or no;; preference (y3=137).;; the counts y1, y2, and y3 are assumed to have a multinomial distribution;; If a uniform prior distribution is assigned to the multinomial vector;; theta = (th1, th2, th3), then the posterior distribution of theta is;; proportional to g(theta) = th1^y1 * th2^y2 * th3^y3, which is a;; dirichlet distribution with parameters (y1+1, y2+1, y3+1)(def theta (sample-dirichlet 1000 [(inc 727) (inc 583) (inc 137)]));; view means, 95% CI, and histograms of the proportion parameters(mean (sel theta :cols 0))(quantile (sel theta :cols 0) :probs [0.0275 0.975])(view (histogram (sel theta :cols 0)))(mean (sel theta :cols 1))(quantile (sel theta :cols 1) :probs [0.0275 0.975])(view (histogram (sel theta :cols 1)))(mean (sel theta :cols 2))(quantile (sel theta :cols 2) :probs [0.0275 0.975])(view (histogram (sel theta :cols 2)));; view a histogram of the difference in proportions between the first;; two candidates(view (histogram (minus (sel theta :cols 0) (sel theta :cols 1))))

- sample-exp
- fn ([size & options])Returns a sample of the given size from a Exponential distribution.Same as R's rexpOptions::rate (default 1)See also:pdf-exp, and cdf-expReferences:http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/Exponential.htmlhttp://en.wikipedia.org/wiki/Exponential_distributionExample:(sample-exp 1000 :rate 1/2)

- sample-gamma
- fn ([size & options])Returns a sample of the given size from a Gamma distribution.This is equivalent to R's rgamma function.Options::shape (default 1):rate (default 1)See also:pdf-gamma, cdf-gamma, and quantile-gammaReferences:http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/Gamma.htmlhttp://en.wikipedia.org/wiki/Gamma_distributionExample:(sample-gamma 1000 :shape 1 :rate 2)

- sample-inv-wishart
- fn ([& options])Returns a p-by-p symmetric distribution drawn from an inverse-Wishart distributionOptions::p (default 2) -- number of dimensions of resulting matrix:df (default p) -- degree of freedoms (aka n), df <= p:scale (default (identity-matrix p)) -- positive definite matrix (aka V)Examples:(use 'incanter.stats)(sample-inv-wishart :df 10 :p 4);; calculate the mean of 1000 wishart matrices, should equal (mult df scale)(div (reduce plus (for [_ (range 1000)] (sample-wishart :p 4))) 1000)References:http://en.wikipedia.org/wiki/Inverse-Wishart_distribution

- sample-mvn
- fn ([size & options])Returns a sample of the given size from a Multivariate Normaldistribution. This is equivalent to R's mvtnorm::rmvnorm function.Arguments:size -- the size of the sample to returnOptions::mean (default (repeat (ncol sigma) 0)):sigma (default (identity-matrix (count mean)))Examples:(use '(incanter core stats charts))(def mvn-samp (sample-mvn 1000 :mean [7 5] :sigma (matrix [[2 1.5] [1.5 3]])))(covariance mvn-samp)(def means (map mean (trans mvn-samp)));; plot scatter-plot of points(def mvn-plot (scatter-plot (sel mvn-samp :cols 0) (sel mvn-samp :cols 1)))(view mvn-plot);; add centroid to plot(add-points mvn-plot [(first means)] [(second means)]);; add regression line to scatter plot(def x (sel mvn-samp :cols 0))(def y (sel mvn-samp :cols 1))(def lm (linear-model y x))(add-lines mvn-plot x (:fitted lm))References:http://en.wikipedia.org/wiki/Multivariate_normal

- sample-neg-binomial
- fn ([size & options])Returns a sample of the given size from a Negative Binomial distribution.Same as R's rnbinomOptions::size (default 10):prob (default 1/2)See also:pdf-neg-binomial and cdf-neg-binomialReferences:http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/NegativeBinomial.htmlhttp://en.wikipedia.org/wiki/Negative_binomial_distributionExample:(sample-neg-binomial 1000 :prob 1/2 :size 20)

- sample-normal
- fn ([size & options])Returns a sample of the given size from a Normal distributionThis is equivalent to R's rnorm function.Options::mean (default 0):sd (default 1)See also:pdf-normal, cdf-normal, quantile-normalReferences:http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/Normal.htmlhttp://en.wikipedia.org/wiki/Normal_distributionExample:(sample-normal 1000 :mean -2 :sd (sqrt 0.5))

- sample-permutations
- fn ([n x] [n x y])If provided a two arguments (n x), it returns a list of n permutationsof x. If provided three (n x y) arguments, returns a list with two with n permutations ofeach arguments, where each permutation is drawn from the pooled arguments.Arguments:n -- number of randomized versions of the original two groups to returnx -- group 1y -- (default nil) group 2Examples:(use '(incanter core stats))(sample-permutations 10 (range 10))(sample-permutations 10 (range 10) (range 10 20));; extended example with plant-growth data(use '(incanter core stats datasets charts));; load the plant-growth dataset(def data (to-matrix (get-dataset :plant-growth)));; break the first column of the data into groups based on treatment (second column).(def groups (group-by data 1 :cols 0));; define a function for the statistic of interest(defn means-diff [x y] (minus (mean x) (mean y)));; calculate the difference in sample means between the two groups(def samp-mean-diff (means-diff (first groups) (second groups))) ;; 0.371;; create 500 permuted versions of the original two groups(def permuted-groups (sample-permutations 1000 (first groups) (second groups)));; calculate the difference of means of the 500 samples(def permuted-means-diffs1 (map means-diff (first permuted-groups) (second permuted-groups)));; use an indicator function that returns 1 when the randomized means diff is greater;; than the original sample mean, and zero otherwise. Then take the mean of this sequence;; of ones and zeros. That is the proportion of times you would see a value more extreme;; than the sample mean (i.e. the p-value).(mean (indicator #(> % samp-mean-diff) permuted-means-diffs1)) ;; 0.088;; calculate the 95% confidence interval of the null hypothesis. If the;; sample difference in means is outside of this range, that is evidence;; that the two means are statistically significantly different.(quantile permuted-means-diffs1 :probs [0.025 0.975]) ;; (-0.606 0.595);; Plot a histogram of the permuted-means-diffs using the density option,;; instead of the default frequency, and then add a normal pdf curve with;; the mean and sd of permuted-means-diffs data for a visual comparison.(doto (histogram permuted-means-diffs1 :density true)(add-lines (range -1 1 0.01) (pdf-normal (range -1 1 0.01):mean (mean permuted-means-diffs1):sd (sd permuted-means-diffs1)))view);; compare the means of treatment 2 and control(def permuted-groups (sample-permutations 1000 (first groups) (last groups)))(def permuted-means-diffs2 (map means-diff (first permuted-groups) (second permuted-groups)))(def samp-mean-diff (means-diff (first groups) (last groups))) ;; -0.4939(mean (indicator #(< % samp-mean-diff) permuted-means-diffs2)) ;; 0.022(quantile permuted-means-diffs2 :probs [0.025 0.975]) ;; (-0.478 0.466);; compare the means of treatment 1 and treatment 2(def permuted-groups (sample-permutations 1000 (second groups) (last groups)))(def permuted-means-diffs3 (map means-diff (first permuted-groups) (second permuted-groups)))(def samp-mean-diff (means-diff (second groups) (last groups))) ;; -0.865(mean (indicator #(< % samp-mean-diff) permuted-means-diffs3)) ;; 0.002(quantile permuted-means-diffs3 :probs [0.025 0.975]) ;; (-0.676 0.646)(doto (box-plot permuted-means-diffs1)(add-box-plot permuted-means-diffs2)(add-box-plot permuted-means-diffs3)view)Further Reading:http://en.wikipedia.org/wiki/Resampling_(statistics)

- sample-poisson
- fn ([size & options])Returns a sample of the given size from a Poisson distribution.Same as R's rpoisOptions::lambda (default 1)See also:pdf-poisson and cdf-poissonReferences:http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/Poisson.htmlhttp://en.wikipedia.org/wiki/Poisson_distributionExample:(sample-poisson 1000 :lambda 10)

- sample-t
- fn ([size & options])Returns a sample of the given size from a Student's t distribution.Same as R's rt function.Options::df (default 1)See also:pdf-t, cdf-t, and quantile-tReferences:http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/StudentT.htmlhttp://en.wikipedia.org/wiki/Student-t_distributionExample:(cdf-t 1000 :df 10)

- sample-uniform
- fn ([size & options])Returns a sample of the given size from a Uniform distribution.This is equivalent to R's runif function.Options::min (default 0):max (default 1):integers (default false)See also:pdf-uniform and cdf-uniformReferences:http://incanter.org/docs/parallelcolt/api/cern/jet/random/tdouble/DoubleUniform.htmlhttp://en.wikipedia.org/wiki/Uniform_distributionExample:(sample-uniform 1000)(sample-uniform 1000 :min 1 :max 10)

- sample-wishart
- fn ([& options])Returns a p-by-p symmetric distribution drawn from a Wishart distributionOptions::p (default 2) -- number of dimensions of resulting matrix:df (default p) -- degree of freedoms (aka n), df <= p:scale (default (identity-matrix p)) -- positive definite matrix (aka V)Examples:(use 'incanter.stats)(sample-wishart :df 10 :p 4);; calculate the mean of 1000 wishart matrices, should equal (mult df scale)(div (reduce plus (for [_ (range 1000)] (sample-wishart :p 4))) 1000)References:http://en.wikipedia.org/wiki/Wishart_distribution#

- sd
- fn ([x])Returns the sample standard deviation of the data, x. Equivalent toR's sd function.Examples:(sd (sample-normal 100))References:http://incanter.org/docs/parallelcolt/api/cern/jet/stat/tdouble/DoubleDescriptive.htmlhttp://en.wikipedia.org/wiki/Standard_deviation

- simple-regression
- fn ([y x & options])A stripped version of linear-model that returns a map containing onlythe coefficients.

- skewness
- fn ([x])Returns the skewness of the data, x. "Skewness is a measure of the asymmetryof the probability distribution of a real-valued random variable." (Wikipedia)Examples:(skewness (sample-normal 100000)) ;; approximately 0(skewness (sample-gamma 100000)) ;; approximately 2References:http://incanter.org/docs/parallelcolt/api/cern/jet/stat/tdouble/DoubleDescriptive.htmlhttp://en.wikipedia.org/wiki/Skewness

- smooth-discrete-probs
- fn ([probs buckets])smooth a map of discrete probabilities.clear up any discrete steps that are missing and should be there.TODO: single class may have a spike of 100% probability.

- sorensen-index
- fn ([a b])http://en.wikipedia.org/wiki/S%C3%B8rensen_similarity_index#cite_note-4The Sørensen index, also known as Sørensen’s similarity coefficient, is a statistic used for comparing the similarity of two samples. where A and B are the species numbers in samples A and B, respectively, and C is the number of species shared by the two samples.The Sørensen index is identical to Dice's coefficient which is always in [0, 1] range. Sørensen index used as a distance measure, 1 − QS, is identical to Hellinger distance and Bray–Curtis dissimilarity.The Sørensen coefficient is mainly useful for ecological community data (e.g. Looman & Campbell, 1960[3]). Justification for its use is primarily empirical rather than theoretical (although it can be justified theoretically as the intersection of two fuzzy sets[4]). As compared to Euclidean distance, Sørensen distance retains sensitivity in more heterogeneous data sets and gives less weight to outliersThis function assumes you pass in a and b as sets.The sorensen index extended to abundance instead of incidence of species is called the Czekanowski index.

- spearmans-rho
- fn ([a b])http://en.wikipedia.org/wiki/Spearman%27s_rank_correlation_coefficientIn statistics, Spearman's rank correlation coefficient or Spearman's rho, is a non-parametric measure of correlation – that is, it assesses how well an arbitrary monotonic function could describe the relationship between two variables, without making any other assumptions about the particular nature of the relationship between the variables. Certain other measures of correlation are parametric in the sense of being based on possible relationships of a parameterised form, such as a linear relationship.

- square-devs-from-mean
- fn ([x] [x m])takes either a sample or a sample and a precalculated mean.returns the squares of the difference between each observation and the sample mean.

- sum-of-square-devs-from-mean
- fn ([x] [x m])takes either a sample or a sample and a precalculated mean.returns the sum of the squares of the difference between each observation and the sample mean.

- sum-variance-test
- fn ([vs])the variance of the sum of n independent variables is equal to the sum of their variances.(variance-independence-test [[1 2 3 4] [1 2 3 4]]) -> 5/2

- sweep
- fn ([x & options])Return an array obtained from an input array by sweeping out asummary statistic. Based to R's sweep function.Arguments:x is an sequenceOptions::stat (default mean) the statistic to sweep out:fun (defaul minus) the function used to sweep the stat outExample:(use '(incanter core stats))(def x (sample-normal 30 :mean 10 :sd 5))(sweep x) ;; center the data around mean(sweep x :stat sd :fun div) ;; divide data by its sd

- t-test
- fn ([x & options])Argument:x : sample to testOptions::y (default nil):mu (default (mean y) or 0) population mean:alternative (default :two-sided) other choices :less :greater:var-equal TODO (default false) variance equal:paired TODO (default false) paired test:conf-level (default 0.95) for returned confidence intervalExamples:(t-test (range 1 11) :mu 0)(t-test (range 1 11) :mu 0 :alternative :less)(t-test (range 1 11) :mu 0 :alternative :greater)(t-test (range 1 11) :y (range 7 21))(t-test (range 1 11) :y (range 7 21) :alternative :less)(t-test (range 1 11) :y (range 7 21) :alternative :greater)(t-test (range 1 11) :y (conj (range 7 21) 200))References:http://en.wikipedia.org/wiki/T_testhttp://www.socialresearchmethods.net/kb/stat_t.php

- tabulate
- fn ([x & options])Cross-tabulates the values of the given numeric matrix.Returns a hash-map with the following fields::table -- the table of counts for each combination of values,this table is only returned if x has two-columns:levels -- a sequence of sequences, where each sequence listthe levels (possible values) of the correspondingcolumn of x.:margins -- a sequence of sequences, where each sequencerepresents the marginal total for each levelof the corresponding column of x.:counts -- a hash-map, where vectors of unique combinationsof the cross-tabulated levels are the keys and thevalues are the total count of each combination.:N -- the grand-total for the contingency tableExamples:(use '(incanter core stats))(tabulate [1 2 3 2 3 2 4 3 5])(tabulate (sample-poisson 100 :lambda 5))(use '(incanter core stats datasets))(def math-prog (to-matrix (get-dataset :math-prog)))(tabulate (sel math-prog :cols [1 2]))(def data (matrix [[1 0 1][1 1 1][1 1 1][1 0 1][0 0 0][1 1 1][1 1 1][1 0 1][1 1 0]]))(tabulate data)(def data (matrix [[1 0][1 1][1 1][1 0][0 0][1 1][1 1][1 0][1 1]]))(tabulate data)

- tanimoto-coefficient
- fn ([a b])http://en.wikipedia.org/wiki/Jaccard_indexThe cosine similarity metric may be extended such that it yields the Jaccard coefficient in the case of binary attributes. This is the Tanimoto coefficient.

- variance
- fn ([x])Returns the sample variance of the data, x. Equivalent to R's var function.Examples:(variance (sample-normal 100))References:http://incanter.org/docs/parallelcolt/api/cern/jet/stat/tdouble/DoubleDescriptive.htmlhttp://en.wikipedia.org/wiki/Sample_variance#Population_variance_and_sample_variance

- within
- fn ([z x y])y is within z of x in metric space.

all-keys bottom-level? flatten-with key-compare kv-compare levels-deep map-compare map-from-keys map-from-nested-map map-from-pairs map-map same-length? set-to-unit-map sort-map sort-map-of-maps sort-maps-by table-to-vectors

- all-keys
- fn ([m])returns a set of all the keys from an arbitarily deeply nested map or seq of maps.

- bottom-level?
- fn ([m])given a map; is this the bottom level in the map?(bottom-level? {:a 1}) -> true(bottom-level? {:a {:b 1}}) -> false

- flatten-with
- fn ([f nested-map])takes an arbitrarily deeply nested map, and flattens it to one level by merging keys.(flatten-with str {:a {:b {:c 1}}}) -> {":a:b:c" 1}

- key-compare
- fn ([x y])

- kv-compare
- fn ([[k1 v1] [k2 v2]])

- levels-deep
- fn ([m])returns the number of levels of depth of nesting for a nested map.1 -> 0{} -> 0{0 1} -> 1{1 {0 1}} -> 2...

- map-compare
- fn ([k])

- map-from-keys
- fn ([a f])

- map-from-nested-map
- fn ([a f])

- map-from-pairs
- fn ([a f])

- map-map
- fn ([f x])

- same-length?
- fn ([a b])

- set-to-unit-map
- fn ([s])

- sort-map
- fn ([m])

- sort-map-of-maps
- fn ([m])

- sort-maps-by
- fn ([k maps])

- table-to-vectors
- fn ([z])takes a big vector that is composed of two vectors of alternating membership in the super vector.splits out the individual vectors.[106 786 0100 27101 5099 28103 2997 20113 12112 6110 17]->[[106 86 100 101 99 103 97 113 112 110] [7 0 27 50 28 29 20 12 6 17]]