Skip to content

Commit

Permalink
Mention return value protocols in docstring (#39)
Browse files Browse the repository at this point in the history
Co-authored-by: Henry Garner <henry@mbp.lan>
  • Loading branch information
henrygarner and Henry Garner committed Jan 13, 2022
1 parent 3362626 commit 7dbc5fd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/kixi/stats/core.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@
(defn simple-linear-regression
"Given two functions: (fx input) and (fy input), each of which returns a
number, calculates a least squares linear model between fx and fy over inputs.
Returns a vector containing the coefficients: offset and slope.
Returns a reified kixi.stats.protocols/PParamaterised.
Ignores any records with fx or fy are nil. If there are no records with
values for fx and fy, the linear relationship is nil. See
https://en.wikipedia.org/wiki/Simple_linear_regression."
Expand All @@ -480,6 +480,7 @@
"Given two functions: (fx input) and (fy input), each of which returns a
number, and an x value, calculates the standard error of the least
squares linear model of fx and fy over inputs.
Returns a reified kixi.stats.protocols/PDependent.
Ignores any records with fx or fy are nil. If there are no records with
values for fx and fy, the standard error of the estimate is nil."
([fx fy]
Expand All @@ -495,6 +496,8 @@
"Given two functions: (fx input) and (fy input), each of which returns a
number, and an x value, calculates the standard error of the least
squares linear model of fx and fy over inputs.
Returns a reified kixi.stats.protocols/PDependent if alpha is supplied,
or a reified kixi.stats.protocols/PDependentWithSignificance otherwise.
Ignores any records with fx or fy are nil. If there are no records with
values for fx and fy, the standard error of the estimate is nil."
([fx fy]
Expand All @@ -517,6 +520,7 @@
"Given two functions: (fx input) and (fy input), each of which returns a
number, and an x value, calculates the standard error of the least
squares linear model of fx and fy over inputs.
Returns a reified kixi.stats.protocols/PDependent.
Ignores any records with fx or fy are nil. If there are no records with
values for fx and fy, the standard error of the estimate is nil."
([fx fy]
Expand All @@ -534,6 +538,8 @@
"Given two functions: (fx input) and (fy input), each of which returns a
number, and an x value, calculates the standard error of the least
squares linear model of fx and fy over inputs.
Returns a reified kixi.stats.protocols/PDependent if alpha is supplied,
or a reified kixi.stats.protocols/PDependentWithSignificance otherwise.
Ignores any records with fx or fy are nil. If there are no records with
values for fx and fy, the standard error of the estimate is nil."
([fx fy]
Expand Down
5 changes: 5 additions & 0 deletions src/kixi/stats/test.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

(defn chi-squared-test
"Calculates the X^2 test of independence for a given contingency table.
Returns a reified kixi.stats.protocols/PTestResult.
See kixi.stats.core/cross-tabulate"
[^kixi.stats.protocols.PContingencyTable table]
(let [margins (p/margin-totals table)
Expand All @@ -57,6 +58,7 @@
sd: the population standard deviation
mean: the sample mean
n: the sample size
Returns a reified kixi.stats.protocols/PTestResult.
See also: kixi.stats.core/simple-z-test"
[{:keys [mu sd]} {:keys [mean n]}]
(when (and (pos? n) (pos? sd))
Expand All @@ -66,6 +68,7 @@
(defn z-test
"Calculates the z-test of statistical significance between two sample means.
Requires the mean, sd and sample size (n) of both samples.
Returns a reified kixi.stats.protocols/PTestResult.
See also: kixi.stats.core/z-test"
[{mean-x :mean sd-x :sd n-x :n}
{mean-y :mean sd-y :sd n-y :n}]
Expand All @@ -81,6 +84,7 @@
(defn t-test
"Calculates Welch's unequal variances t-test of statistical significance.
Requires the mean, sd and sample size (n) of both samples.
Returns a reified kixi.stats.protocols/PTestResult.
See also: kixi.stats.core/t-test"
[{mean-a :mean sd-a :sd n-a :n}
{mean-b :mean sd-b :sd n-b :n}]
Expand All @@ -103,6 +107,7 @@
sd: the population standard deviation
mean: the sample mean
n: the sample size
Returns a reified kixi.stats.protocols/PTestResult.
See also: kixi.stats.core/simple-t-test"
[{:keys [mu sd]} {:keys [mean n]}]
(let [dof (dec n)
Expand Down

0 comments on commit 7dbc5fd

Please sign in to comment.