From: Thomas F. <tho...@ru...> - 2015-01-25 19:08:11
|
Git commit 227ed9131aed2ae5945551f70355ac2a449db0a5 by Thomas Friedrichsmeier. Committed on 25/01/2015 at 19:07. Pushed by tfry into branch 'work/distributions'. Further progress on the mass-conversion of distribution plugins. TODO: Complete help pages, add tests. M +1 -1 rkward/plugins/distributions.pluginmap M +1 -1 rkward/plugins/distributions/beta.js M +1 -1 rkward/plugins/distributions/binomial.js M +3 -2 rkward/plugins/distributions/binomial.xml M +1 -1 rkward/plugins/distributions/cauchy.js M +21 -0 rkward/plugins/distributions/cauchy.rkh M +4 -1 rkward/plugins/distributions/chi_squared.js M +21 -0 rkward/plugins/distributions/chi_squared.rkh M +15 -7 rkward/plugins/distributions/dist_common.js M +2 -1 rkward/plugins/distributions/dist_snippets.xml M +2 -1 rkward/plugins/distributions/exponential.js M +21 -0 rkward/plugins/distributions/exponential.rkh M +1 -1 rkward/plugins/distributions/exponential.xml M +1 -1 rkward/plugins/distributions/f.js M +22 -0 rkward/plugins/distributions/f.rkh M +3 -3 rkward/plugins/distributions/f.xml M +1 -1 rkward/plugins/distributions/gamma.js M +22 -0 rkward/plugins/distributions/gamma.rkh M +2 -2 rkward/plugins/distributions/gamma.xml M +2 -1 rkward/plugins/distributions/geom.js M +22 -0 rkward/plugins/distributions/geom.rkh M +3 -0 rkward/plugins/distributions/geom.xml M +6 -17 rkward/plugins/distributions/gumbel.js M +2 -2 rkward/plugins/distributions/gumbel.xml M +1 -3 rkward/plugins/distributions/hypergeometric.js M +7 -4 rkward/plugins/distributions/hypergeometric.xml M +1 -1 rkward/plugins/distributions/log_normal.js M +2 -2 rkward/plugins/distributions/log_normal.xml M +3 -1 rkward/plugins/distributions/logistic.js M +2 -2 rkward/plugins/distributions/logistic.xml M +3 -1 rkward/plugins/distributions/negative_binomial.js M +4 -1 rkward/plugins/distributions/negative_binomial.xml M +1 -1 rkward/plugins/distributions/normal.js M +1 -0 rkward/plugins/distributions/plot_beta_distribution.rkh M +2 -2 rkward/plugins/distributions/plot_binomial_distribution.rkh M +2 -2 rkward/plugins/distributions/plot_cauchy_distribution.rkh M +2 -1 rkward/plugins/distributions/poisson.js M +5 -1 rkward/plugins/distributions/poisson.xml M +1 -1 rkward/plugins/distributions/t.js M +2 -2 rkward/plugins/distributions/t.xml M +1 -1 rkward/plugins/distributions/tukey.js M +2 -2 rkward/plugins/distributions/tukey.xml M +3 -1 rkward/plugins/distributions/uniform.js M +1 -1 rkward/plugins/distributions/weibull.js M +3 -1 rkward/plugins/distributions/wilcoxon.js M +2 -0 rkward/plugins/distributions/wilcoxon.xml http://commits.kde.org/rkward/227ed9131aed2ae5945551f70355ac2a449db0a5 diff --git a/rkward/plugins/distributions.pluginmap b/rkward/plugins/distributions.pluginmap index 1e24fef..4a19ead 100644 --- a/rkward/plugins/distributions.pluginmap +++ b/rkward/plugins/distributions.pluginmap @@ -38,7 +38,7 @@ <component type="standard" id="chi_squared_probabilities" file="chi_squared.xml" label="Chi-squared distribution calculator" /> <component type="standard" id="plot_chi_squared_distribution" file="plot_chi_squared_distribution.xml" label="Plot Chi-squared distribution" /> - <component type="standard" id="exponential_probabilities" file="exponential.xml" label="Exponential probabilities" /> + <component type="standard" id="exponential_probabilities" file="exponential.xml" label="Exponential distribution calculator" /> <component type="standard" id="plot_exponential_distribution" file="plot_exponential_distribution.xml" label="Plot Exponential distribution" /> <component type="standard" id="f_probabilities" file="f.xml" label="F distribution calculator" /> diff --git a/rkward/plugins/distributions/beta.js b/rkward/plugins/distributions/beta.js index 209b8c1..c3e9bd6 100755 --- a/rkward/plugins/distributions/beta.js +++ b/rkward/plugins/distributions/beta.js @@ -1,5 +1,5 @@ include ("dist_common.js"); function getDistSpecifics () { - return initDistSpecifics (i18n ('Beta distribution'), 'beta', ["shape1", "shape2", "ncp"], [0, 1], true); + return initDistSpecifics (i18n ('Beta distribution'), 'beta', ["shape1", "shape2", "ncp"], [0, 1], continuous); } diff --git a/rkward/plugins/distributions/binomial.js b/rkward/plugins/distributions/binomial.js index ca0f014..f4cff4f 100644 --- a/rkward/plugins/distributions/binomial.js +++ b/rkward/plugins/distributions/binomial.js @@ -1,6 +1,6 @@ include ("dist_common.js"); function getDistSpecifics () { - var dist = initDistSpecifics (i18n ('Binomial distribution'), 'binom', ["size", "prob"], [0, getString ("size")], false); + var dist = initDistSpecifics (i18n ('Binomial distribution'), 'binom', ["size", "prob"], [0, getString ("size")], discrete); return dist; } diff --git a/rkward/plugins/distributions/binomial.xml b/rkward/plugins/distributions/binomial.xml index b6198b0..f1047a1 100644 --- a/rkward/plugins/distributions/binomial.xml +++ b/rkward/plugins/distributions/binomial.xml @@ -4,8 +4,9 @@ <help file="binomial.rkh" /> <logic> <insert snippet="dialog_logic"/> - <set id="ui_note.visible" to="true"/> - <set id="ui_note.text" to="Note: For the binomial distribution, quantiles can be interpreted as number of successes in the given number of trials."/> + <script><![CDATA[ + gui.setValue ("ui_note.text", i18n (noquote ("Quantiles can be interpreted as number of successes in the given number of trials."))); + ]]></script> </logic> <snippets> <snippet id="dist_options"> diff --git a/rkward/plugins/distributions/cauchy.js b/rkward/plugins/distributions/cauchy.js index 66938ec..d7779de 100755 --- a/rkward/plugins/distributions/cauchy.js +++ b/rkward/plugins/distributions/cauchy.js @@ -1,5 +1,5 @@ include ("dist_common.js"); function getDistSpecifics () { - return initDistSpecifics (i18n ('Cauchy distribution'), 'cauchy', ["location", "scale"]); + return initDistSpecifics (i18n ('Cauchy distribution'), 'cauchy', ["location", "scale"], [], continuous); } diff --git a/rkward/plugins/distributions/cauchy.rkh b/rkward/plugins/distributions/cauchy.rkh index e69de29..dfa4fc4 100644 --- a/rkward/plugins/distributions/cauchy.rkh +++ b/rkward/plugins/distributions/cauchy.rkh @@ -0,0 +1,21 @@ +<!DOCTYPE rkhelp> +<document> + <snippets> + <include file="dist_help_snippets.xml"/> + </snippets> + <summary> + Provides a calculator for probabilities, quantiles, and densities in the Cauchy distribution. + </summary> + <insert snippet="dialog_usage"/> + <settings> + <insert snippet="dialog_settings"/> + <setting id="location">Location parameter (median) of the Cauchy distribution</setting> + <setting id="scale">Scale parameter of the Cauchy distribution</setting> + </settings> + <related> + <ul> + <li><link href="rkward://rhelp/Cauchy"/></li> + <li><link href="rkward://component/rkward/plot_cauchy_distribution"/></li> + </ul> + </related> +</document> diff --git a/rkward/plugins/distributions/chi_squared.js b/rkward/plugins/distributions/chi_squared.js index 2ffd350..71631e4 100644 --- a/rkward/plugins/distributions/chi_squared.js +++ b/rkward/plugins/distributions/chi_squared.js @@ -1,5 +1,8 @@ include ("dist_common.js"); function getDistSpecifics () { - return initDistSpecifics (i18n ('Chi-squared distribution'), 'chisq', ["df", "ncp"]); + var df = Number (getString ("df")); + return initDistSpecifics (i18n ('Chi-squared distribution'), 'chisq', ["df", "ncp"], + [Math.max (0, Math.floor (df * .6 - 4)), Math.floor (df * 1.4 + 4)], // NOTE: crude self-made heuristic for covering the likely range of interest for auto-quantiles + continuos); } diff --git a/rkward/plugins/distributions/chi_squared.rkh b/rkward/plugins/distributions/chi_squared.rkh index e69de29..50818c6 100644 --- a/rkward/plugins/distributions/chi_squared.rkh +++ b/rkward/plugins/distributions/chi_squared.rkh @@ -0,0 +1,21 @@ +<!DOCTYPE rkhelp> +<document> + <snippets> + <include file="dist_help_snippets.xml"/> + </snippets> + <summary> + Provides a calculator for probabilities, quantiles, and densities in the Chi-squared (χ²) distribution. + </summary> + <insert snippet="dialog_usage"/> + <settings> + <insert snippet="dialog_settings"/> + <setting id="df">Degrees of freedom</setting> + <setting id="ncp">Non-centrality parameter</setting> + </settings> + <related> + <ul> + <li><link href="rkward://rhelp/Chisquare"/></li> + <li><link href="rkward://component/rkward/plot_chi_squared_distribution"/></li> + </ul> + </related> +</document> diff --git a/rkward/plugins/distributions/dist_common.js b/rkward/plugins/distributions/dist_common.js index 2028932..de9d69e 100644 --- a/rkward/plugins/distributions/dist_common.js +++ b/rkward/plugins/distributions/dist_common.js @@ -4,7 +4,11 @@ var dist; var invar; var outvar; -function initDistSpecifics (title, stem, params, range, continuous) { +const continuous = 1; +const discrete = 2; + +// NOTE: range +function initDistSpecifics (title, stem, params, range, type) { var dist = new Object (); var header = new Header (title); var par = ""; @@ -15,9 +19,9 @@ function initDistSpecifics (title, stem, params, range, continuous) { dist["header"] = header; dist["params"] = par; dist["funstem"] = stem; - dist["min"] = Number (range[0]); - dist["max"] = Number (range[1]); - dist["cont"] = continuous; + dist["min"] = range[0]; + dist["max"] = range[1]; + dist["cont"] = (type == continuous); return dist; } @@ -45,24 +49,28 @@ function calculate () { if (mode == "q") values = getList ("p.0"); else values = getList ("q.0"); if (values.length < 1) { + // NOTE: making this an even number is somewhat important. Otherwise, the middle number will be something very close to (but not quite) 0 in many cases, + // resulting in very ugly number formatting var max_auto_sequence_length = 20; if (invar == 'q') { if (!dist["cont"]) { - var span = dist["max"] - dist["min"]; + var span = Number (dist["max"]) - Number (dist["min"]) - 1; if (span <= max_auto_sequence_length) { values = String (dist["min"]) + ':' + String (dist["max"]); } else { values = 'seq.int (' + String (dist["min"]) + ', ' + String (dist["max"]) + ', by=' + String (Math.ceil (span / max_auto_sequence_length)) + ')'; } } else { - values = 'seq (' + String (dist["min"]) + ', ' + String (dist["max"]) + ', length.out=' + String (max_auto_sequence_length+1) + ')'; + if (dist["min"] === undefined) dist["min"] = 'q' + dist["funstem"] + ' (.01' + dist["params"] + ')'; + if (dist["max"] === undefined) dist["max"] = 'q' + dist["funstem"] + ' (.99' + dist["params"] + ')'; + values = 'seq (' + String (dist["min"]) + ', ' + String (dist["max"]) + ', length.out=' + String (max_auto_sequence_length) + ')'; } } else { // invar == 'p' if (logpd) { values = '-' + String (max_auto_sequence_length) + ':0'; } else { - values = 'seq (0, 1, length.out=' + String (max_auto_sequence_length+1) + ')'; + values = 'seq (0, 1, length.out=' + String (max_auto_sequence_length) + ')'; } } } else { diff --git a/rkward/plugins/distributions/dist_snippets.xml b/rkward/plugins/distributions/dist_snippets.xml index 63855a9..25c5b21 100644 --- a/rkward/plugins/distributions/dist_snippets.xml +++ b/rkward/plugins/distributions/dist_snippets.xml @@ -10,7 +10,8 @@ <connect client="q.visible" governor="do_q.not"/> <connect client="p.visible" governor="do_q"/> - <set id="ui_note.visible" to="false"/> + <convert id="have_ui_note" mode="notequals" sources="ui_note.text" standard=""/> + <connect client="ui_note.visible" governor="have_ui_note"/> </snippet> <snippet id="dialog_layout"> <dropdown id="mode" label="Mode"> diff --git a/rkward/plugins/distributions/exponential.js b/rkward/plugins/distributions/exponential.js index 22f8660..e581136 100755 --- a/rkward/plugins/distributions/exponential.js +++ b/rkward/plugins/distributions/exponential.js @@ -1,5 +1,6 @@ include ("dist_common.js"); function getDistSpecifics () { - return initDistSpecifics (i18n ('Exponential distribution'), 'exp', ["rate"]); + var rate = Number (getString ("rate")); + return initDistSpecifics (i18n ('Exponential distribution'), 'exp', ["rate"], [0, Math.floor (5/rate)], continuous); } diff --git a/rkward/plugins/distributions/exponential.rkh b/rkward/plugins/distributions/exponential.rkh index e69de29..4324ee6 100644 --- a/rkward/plugins/distributions/exponential.rkh +++ b/rkward/plugins/distributions/exponential.rkh @@ -0,0 +1,21 @@ +<!DOCTYPE rkhelp> +<document> + <snippets> + <include file="dist_help_snippets.xml"/> + </snippets> + <summary> + Provides a calculator for probabilities, quantiles, and densities in the Exponential distribution. + </summary> + <insert snippet="dialog_usage"/> + <settings> + <insert snippet="dialog_settings"/> + <setting id="rate">Rate parameter λ (1/mean)</setting> + </settings> + <related> + <ul> + <li><link href="rkward://component/rkward/gamma_probabilities"/> (of which the exponential distribution is a special case)</li> + <li><link href="rkward://rhelp/Exponential"/></li> + <li><link href="rkward://component/rkward/plot_exponential_distribution"/></li> + </ul> + </related> +</document> diff --git a/rkward/plugins/distributions/exponential.xml b/rkward/plugins/distributions/exponential.xml index cec6009..339a809 100755 --- a/rkward/plugins/distributions/exponential.xml +++ b/rkward/plugins/distributions/exponential.xml @@ -7,7 +7,7 @@ </logic> <snippets> <snippet id="dist_options"> - <spinbox default_precision="2" type="real" min="0" initial="1" id="rate" label="vector of rates"/> + <spinbox default_precision="1" type="real" min="0" initial="1" id="rate" label="Rates"/> </snippet> <include file="dist_snippets.xml"/> </snippets> diff --git a/rkward/plugins/distributions/f.js b/rkward/plugins/distributions/f.js index b148eae..d69986b 100644 --- a/rkward/plugins/distributions/f.js +++ b/rkward/plugins/distributions/f.js @@ -1,5 +1,5 @@ include ("dist_common.js"); function getDistSpecifics () { - return initDistSpecifics (i18n ('F distribution'), 'f', ["df1", "df2", "ncp"]); + return initDistSpecifics (i18n ('F distribution'), 'f', ["df1", "df2", "ncp"], [0, undefined], continuous); } diff --git a/rkward/plugins/distributions/f.rkh b/rkward/plugins/distributions/f.rkh index e69de29..7962a6c 100644 --- a/rkward/plugins/distributions/f.rkh +++ b/rkward/plugins/distributions/f.rkh @@ -0,0 +1,22 @@ +<!DOCTYPE rkhelp> +<document> + <snippets> + <include file="dist_help_snippets.xml"/> + </snippets> + <summary> + Provides a calculator for probabilities, quantiles, and densities in the F distribution. + </summary> + <insert snippet="dialog_usage"/> + <settings> + <insert snippet="dialog_settings"/> + <setting id="df1">Numerator degrees of freedom</setting> + <setting id="df2">Denominator degrees of freedom</setting> + <setting id="ncp">Non-centrality parameter</setting> + </settings> + <related> + <ul> + <li><link href="rkward://rhelp/Fdist"/></li> + <li><link href="rkward://component/rkward/plot_f_distribution"/></li> + </ul> + </related> +</document> diff --git a/rkward/plugins/distributions/f.xml b/rkward/plugins/distributions/f.xml index ee0e96a..c16873c 100644 --- a/rkward/plugins/distributions/f.xml +++ b/rkward/plugins/distributions/f.xml @@ -7,9 +7,9 @@ </logic> <snippets> <snippet id="dist_options"> - <spinbox default_precision="2" type="real" initial="1" id="df1" min="0" label="Numerator degree of Freedom"/> - <spinbox default_precision="2" type="real" initial="1" id="df2" min="0" label="Denominator degree of Freedom"/> - <spinbox default_precision="2" type="real" initial="0" id="ncp" min="0" label="non-centrality parameter"/> + <spinbox default_precision="1" type="real" initial="1" id="df1" min="0" label="Numerator degrees of Freedom"/> + <spinbox default_precision="1" type="real" initial="10" id="df2" min="0" label="Denominator degrees of Freedom"/> + <spinbox default_precision="1" type="real" initial="0" id="ncp" min="0" label="non-centrality parameter"/> </snippet> <include file="dist_snippets.xml"/> </snippets> diff --git a/rkward/plugins/distributions/gamma.js b/rkward/plugins/distributions/gamma.js index b7dabe1..32487c1 100755 --- a/rkward/plugins/distributions/gamma.js +++ b/rkward/plugins/distributions/gamma.js @@ -1,5 +1,5 @@ include ("dist_common.js"); function getDistSpecifics () { - return initDistSpecifics (i18n ('Gamma distribution'), 'gamma', ["shape", "rate"]); + return initDistSpecifics (i18n ('Gamma distribution'), 'gamma', ["shape", "rate"], [0, undefined], continuous); } diff --git a/rkward/plugins/distributions/gamma.rkh b/rkward/plugins/distributions/gamma.rkh index e69de29..610d165 100644 --- a/rkward/plugins/distributions/gamma.rkh +++ b/rkward/plugins/distributions/gamma.rkh @@ -0,0 +1,22 @@ +<!DOCTYPE rkhelp> +<document> + <snippets> + <include file="dist_help_snippets.xml"/> + </snippets> + <summary> + Provides a calculator for probabilities, quantiles, and densities in the gamma distribution. + </summary> + <insert snippet="dialog_usage"/> + <settings> + <insert snippet="dialog_settings"/> + <setting id="shape">Shape parameter (k)</setting> + <setting id="rate">Rate parameter β (inverse of scale parameter)</setting> + </settings> + <related> + <ul> + <li><link href="rkward://component/rkward/exponential_probabilities"/> (a special case of the gamma distribution with shape=1)</li> + <li><link href="rkward://rhelp/GammaDist">R help on Gamma Distribution functions</link></li> + <li><link href="rkward://component/rkward/plot_gamma_distribution"/></li> + </ul> + </related> +</document> diff --git a/rkward/plugins/distributions/gamma.xml b/rkward/plugins/distributions/gamma.xml index c5d3288..6bbd16e 100755 --- a/rkward/plugins/distributions/gamma.xml +++ b/rkward/plugins/distributions/gamma.xml @@ -7,8 +7,8 @@ </logic> <snippets> <snippet id="dist_options"> - <spinbox default_precision="2" type="real" min="0" initial="1" id="shape" label="Shape"/> - <spinbox default_precision="2" type="real" min="0" initial="1" id="rate" label="Rate"/> + <spinbox default_precision="1" type="real" min="0" initial="1" id="shape" label="Shape"/> + <spinbox default_precision="1" type="real" min="0" initial="1" id="rate" label="Rate"/> </snippet> <include file="dist_snippets.xml"/> </snippets> diff --git a/rkward/plugins/distributions/geom.js b/rkward/plugins/distributions/geom.js index 0c4a02f..f7dbbd6 100755 --- a/rkward/plugins/distributions/geom.js +++ b/rkward/plugins/distributions/geom.js @@ -1,5 +1,6 @@ include ("dist_common.js"); function getDistSpecifics () { - return initDistSpecifics (i18n ('Geometric distribution'), 'geom', ["prob"]); + var prob = Number (getString ("prob")); + return initDistSpecifics (i18n ('Geometric distribution'), 'geom', ["prob"], [0, Math.floor (5/prob)], discrete); } diff --git a/rkward/plugins/distributions/geom.rkh b/rkward/plugins/distributions/geom.rkh index e69de29..64e4c80 100644 --- a/rkward/plugins/distributions/geom.rkh +++ b/rkward/plugins/distributions/geom.rkh @@ -0,0 +1,22 @@ +<!DOCTYPE rkhelp> +<document> + <snippets> + <include file="dist_help_snippets.xml"/> + </snippets> + <summary> + Provides a calculator for probabilities, quantiles, and densities in the Geometric distribution. + + Quantiles in the geometric distribution represent the number of failures in a sequence of Bernoulli trials before the first success. + </summary> + <insert snippet="dialog_usage"/> + <settings> + <insert snippet="dialog_settings"/> + <setting id="prob">Probability of success in each trial. Note that this setting is <b>not</b> affected by the "log probabilities" setting, i.e. always specify the plain probability,</setting> + </settings> + <related> + <ul> + <li><link href="rkward://rhelp/Geometric"/></li> + <li><link href="rkward://component/rkward/plot_geom_distribution"/></li> + </ul> + </related> +</document> diff --git a/rkward/plugins/distributions/geom.xml b/rkward/plugins/distributions/geom.xml index bd3564b..68b4ce5 100755 --- a/rkward/plugins/distributions/geom.xml +++ b/rkward/plugins/distributions/geom.xml @@ -4,6 +4,9 @@ <help file="geom.rkh" /> <logic> <insert snippet="dialog_logic"/> + <script><![CDATA[ + gui.setValue ("ui_note.text", i18n (noquote ("Quantiles represent the number of failures in a sequence of Bernoulli trials before the first success."))); + ]]></script> </logic> <snippets> <snippet id="dist_options"> diff --git a/rkward/plugins/distributions/gumbel.js b/rkward/plugins/distributions/gumbel.js index 6dc1e8d..5f5098f 100755 --- a/rkward/plugins/distributions/gumbel.js +++ b/rkward/plugins/distributions/gumbel.js @@ -1,22 +1,11 @@ include ("dist_common.js"); -function getDistSpecifics () { - return initDistSpecifics (i18n ('Gumbel distribution'), 'weibull', ["shape", "scale"]); -} - -error! - -// globals -var q; - -function calculate () { - q = "c (" + getString ("q").replace (/[, ]+/g, ", ") + ")"; - - echo ('result <- (pweibull (q = exp(' + q + '), shape = ' + getValue ("shape") + ', scale = ' + getValue ("scale") + ', ' + getValue ("tail") + ', ' + getValue("logp") + '))\n'); +function preprocess () { + echo ('require (FAdist)\n'); } -function printout () { - echo ('rk.header ("Gumbel probability", list ("Vector of quantiles", "' + q + '", "Shape", "' + getValue ("shape") + '", "Scale", "' + getValue ("scale") + '", "Tail", "' + getValue ("tail") + '", "Probabilities p are given as", "' + getValue ("logp") + '"))\n'); - echo ('rk.results (result, titles="Gumbel probabilities")\n'); +function getDistSpecifics () { + var scale = Number (getString ("scale")); + var location = Number (getString ("location")); + return initDistSpecifics (i18n ('Gumbel distribution'), 'gumbel', ["location", "scale"], [Math.floor (-2*scale+location), Math.ceil (5*scale+location)], continuous); } - diff --git a/rkward/plugins/distributions/gumbel.xml b/rkward/plugins/distributions/gumbel.xml index 120bc81..a195e3e 100755 --- a/rkward/plugins/distributions/gumbel.xml +++ b/rkward/plugins/distributions/gumbel.xml @@ -7,8 +7,8 @@ </logic> <snippets> <snippet id="dist_options"> - <spinbox default_precision="2" type="real" min="0" initial="1" id="shape" label="Shape"/> - <spinbox default_precision="2" type="real" min="1" initial="1" id="scale" label="Scale"/> + <spinbox default_precision="1" type="real" min="0" initial="0" id="location" label="Location"/> + <spinbox default_precision="1" type="real" initial="1" id="scale" label="Scale"/> </snippet> <include file="dist_snippets.xml"/> </snippets> diff --git a/rkward/plugins/distributions/hypergeometric.js b/rkward/plugins/distributions/hypergeometric.js index d9f9b7d..9e65315 100755 --- a/rkward/plugins/distributions/hypergeometric.js +++ b/rkward/plugins/distributions/hypergeometric.js @@ -1,7 +1,5 @@ include ("dist_common.js"); function getDistSpecifics () { - var dist = initDistSpecifics (i18n ('Hypergeometric distribution'), 'hyper', ["m", "n", "k"]); - dist["max_quantile"] = getString ("m"); - return dist; + return initDistSpecifics (i18n ('Hypergeometric distribution'), 'hyper', ["m", "n", "k"], [0, getString ("m")], discrete); } diff --git a/rkward/plugins/distributions/hypergeometric.xml b/rkward/plugins/distributions/hypergeometric.xml index 26a064e..73e1e13 100755 --- a/rkward/plugins/distributions/hypergeometric.xml +++ b/rkward/plugins/distributions/hypergeometric.xml @@ -1,15 +1,18 @@ <!DOCTYPE rkplugin> <document> - <code file="hypergeometric_probabilities.js" /> + <code file="hypergeometric.js" /> <help file="hypergeometric.rkh" /> <logic> <insert snippet="dialog_logic"/> + <script><![CDATA[ + gui.setValue ("ui_note.text", i18n (noquote ("Quantiles represent the number of white balls drawn in k draws without replacement from an urn containing m white and n black balls."))); + ]]></script> </logic> <snippets> <snippet id="dist_options"> - <spinbox type="integer" min="0" initial="1" id="m" label="m (Number of white balls in the urn)"/> - <spinbox type="integer" min="0" initial="1" id="n" label="n (Number of black balls in the urn)"/> - <spinbox type="integer" min="0" initial="1" id="k" label="k (Number of balls drawn from the urn)"/> + <spinbox type="integer" min="0" initial="10" id="m" label="m (Number of white balls in the urn)"/> + <spinbox type="integer" min="0" initial="10" id="n" label="n (Number of black balls in the urn)"/> + <spinbox type="integer" min="0" initial="5" id="k" label="k (Number of balls drawn from the urn)"/> </snippet> <include file="dist_snippets.xml"/> </snippets> diff --git a/rkward/plugins/distributions/log_normal.js b/rkward/plugins/distributions/log_normal.js index 772c877..a61ae46 100644 --- a/rkward/plugins/distributions/log_normal.js +++ b/rkward/plugins/distributions/log_normal.js @@ -1,5 +1,5 @@ include ("dist_common.js"); function getDistSpecifics () { - return initDistSpecifics (i18n ('Log Normal distribution'), 'lnorm', ["meanlog", "sdlog"]); + return initDistSpecifics (i18n ('Log Normal distribution'), 'lnorm', ["meanlog", "sdlog"], [0, undefined], continuous); } diff --git a/rkward/plugins/distributions/log_normal.xml b/rkward/plugins/distributions/log_normal.xml index e4df211..24d3164 100644 --- a/rkward/plugins/distributions/log_normal.xml +++ b/rkward/plugins/distributions/log_normal.xml @@ -7,8 +7,8 @@ </logic> <snippets> <snippet id="dist_options"> - <spinbox default_precision="2" type="real" initial="0" id="meanlog" label="meanlog (mean of the distribution on the log scale)"/> - <spinbox default_precision="2" type="real" min="0.000001" initial="1" id="sdlog" label="sdlog (standard deviation of the distribution on the log scale)"/> + <spinbox default_precision="1" type="real" initial="0" id="meanlog" label="meanlog (mean of the distribution on the log scale)"/> + <spinbox default_precision="1" type="real" min="0.000001" initial="1" id="sdlog" label="sdlog (standard deviation of the distribution on the log scale)"/> </snippet> <include file="dist_snippets.xml"/> </snippets> diff --git a/rkward/plugins/distributions/logistic.js b/rkward/plugins/distributions/logistic.js index 4c6fcdf..77b4052 100755 --- a/rkward/plugins/distributions/logistic.js +++ b/rkward/plugins/distributions/logistic.js @@ -1,5 +1,7 @@ include ("dist_common.js"); function getDistSpecifics () { - return initDistSpecifics (i18n ('Logistic distribution'), 'logis', ["location", "scale"]); + var loc = Number (getString ("location")); + var scale = Number (getString ("scale")); + return initDistSpecifics (i18n ('Logistic distribution'), 'logis', ["location", "scale"], [-5*scale+loc, 5*scale+loc], continuous); } diff --git a/rkward/plugins/distributions/logistic.xml b/rkward/plugins/distributions/logistic.xml index 41b5baf..639b6dd 100755 --- a/rkward/plugins/distributions/logistic.xml +++ b/rkward/plugins/distributions/logistic.xml @@ -7,8 +7,8 @@ </logic> <snippets> <snippet id="dist_options"> - <spinbox default_precision="2" type="real" initial="1" id="location" label="Location"/> - <spinbox default_precision="2" type="real" min="0" initial="1" id="scale" label="Scale"/> + <spinbox default_precision="1" type="real" initial="0" id="location" label="Location"/> + <spinbox default_precision="1" type="real" min="0" initial="1" id="scale" label="Scale"/> </snippet> <include file="dist_snippets.xml"/> </snippets> diff --git a/rkward/plugins/distributions/negative_binomial.js b/rkward/plugins/distributions/negative_binomial.js index 8a2f008..e388796 100755 --- a/rkward/plugins/distributions/negative_binomial.js +++ b/rkward/plugins/distributions/negative_binomial.js @@ -1,5 +1,7 @@ include ("dist_common.js"); function getDistSpecifics () { - return initDistSpecifics (i18n ('Negative Binomial distribution'), 'nbinom', ["size", "prob"]); + var size = Number (getString ("size")); + var prob = Number (getString ("prob")); + return initDistSpecifics (i18n ('Negative Binomial distribution'), 'nbinom', ["size", "prob"], [0, Math.ceil (size * 1.5 / prob)], discrete); } diff --git a/rkward/plugins/distributions/negative_binomial.xml b/rkward/plugins/distributions/negative_binomial.xml index 3e464cb..aa8a636 100755 --- a/rkward/plugins/distributions/negative_binomial.xml +++ b/rkward/plugins/distributions/negative_binomial.xml @@ -4,10 +4,13 @@ <help file="negative_binomial.rkh" /> <logic> <insert snippet="dialog_logic"/> + <script><![CDATA[ + gui.setValue ("ui_note.text", i18n (noquote ("Quantiles represents the number of failures in a sequence of Bernoulli trials before the target number of successes is reached."))); + ]]></script> </logic> <snippets> <snippet id="dist_options"> - <spinbox type="integer" min="0" initial="1" id="size" label="Target for number of successful trials"/> + <spinbox type="integer" min="0" initial="5" id="size" label="Target for number of successful trials"/> <spinbox default_precision="2" type="real" min="0" initial="0.5" max="1" id="prob" label="Probability of success in each trial"/> </snippet> <include file="dist_snippets.xml"/> diff --git a/rkward/plugins/distributions/normal.js b/rkward/plugins/distributions/normal.js index 4abf66d..d9e5518 100644 --- a/rkward/plugins/distributions/normal.js +++ b/rkward/plugins/distributions/normal.js @@ -1,5 +1,5 @@ include ("dist_common.js"); function getDistSpecifics () { - return initDistSpecifics (i18n ('Normal distribution'), 'norm', ["mean", "sd"], [-4, 4], true); + return initDistSpecifics (i18n ('Normal distribution'), 'norm', ["mean", "sd"], [-4, 4], continous); } diff --git a/rkward/plugins/distributions/plot_beta_distribution.rkh b/rkward/plugins/distributions/plot_beta_distribution.rkh index b2898f5..1afb251 100644 --- a/rkward/plugins/distributions/plot_beta_distribution.rkh +++ b/rkward/plugins/distributions/plot_beta_distribution.rkh @@ -20,6 +20,7 @@ Density and distribution function plots for the Beta distribution. </settings> <related> <ul> + <li><link href="rkward://component/beta_probabilities"/></li> <li><link href="rkward://rhelp/Beta"/></li> <li><link href="rkward://component/plot_options"/></li> <li><link href="rkward://rhelp/curve"/></li> diff --git a/rkward/plugins/distributions/plot_binomial_distribution.rkh b/rkward/plugins/distributions/plot_binomial_distribution.rkh index 77bb4c7..4e28fac 100644 --- a/rkward/plugins/distributions/plot_binomial_distribution.rkh +++ b/rkward/plugins/distributions/plot_binomial_distribution.rkh @@ -13,8 +13,8 @@ Density and distribution function plots for the Binomial distribution. <settings> <insert snippet="density_help"/> <insert snippet="discont_range_help"/> - <setting id="size">See R reference on Binomial distribution.</setting> - <setting id="prob">See R reference on Binomial distribution.</setting> + <setting id="size">Number of binomial trials</setting> + <setting id="prob">Probability of success in each trial</setting> <insert snippet="common_options_help"/> </settings> diff --git a/rkward/plugins/distributions/plot_cauchy_distribution.rkh b/rkward/plugins/distributions/plot_cauchy_distribution.rkh index 386ef6e..2c9a82c 100644 --- a/rkward/plugins/distributions/plot_cauchy_distribution.rkh +++ b/rkward/plugins/distributions/plot_cauchy_distribution.rkh @@ -13,8 +13,8 @@ Density and distribution function plots for the Cauchy distribution. <settings> <insert snippet="density_help"/> <insert snippet="cont_range_help"/> - <setting id="loc">See R reference on Cauchy distribution.</setting> - <setting id="scale">See R reference on Cauchy distribution.</setting> + <setting id="loc">Location parameter (median) of the Cauchy distribution</setting> + <setting id="scale">Scale parameter of the Cauchy distribution</setting> <insert snippet="common_options_help"/> </settings> <related> diff --git a/rkward/plugins/distributions/poisson.js b/rkward/plugins/distributions/poisson.js index eed2a57..fbffaa9 100644 --- a/rkward/plugins/distributions/poisson.js +++ b/rkward/plugins/distributions/poisson.js @@ -1,5 +1,6 @@ include ("dist_common.js"); function getDistSpecifics () { - return initDistSpecifics (i18n ('Poisson distribution'), 'pois', ["lambda"]); + var lambda = Number (getString ("lambda")); + return initDistSpecifics (i18n ('Poisson distribution'), 'pois', ["lambda"], [0, lambda + Math.sqrt (lambda)*3 + 1], discrete); } diff --git a/rkward/plugins/distributions/poisson.xml b/rkward/plugins/distributions/poisson.xml index c865d5b..683b553 100644 --- a/rkward/plugins/distributions/poisson.xml +++ b/rkward/plugins/distributions/poisson.xml @@ -4,10 +4,14 @@ <help file="poisson.rkh" /> <logic> <insert snippet="dialog_logic"/> + <script><![CDATA[ + gui.setValue ("ui_note.text", i18n (noquote ("Quantiles represents the number of events observed in a fixed number of trials (or a fixed period of time), where lamda is the expected (mean) number of such events."))); + ]]></script> + </logic> <snippets> <snippet id="dist_options"> - <spinbox default_precision="2" type="real" min="0" initial="1" id="lambda" label="Lambda"/> + <spinbox default_precision="1" type="real" min="0" initial="1" id="lambda" label="Lambda"/> </snippet> <include file="dist_snippets.xml"/> </snippets> diff --git a/rkward/plugins/distributions/t.js b/rkward/plugins/distributions/t.js index 682dc28..c7132af 100644 --- a/rkward/plugins/distributions/t.js +++ b/rkward/plugins/distributions/t.js @@ -1,5 +1,5 @@ include ("dist_common.js"); function getDistSpecifics () { - return initDistSpecifics (i18n ('t distribution'), 't', ["df", "ncp"]); + return initDistSpecifics (i18n ('t distribution'), 't', ["df", "ncp"], [], continuous); } diff --git a/rkward/plugins/distributions/t.xml b/rkward/plugins/distributions/t.xml index 286a19c..6b19b95 100644 --- a/rkward/plugins/distributions/t.xml +++ b/rkward/plugins/distributions/t.xml @@ -7,8 +7,8 @@ </logic> <snippets> <snippet id="dist_options"> - <spinbox default_precision="2" type="real" initial="1" id="df" min="0" label="Degrees of Freedom"/> - <spinbox default_precision="2" type="real" initial="0" id="ncp" min="0" label="non-centrality parameter"/> + <spinbox default_precision="1" type="real" initial="10" id="df" min="0" label="Degrees of Freedom"/> + <spinbox default_precision="1" type="real" initial="0" id="ncp" min="0" label="non-centrality parameter"/> </snippet> <include file="dist_snippets.xml"/> </snippets> diff --git a/rkward/plugins/distributions/tukey.js b/rkward/plugins/distributions/tukey.js index e224d99..32db2a0 100644 --- a/rkward/plugins/distributions/tukey.js +++ b/rkward/plugins/distributions/tukey.js @@ -1,5 +1,5 @@ include ("dist_common.js"); function getDistSpecifics () { - return initDistSpecifics (i18n ('Studentized Range (Tukey) distribution'), 'tukey', ["nmeans", "df", "nranges"]); + return initDistSpecifics (i18n ('Studentized Range (Tukey) distribution'), 'tukey', ["nmeans", "df", "nranges"], [0, undefined], continuous); } diff --git a/rkward/plugins/distributions/tukey.xml b/rkward/plugins/distributions/tukey.xml index 910f1a5..32236ea 100644 --- a/rkward/plugins/distributions/tukey.xml +++ b/rkward/plugins/distributions/tukey.xml @@ -8,8 +8,8 @@ <snippets> <snippet id="dist_options"> <spinbox min="1" type="integer" initial="2" id="nmeans" label="Sample size for range"/> - <input default_precision="2" initial="5" id="df" label="Degrees of freedom for s"/> - <spinbox default_precision="2" type="integer" initial="1" min="0" id="nranges" label="Number of groups whose maximum range is considered"/> + <spinbox default_precision="1" initial="5" id="df" label="Degrees of freedom for s"/> + <spinbox type="integer" initial="1" min="0" id="nranges" label="Number of groups whose maximum range is considered"/> </snippet> <include file="dist_snippets.xml"/> </snippets> diff --git a/rkward/plugins/distributions/uniform.js b/rkward/plugins/distributions/uniform.js index 09276b7..4b2fba2 100755 --- a/rkward/plugins/distributions/uniform.js +++ b/rkward/plugins/distributions/uniform.js @@ -1,5 +1,7 @@ include ("dist_common.js"); function getDistSpecifics () { - return initDistSpecifics (i18n ('Uniform distribution'), 'unif', ["min", "max"]); + var min = Number (getString ("min")); + var max = Number (getString ("max")); + return initDistSpecifics (i18n ('Uniform distribution'), 'unif', ["min", "max"], [min, max], continuous); } diff --git a/rkward/plugins/distributions/weibull.js b/rkward/plugins/distributions/weibull.js index c0832b6..dd74d2c 100755 --- a/rkward/plugins/distributions/weibull.js +++ b/rkward/plugins/distributions/weibull.js @@ -1,5 +1,5 @@ include ("dist_common.js"); function getDistSpecifics () { - return initDistSpecifics (i18n ('Weilbull distribution'), 'weibull', ["shape", "scale"]); + return initDistSpecifics (i18n ('Weilbull distribution'), 'weibull', ["shape", "scale"], [0, undefined], continuous); } diff --git a/rkward/plugins/distributions/wilcoxon.js b/rkward/plugins/distributions/wilcoxon.js index 7d94bd0..6dbaba7 100755 --- a/rkward/plugins/distributions/wilcoxon.js +++ b/rkward/plugins/distributions/wilcoxon.js @@ -1,5 +1,7 @@ include ("dist_common.js"); function getDistSpecifics () { - return initDistSpecifics (i18n ('Wilcox Rank Sum distribution'), 'wilcox', ["m", "n"]); + var m = Number (getString ("m")); + var n = Number (getString ("n")); + return initDistSpecifics (i18n ('Wilcox Rank Sum distribution'), 'wilcox', ["m", "n"], [0, m*n], discrete); } diff --git a/rkward/plugins/distributions/wilcoxon.xml b/rkward/plugins/distributions/wilcoxon.xml index 0d7ccba..d4c59b0 100755 --- a/rkward/plugins/distributions/wilcoxon.xml +++ b/rkward/plugins/distributions/wilcoxon.xml @@ -4,6 +4,8 @@ <help file="wilcoxon.rkh" /> <logic> <insert snippet="dialog_logic"/> + <set id="ui_note.visible" to="true"/> + <set id="ui_note.text" to="Quantiles correspond to the value of the Wilcoxon Rank Sum statistic, i.e. the number of pairs from sample x and y, for which y[j] is not greater than x[i]."/> </logic> <snippets> <snippet id="dist_options"> |