Commit 136f7a07 authored by Thomas Friedrichsmeier's avatar Thomas Friedrichsmeier
Browse files

Merge branch 'work/distributions'

parents ef0e4bb1 e44a0cdb
- Added power analysis plugin (already existed as separate plugin)
- TODO: add automated tests
- Reworked distribution calculator plugins
- Added power analysis plugin (already existed as separate plugin) - TODO: add automated tests
- Assume plugin .js files to be in utf-8 encoding; this allows using non-ascii characters in the generated code
- <matrix> element gains options min_rows and min_columns, and the details of fixed_width="true" have been improved
- Fixed: <valueslot>s were quirky with respect to showing as invalid
- Fix a hang-on-exit issue
......
......@@ -50,6 +50,7 @@ as Authors, publish date, the abstract, and Keywords -->
<year>2012</year>
<year>2013</year>
<year>2014</year>
<year>2015</year>
<holder>Thomas Friedrichsmeier</holder>
</copyright>
<!-- Translators: put here the copyright notice of the translation -->
......@@ -57,7 +58,7 @@ as Authors, publish date, the abstract, and Keywords -->
and in the FDL itself on how to use it. -->
<legalnotice>&FDLNotice;</legalnotice>
<date>2014-12-18</date>
<date>2015-01-22</date>
<releaseinfo>0.6.300</releaseinfo>
<abstract>
......@@ -535,6 +536,11 @@ This is a guide to writing plugins for &rkward;.
After reading this chapter, have a look at the <link linkend="rkwarddev"><application>rkwarddev</application> package</link> as well. It provides some &r; functions to create JavaScript code commonly used in &rkward;. It can also autodetect variables used in a plugin XML file and create basic JavaScript code from that for you to start with.
</para>
</tip>
<note>
<para>
Plugin .js files are assumed to be UTF-8 encoded. Be sure to check you editor's encoding, if using any non-ascii characters.
</para>
</note>
<para>
For the two variable t-test, the <filename>code.js</filename> file looks as follows (with comments in between):
</para>
......@@ -3319,7 +3325,9 @@ Child-elements:
<varlistentry>
<term>&lt;set&gt;</term>
<listitem><para>Set a property to a fixed value (of course, if you additionally connect the property to some other property, the value does not remain fixed). For instance, if you embed a plugin, but want to hide some of its elements, you might set the visibility property of those elements to false. Useful esp. for embedded/embedding plugins. Attributes:
<listitem><para>Set a property to a fixed value (of course, if you additionally connect the property to some other property, the value does not remain fixed). For instance, if you embed a plugin, but want to hide some of its elements, you might set the visibility property of those elements to false. Useful esp. for embedded/embedding plugins. Note: If there are several &lt;set&gt; elements
for a single <parameter>id</parameter>, the latest one to be defined takes precendence. This will sometimes be useful to rely on when using &lt;include&gt;d parts.
Attributes:
<variablelist>
<varlistentry>
<term><parameter>id</parameter></term>
......
......@@ -24,6 +24,11 @@ table {
border-spacing: 0px;
}
td {
padding-left: .5em;
padding-right: .5em;
}
/* TOC menu */
.RKTOC {
background-color: #eeeeff;
......
......@@ -710,11 +710,6 @@ void RKComponentBuilder::parseLogic (const QDomElement &element, XMLHelper &xml,
addConnection (xml.getStringAttribute (*it, "client", "#noid#", DL_WARNING), QString::null, xml.getStringAttribute (*it, "governor", "#noid#", DL_WARNING), QString::null, xml.getBoolAttribute (*it, "reconcile", false, DL_INFO), element);
}
// find initialize elements
children = xml.getChildElements (element, "set", DL_INFO);
for (it = children.constBegin (); it != children.constEnd (); ++it) {
initial_values.insert (xml.getStringAttribute (*it, "id", "#noid#", DL_WARNING), xml.getStringAttribute (*it, "to", "false", DL_WARNING));
}
children = xml.getChildElements (element, "dependency_check", DL_INFO);
for (it = children.constBegin (); it != children.constEnd (); ++it) {
RKComponentPropertyBool *dep = new RKComponentPropertyBool (component (), false);
......@@ -736,7 +731,13 @@ void RKComponentBuilder::parseLogic (const QDomElement &element, XMLHelper &xml,
if (!dummy.isNull ()) {
initial_values.insert (id, dummy);
}
// TODO add more options
}
// find initialize elements
children = xml.getChildElements (element, "set", DL_INFO);
for (it = children.constBegin (); it != children.constEnd (); ++it) {
// NOTE: It is by design that if there are several initializations for a single id, the latest one takes precedence. Useful in some cases of inclusion.
initial_values.insert (xml.getStringAttribute (*it, "id", "#noid#", DL_WARNING), xml.getStringAttribute (*it, "to", "false", DL_WARNING));
}
// find convert elements
......
This diff is collapsed.
include ("dist_common.js");
function getDistSpecifics () {
return initDistSpecifics (i18n ('Beta distribution'), 'beta', ["shape1", "shape2", "ncp"], [0, 1], continuous);
}
<!DOCTYPE rkhelp>
<document>
<snippets>
<include file="dist_help_snippets.xml"/>
</snippets>
<summary>
Provides a calculator for probabilities, quantiles, and densities in the Beta distribution.
</summary>
<insert snippet="dialog_usage"/>
<settings>
<insert snippet="dialog_settings"/>
<setting id="shape1">Parameter of the Beta distribution</setting>
<setting id="shape2">Parameter of the Beta distribution</setting>
<setting id="ncp">Non-centrality parameter</setting>
</settings>
<related>
<ul>
<li><link href="rkward://rhelp/Beta"/></li>
<li><link href="rkward://component/rkward/plot_beta_distribution"/></li>
</ul>
</related>
</document>
<!DOCTYPE rkplugin>
<document>
<code file="beta_probabilities.js" />
<code file="beta.js" />
<help file="beta.rkh" />
<logic>
<insert snippet="dialog_logic"/>
</logic>
<snippets>
<snippet id="dist_options">
<spinbox default_precision="2" type="real" initial="1" id="shape1" min="0" label="Shape 1"/>
<spinbox default_precision="2" type="real" initial="1" id="shape2" min="0" label="Shape 2"/>
<spinbox default_precision="2" type="real" min="0" initial="0" id="ncp" label="non-centrality parameter (ncp)"/>
<spinbox default_precision="1" type="real" initial="1" id="shape1" min="0" label="Shape 1"/>
<spinbox default_precision="1" type="real" initial="1" id="shape2" min="0" label="Shape 2"/>
<spinbox default_precision="1" type="real" min="0" initial="0" id="ncp" label="non-centrality parameter (ncp)"/>
</snippet>
<include file="dist_snippets.xml"/>
</snippets>
<dialog label="Beta probability" >
<insert snippet="probabilities_layout"/>
<dialog label="Beta distribution calculator" >
<insert snippet="dialog_layout"/>
</dialog>
</document>
// globals
var q;
function calculate () {
q = "c (" + getString ("q").replace (/[, ]+/g, ", ") + ")";
echo ('result <- (pbeta (q = ' + q + ', shape1 = ' + getValue ("shape1") + ', shape2 = ' + getValue ("shape2") + ', ncp = ' + getValue ("ncp") + ', ' + getValue ("tail") + ', ' + getValue("logp") + '))\n');
}
function printout () {
echo ('rk.header ("Beta probability", list ("Vector of quantiles", "' + q + '", "Shape 1", "' + getValue ("shape1") + '", "Shape 2", "' + getValue ("shape2") + '", "non-centrality parameter (ncp)", "' + getValue ("ncp") + '", "Tail", "' + getValue ("tail") + '", "Probabilities p are given as", "' + getValue ("logp") + '"));\n');
echo ('rk.results (result, titles="Beta probability")\n');
}
// globals
var p;
function calculate () {
p = "c (" + getString ("p").replace (/[, ]+/g, ", ") + ")";
echo ('result <- (qbeta (p = ' + p + ', shape1 = ' + getValue ("shape1") + ', shape2 = ' + getValue ("shape2") + ', ncp = ' + getValue ("ncp") + ', ' + getValue ("tail") + ', ' + getValue("logp") + '))\n');
}
function printout () {
echo ('rk.header ("Beta quantiles", list ("Vector of probabilities", "' + p + '", "Shape 1", "' + getValue ("shape1") + '", "Shape 2", "' + getValue ("shape2") + '", "non-centrality parameter (ncp)", "' + getValue ("ncp") + '", "Tail", "' + getValue ("tail") + '", "Probabilities p are given as", "' + getValue ("logp") + '"));\n');
echo ('rk.results (result, titles="Beta quantiles")\n');
}
<!DOCTYPE rkplugin>
<document>
<code file="beta_quantiles.js" />
<snippets>
<snippet id="dist_options">
<spinbox default_precision="2" type="real" initial="1" id="shape1" min="0" label="Shape 1"/>
<spinbox default_precision="2" type="real" initial="1" id="shape2" min="0" label="Shape 2"/>
<spinbox default_precision="2" type="real" min="0" initial="0" id="ncp" label="non-centrality parameter (ncp)"/>
</snippet>
<include file="dist_snippets.xml"/>
</snippets>
<dialog label="Beta quantiles" >
<insert snippet="quantiles_layout"/>
</dialog>
</document>
include ("dist_common.js");
function getDistSpecifics () {
var dist = initDistSpecifics (i18n ('Binomial distribution'), 'binom', ["size", "prob"], [0, getString ("size")], discrete);
return dist;
}
<!DOCTYPE rkhelp>
<document>
<snippets>
<include file="dist_help_snippets.xml"/>
</snippets>
<summary>
Provides a calculator for probabilities, quantiles, and densities in the binonmial distribution.
Note: For the binomial distribution, quantiles can be interpreted as number of successes in the given number of trials.
</summary>
<insert snippet="dialog_usage"/>
<settings>
<insert snippet="dialog_settings"/>
<setting id="size">Number of binomial trials</setting>
<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, here.</setting>
</settings>
<related>
<ul>
<li><link href="rkward://rhelp/Binomial"/></li>
<li><link href="rkward://component/rkward/plot_binomial_distribution"/></li>
</ul>
</related>
</document>
<!DOCTYPE rkplugin>
<document>
<code file="binomial_quantiles.js" />
<code file="binomial.js" />
<help file="binomial.rkh" />
<logic>
<insert snippet="dialog_logic"/>
<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">
<spinbox default_precision="2" type="integer" initial="1" id="size" min="1" label="Binomial trials"/>
<spinbox type="integer" initial="10" id="size" min="1" label="Binomial trials"/>
<spinbox default_precision="2" type="real" initial="0.5" id="prob" min="0" max="1" label="Probability of success"/>
</snippet>
<include file="dist_snippets.xml"/>
</snippets>
<dialog label="Binomial quantiles" >
<insert snippet="quantiles_layout"/>
<dialog label="Binomial probabilities, quantiles, densities" >
<insert snippet="dialog_layout"/>
</dialog>
</document>
// globals
var p;
function calculate () {
p = "c (" + getString ("p").replace (/[, ]+/g, ", ") + ")";
echo ('result <- (qbinom (p = ' + p + ', size = ' + getValue ("size") + ', prob = ' + getValue ("prob") + ', ' + getValue ("tail") + ', ' + getValue ("logp") + '))\n');
}
function printout () {
//produce the output
echo ('rk.header ("Binomial quantile", list ("Vector of quantiles probabilities", "' + p + '", "Binomial trials", "' + getValue ("size") + '", "Probability of success", "' + getValue ("prob") + '", "Tail", "' + getValue ("tail") + '", "Probabilities p are given as", "' + getValue ("logp") + '"));\n');
echo ('rk.results (result, titles="Binomial quantiles")\n');
}
// globals
var q;
function calculate () {
q = "c (" + getString ("q").replace (/[, ]+/g, ", ") + ")";
echo ('result <- (pbinom (q = ' + q + ', size = ' + getValue ("size") + ', prob = ' + getValue ("prob") + ', ' + getValue ("tail") + ', ' + getValue ("logp") + '))\n');
}
function printout () {
echo ('rk.header ("Binomial tail probability", list ("Vector of quantiles", "' + q + '", "Binomial trials", "' + getValue ("size") + '", "Probability of success", "' + getValue ("prob") + '", "Tail", "' + getValue ("tail") + '", "Probabilities p are given as", "' + getValue ("logp") + '"));\n');
echo ('rk.results (result, titles="Binomial tail probabilities")\n');
}
<!DOCTYPE rkplugin>
<document>
<code file="binomial_tail_probabilities.js" />
<snippets>
<snippet id="dist_options">
<spinbox default_precision="2" type="integer" initial="1" id="size" min="1" label="Binomial trials"/>
<spinbox default_precision="2" type="real" initial="0.5" id="prob" min="0" max="1" label="Probability of success"/>
</snippet>
<include file="dist_snippets.xml"/>
</snippets>
<dialog label="Binomial tail probability" >
<insert snippet="probabilities_layout"/>
</dialog>
</document>
include ("dist_common.js");
function getDistSpecifics () {
return initDistSpecifics (i18n ('Cauchy distribution'), 'cauchy', ["location", "scale"], [], continuous);
}
<!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>
<!DOCTYPE rkplugin>
<document>
<code file="cauchy_probabilities.js" />
<code file="cauchy.js" />
<help file="cauchy.rkh" />
<logic>
<insert snippet="dialog_logic"/>
</logic>
<snippets>
<snippet id="dist_options">
<spinbox default_precision="2" type="real" initial="0" id="location" label="Location"/>
......@@ -8,7 +12,7 @@
</snippet>
<include file="dist_snippets.xml"/>
</snippets>
<dialog label="Cauchy probabilities" >
<insert snippet="probabilities_layout"/>
<dialog label="Cauchy distribution calculator" >
<insert snippet="dialog_layout"/>
</dialog>
</document>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment