<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>data/iran_election_2009.csv</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -40,7 +40,7 @@ For a great introduction to programming in Clojure, read &quot;Clojure - Functional P
 
 h2. Getting started with Incanter
 
-Start the Clojure shell (aka the REPL) from the Incanter directory: @bin/clj@ (or @bin\clj.bat@ on Windows).
+Start the Clojure shell (aka the REPL) from the Incanter directory: @bin/clj@ or @bin\clj.bat@ on Windows (note: if you want to start the Clojure REPL from a directory other than the top level Incanter directory, change the INCANTER_HOME variable in the clj script so that it uses an absolute path instead the ./ directory).
 
 From the Clojure shell, load the Incanter libraries: &lt;pre&gt;&lt;code&gt;(use '(incanter core stats charts))&lt;/code&gt;&lt;/pre&gt;
 </diff>
      <filename>README.textile</filename>
    </modified>
    <modified>
      <diff>@@ -1917,7 +1917,7 @@ setLinkToggleText(&amp;apos;library-contents-toggle-incanter.censored&amp;apos;, &amp;apos;+
           dist (DoubleUniform. min max (DoubleMersenneTwister.))]
       (if (coll? x)
         (map #(.cdf dist %) x)
-        (.cdf dist x)))))&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/dd&gt;&lt;/dl&gt;&lt;/li&gt;&lt;li class=&quot;library-member&quot;&gt;&lt;a name=&quot;member-incanter.stats-chisq-test&quot;/&gt;&lt;dl class=&quot;library-member-table&quot;&gt;&lt;dt class=&quot;library-member-name&quot;&gt;chisq-test&lt;/dt&gt;&lt;dd&gt;&lt;div class=&quot;library-member-info&quot;&gt;&lt;span class=&quot;library-member-type&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;library-member-arglists&quot;&gt;([&amp;amp; options])&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;library-member-docs&quot;&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt; &lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;  Performs chi-squared contingency table tests and goodness-of-fit tests.&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;  &lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;  If the optional argument :y is not provided then a goodness-of-fit test&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;  is performed. In this case, the hypothesis tested is whether the &lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;  population probabilities equal those in :probs, or are all equal if &lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;  :probs is not given.&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;&lt;span class=&quot;library-member-doc-whitespace&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;  If :y is provided, it must be a sequence of integers that is the&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;  same length as x. A contingency table is computed from x and :y. &lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;  Then, Pearson&amp;apos;s chi-squared test of the null hypothesis that the joint&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;  distribution of the cell counts in a 2-dimensional contingency&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;  table is the product of the row and column marginals is performed.&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;  By default the Yates&amp;apos; continuity correction for 2x2 contingency&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;  tables is performed, this can be disabled by setting the :correct &lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;  option to false.&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;  &lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;&lt;span class=&quot;library-member-doc-whitespace&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;  Options:&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    :x -- a sequence of numbers.&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    :y -- a sequence of numbers&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    :table -- a contigency table&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    :probs (when (nil? y) -- (repeat n-levels (/ n-levels)))&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    :correct (default true) -- use Yates&amp;apos; correction for continuity&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;&lt;span class=&quot;library-member-doc-whitespace&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;&lt;span class=&quot;library-member-doc-whitespace&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;  Returns:&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    :X-sq -- the Pearson X-squared test statistics&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    :p-value -- the p-value for the test statistic&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    :df -- the degress of freedom&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;&lt;span class=&quot;library-member-doc-whitespace&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;&lt;span class=&quot;library-member-doc-whitespace&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;  Examples:&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    (use &amp;apos;(incanter core stats))&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    (chisq-test :x [1 2 3 2 3 2 4 3 5]) ;; 2.6667&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    (chisq-test :x [1 0 0 0  1 1 1 0 0 1 0 0 1 1 1 1]) ;; 0.25&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;   &lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    (use &amp;apos;(incanter core stats datasets))&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    (def math-prog (to-matrix (get-dataset :math-prog)))&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    (def x (sel math-prog :cols 1))&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    (def y (sel math-prog :cols 2))&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    (chisq-test :x x :y y) ;; X-sq = 1.24145, df=1, p-value = 0.26519&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    (chisq-test :x x :y y :correct false) ;; X-sq = 2.01094, df=1, p-value = 0.15617&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;&lt;span class=&quot;library-member-doc-whitespace&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    (def table (matrix [[31 12] [9 8]]))&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    (chisq-test :table table) ;; X-sq = 1.24145, df=1, p-value = 0.26519&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    (chisq-test :table table :correct false) ;; X-sq = 2.01094, df=1, p-value = 0.15617&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;&lt;span class=&quot;library-member-doc-whitespace&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    ;; look at the hair-eye-color data&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    ;; turn the count data for males into a contigency table&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    (def male (matrix (sel (get-dataset :hair-eye-color) :cols 3 :rows (range 16)) 4))&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    (chisq-test :table male) ;; X-sq = 41.280, df = 9, p-value = 4.44E-6&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    ;; turn the count data for females into a contigency table&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    (def female (matrix (sel (get-dataset :hair-eye-color) :cols 3 :rows (range 16 32)) 4))&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    (chisq-test :table female) ;; X-sq = 106.664, df = 9, p-value = 7.014E-19,&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;&lt;span class=&quot;library-member-doc-whitespace&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;&lt;span class=&quot;library-member-doc-whitespace&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    (def detab (detabulate :table table))&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    (chisq-test :x (sel detab :cols 0) :y (sel detab :cols 1))&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;&lt;span class=&quot;library-member-doc-whitespace&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;&lt;span class=&quot;library-member-doc-whitespace&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;&lt;span class=&quot;library-member-doc-whitespace&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;&lt;span class=&quot;library-member-doc-whitespace&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;  References:&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    http://www.itl.nist.gov/div898/handbook/eda/section3/eda35f.htm&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    http://en.wikipedia.org/wiki/Pearson&amp;apos;s_chi-square_test&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    http://en.wikipedia.org/wiki/Yates&amp;apos;_chi-square_test&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;library-member-source-section&quot;&gt;&lt;div class=&quot;library-member-source-toggle&quot;&gt;[ &lt;a href=&quot;javascript:toggleSource(&amp;apos;membersource-incanter.stats-chisq-test&amp;apos;)&quot; id=&quot;linkto-membersource-incanter.stats-chisq-test&quot;&gt;Show Source&lt;/a&gt; ]&lt;/div&gt;&lt;div class=&quot;library-member-source&quot; id=&quot;membersource-incanter.stats-chisq-test&quot;&gt;&lt;pre&gt;(defn chisq-test
+        (.cdf dist x)))))&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;&lt;/dd&gt;&lt;/dl&gt;&lt;/li&gt;&lt;li class=&quot;library-member&quot;&gt;&lt;a name=&quot;member-incanter.stats-chisq-test&quot;/&gt;&lt;dl class=&quot;library-member-table&quot;&gt;&lt;dt class=&quot;library-member-name&quot;&gt;chisq-test&lt;/dt&gt;&lt;dd&gt;&lt;div class=&quot;library-member-info&quot;&gt;&lt;span class=&quot;library-member-type&quot;&gt;fn&lt;/span&gt; &lt;span class=&quot;library-member-arglists&quot;&gt;([&amp;amp; options])&lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;library-member-docs&quot;&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt; &lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;  Performs chi-squared contingency table tests and goodness-of-fit tests.&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;  &lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;  If the optional argument :y is not provided then a goodness-of-fit test&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;  is performed. In this case, the hypothesis tested is whether the &lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;  population probabilities equal those in :probs, or are all equal if &lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;  :probs is not given.&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;&lt;span class=&quot;library-member-doc-whitespace&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;  If :y is provided, it must be a sequence of integers that is the&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;  same length as x. A contingency table is computed from x and :y. &lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;  Then, Pearson&amp;apos;s chi-squared test of the null hypothesis that the joint&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;  distribution of the cell counts in a 2-dimensional contingency&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;  table is the product of the row and column marginals is performed.&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;  By default the Yates&amp;apos; continuity correction for 2x2 contingency&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;  tables is performed, this can be disabled by setting the :correct &lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;  option to false.&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;  &lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;&lt;span class=&quot;library-member-doc-whitespace&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;  Options:&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    :x -- a sequence of numbers.&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    :y -- a sequence of numbers&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    :table -- a contigency table. If one dimensional, the test is a goodness-of-fit&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    :probs (when (nil? y) -- (repeat n-levels (/ n-levels)))&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    :freq (default nil) -- if given, these are rescaled to probabilities&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    :correct (default true) -- use Yates&amp;apos; correction for continuity for 2x2 contingency tables&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;&lt;span class=&quot;library-member-doc-whitespace&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;&lt;span class=&quot;library-member-doc-whitespace&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;  Returns:&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    :X-sq -- the Pearson X-squared test statistics&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    :p-value -- the p-value for the test statistic&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    :df -- the degress of freedom&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;&lt;span class=&quot;library-member-doc-whitespace&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;&lt;span class=&quot;library-member-doc-whitespace&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;  Examples:&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    (use &amp;apos;(incanter core stats))&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    (chisq-test :x [1 2 3 2 3 2 4 3 5]) ;; X-sq 2.6667&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    ;; create a one-dimensional table of this data&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    (def table (matrix [1 3 3 1 1]))&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    (chisq-test :table table) ;; X-sq 2.6667&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    (chisq-test :table (trans table)) ;; throws exception&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;&lt;span class=&quot;library-member-doc-whitespace&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    (chisq-test :x [1 0 0 0  1 1 1 0 0 1 0 0 1 1 1 1]) ;; 0.25&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;   &lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    (use &amp;apos;(incanter core stats datasets))&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    (def math-prog (to-matrix (get-dataset :math-prog)))&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    (def x (sel math-prog :cols 1))&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    (def y (sel math-prog :cols 2))&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    (chisq-test :x x :y y) ;; X-sq = 1.24145, df=1, p-value = 0.26519&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    (chisq-test :x x :y y :correct false) ;; X-sq = 2.01094, df=1, p-value = 0.15617&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;&lt;span class=&quot;library-member-doc-whitespace&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    (def table (matrix [[31 12] [9 8]]))&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    (chisq-test :table table) ;; X-sq = 1.24145, df=1, p-value = 0.26519&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    (chisq-test :table table :correct false) ;; X-sq = 2.01094, df=1, p-value = 0.15617&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    ;; use the detabulate function to create data rows corresponding to the table&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    (def detab (detabulate :table table))&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    (chisq-test :x (sel detab :cols 0) :y (sel detab :cols 1))&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;&lt;span class=&quot;library-member-doc-whitespace&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    ;; look at the hair-eye-color data&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    ;; turn the count data for males into a contigency table&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    (def male (matrix (sel (get-dataset :hair-eye-color) :cols 3 :rows (range 16)) 4))&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    (chisq-test :table male) ;; X-sq = 41.280, df = 9, p-value = 4.44E-6&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    ;; turn the count data for females into a contigency table&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    (def female (matrix (sel (get-dataset :hair-eye-color) :cols 3 :rows (range 16 32)) 4))&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    (chisq-test :table female) ;; X-sq = 106.664, df = 9, p-value = 7.014E-19,&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;&lt;span class=&quot;library-member-doc-whitespace&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;&lt;span class=&quot;library-member-doc-whitespace&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    ;; supply probabilities to goodness-of-fit test&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    (def table [89 37 30 28 2])&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    (def probs [0.40 0.20 0.20 0.19 0.01])&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    (chisq-test :table table :probs probs) ;; X-sq = 5.7947, df = 4, p-value = 0.215&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;&lt;span class=&quot;library-member-doc-whitespace&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    ;; use frequencies instead of probabilities &lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    (def freq [40 20 20 15 5])&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    (chisq-test :table table :freq freq) ;; X-sq = 9.9901, df = 4, p-value = 0.04059&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;&lt;span class=&quot;library-member-doc-whitespace&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;&lt;span class=&quot;library-member-doc-whitespace&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;&lt;span class=&quot;library-member-doc-whitespace&quot;&gt; &lt;/span&gt;&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;  References:&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    http://www.itl.nist.gov/div898/handbook/eda/section3/eda35f.htm&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    http://en.wikipedia.org/wiki/Pearson&amp;apos;s_chi-square_test&lt;/div&gt;&lt;div class=&quot;library-member-doc-line&quot;&gt;    http://en.wikipedia.org/wiki/Yates&amp;apos;_chi-square_test&lt;/div&gt;&lt;/div&gt;&lt;div class=&quot;library-member-source-section&quot;&gt;&lt;div class=&quot;library-member-source-toggle&quot;&gt;[ &lt;a href=&quot;javascript:toggleSource(&amp;apos;membersource-incanter.stats-chisq-test&amp;apos;)&quot; id=&quot;linkto-membersource-incanter.stats-chisq-test&quot;&gt;Show Source&lt;/a&gt; ]&lt;/div&gt;&lt;div class=&quot;library-member-source&quot; id=&quot;membersource-incanter.stats-chisq-test&quot;&gt;&lt;pre&gt;(defn chisq-test
 &amp;quot; ...&amp;quot;
   ([&amp;amp; options]
     (let [opts (if options (apply assoc {} options) nil)
@@ -1945,25 +1945,32 @@ setLinkToggleText(&amp;apos;library-contents-toggle-incanter.censored&amp;apos;, &amp;apos;+
                      (range (ncol table)) 
                      (second (:levels xtab)))
           r-margins (if table?
-                      (apply hash-map (interleave r-levels (map sum (trans table)))) 
+                      (if two-samp?
+                        (apply hash-map (interleave r-levels (map sum (trans table))))
+                        (if (&amp;gt; (nrow table) 1) 
+                          (to-list table) 
+                          (throw (Exception. &amp;quot;One dimensional tables must have only a single column&amp;quot;))))
                       (second (:margins xtab)))
           c-margins (if table? 
-                      (apply hash-map (interleave c-levels (map sum table)))
+                      (if two-samp?
+                        (apply hash-map (interleave c-levels (map sum table)))
+                        0)
                       (first (:margins xtab)))
                   
-          counts (vectorize table) 
-                  ;(if table? 
-                  ; (vectorize table) 
-                   ;(vals (:counts xtab))) ;; BAD
+          counts (if two-samp? (vectorize table) table)
           N (if table? 
               (sum counts) 
               (:N xtab))
           n (when (not two-samp?) (count r-levels))
           df (if two-samp? (* (dec (nrow table)) (dec (ncol table))) (dec n))
           probs (when (not two-samp?)
-                  (if (:probs opts) 
+                  (cond 
                     (:probs opts) 
-                    (repeat n (/ n))))
+                      (:probs opts) 
+                    (:freq opts)
+                      (div (:freq opts) (sum (:freq opts)))
+                    :else
+                      (repeat n (/ n))))
           E (if two-samp?
               (for [r r-levels c c-levels]
                 (/ (* (c-margins c) (r-margins r)) N))</diff>
      <filename>docs/api/index.html</filename>
    </modified>
    <modified>
      <diff></diff>
      <filename>incanter.jar</filename>
    </modified>
    <modified>
      <diff></diff>
      <filename>lib/clojure.jar</filename>
    </modified>
    <modified>
      <diff>@@ -2007,9 +2007,10 @@
   Options:
     :x -- a sequence of numbers.
     :y -- a sequence of numbers
-    :table -- a contigency table
+    :table -- a contigency table. If one dimensional, the test is a goodness-of-fit
     :probs (when (nil? y) -- (repeat n-levels (/ n-levels)))
-    :correct (default true) -- use Yates' correction for continuity
+    :freq (default nil) -- if given, these are rescaled to probabilities
+    :correct (default true) -- use Yates' correction for continuity for 2x2 contingency tables
 
 
   Returns:
@@ -2020,7 +2021,12 @@
 
   Examples:
     (use '(incanter core stats))
-    (chisq-test :x [1 2 3 2 3 2 4 3 5]) ;; 2.6667
+    (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))
@@ -2033,6 +2039,9 @@
     (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
@@ -2043,9 +2052,14 @@
     (chisq-test :table female) ;; X-sq = 106.664, df = 9, p-value = 7.014E-19,
 
 
-    (def detab (detabulate :table table))
-    (chisq-test :x (sel detab :cols 0) :y (sel detab :cols 1))
+    ;; 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.04059
 
 
 
@@ -2081,25 +2095,32 @@
                      (range (ncol table)) 
                      (second (:levels xtab)))
           r-margins (if table?
-                      (apply hash-map (interleave r-levels (map sum (trans table)))) 
+                      (if two-samp?
+                        (apply hash-map (interleave r-levels (map sum (trans table))))
+                        (if (&gt; (nrow table) 1) 
+                          (to-list table) 
+                          (throw (Exception. &quot;One dimensional tables must have only a single column&quot;))))
                       (second (:margins xtab)))
           c-margins (if table? 
-                      (apply hash-map (interleave c-levels (map sum table)))
+                      (if two-samp?
+                        (apply hash-map (interleave c-levels (map sum table)))
+                        0)
                       (first (:margins xtab)))
                   
-          counts (vectorize table) 
-                  ;(if table? 
-                  ; (vectorize table) 
-                   ;(vals (:counts xtab))) ;; BAD
+          counts (if two-samp? (vectorize table) table)
           N (if table? 
               (sum counts) 
               (:N xtab))
           n (when (not two-samp?) (count r-levels))
           df (if two-samp? (* (dec (nrow table)) (dec (ncol table))) (dec n))
           probs (when (not two-samp?)
-                  (if (:probs opts) 
+                  (cond 
                     (:probs opts) 
-                    (repeat n (/ n))))
+                      (:probs opts) 
+                    (:freq opts)
+                      (div (:freq opts) (sum (:freq opts)))
+                    :else
+                      (repeat n (/ n))))
           E (if two-samp?
               (for [r r-levels c c-levels]
                 (/ (* (c-margins c) (r-margins r)) N))</diff>
      <filename>src/incanter/stats.clj</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>db974d086732e2362753dbeba0ccf139c84ffa4f</id>
    </parent>
  </parents>
  <author>
    <name>David Edgar Liebke</name>
    <email>liebke@gmail.com</email>
  </author>
  <url>http://github.com/liebke/incanter/commit/005a408a9ab2b0c669f156bde65fe1b3c32e258d</url>
  <id>005a408a9ab2b0c669f156bde65fe1b3c32e258d</id>
  <committed-date>2009-06-21T16:38:27-07:00</committed-date>
  <authored-date>2009-06-21T16:38:27-07:00</authored-date>
  <message>added goodness-of-fit test to chisq-test function</message>
  <tree>1c2fa0abaf259a62564fe00f2ee9f8fa6ea04465</tree>
  <committer>
    <name>David Edgar Liebke</name>
    <email>liebke@gmail.com</email>
  </committer>
</commit>
