[rkward-cvs] [rkward/work/distributions] rkward/plugins/distributions: Start experimenting with a re-design of the distributions plugins.

Thomas Friedrichsmeier thomas.friedrichsmeier at ruhr-uni-bochum.de
Mon Jan 19 19:56:19 UTC 2015


Git commit b03978d7cf79287bce8f5e645777296429e8ef5f by Thomas Friedrichsmeier.
Committed on 19/01/2015 at 19:55.
Pushed by tfry into branch 'work/distributions'.

Start experimenting with a re-design of the distributions plugins.

M  +1    -1    rkward/plugins/distributions/binomial_quantiles.js
M  +5    -1    rkward/plugins/distributions/binomial_tail_probabilities.xml
M  +40   -34   rkward/plugins/distributions/dist_snippets.xml

http://commits.kde.org/rkward/b03978d7cf79287bce8f5e645777296429e8ef5f

diff --git a/rkward/plugins/distributions/binomial_quantiles.js b/rkward/plugins/distributions/binomial_quantiles.js
index 7878b0e..ae81961 100644
--- a/rkward/plugins/distributions/binomial_quantiles.js
+++ b/rkward/plugins/distributions/binomial_quantiles.js
@@ -4,7 +4,7 @@ var p;
 function calculate () {
 	p = "c (" + getList ("p.0").join (", ") + ")";
 
-	echo ('result <- (qbinom (p = ' + p + ', size = ' + getValue ("size") + ', prob = ' + getValue ("prob") + ', ' + getValue ("tail") + ', ' + getValue ("logp") + '))\n');
+	echo ('result <- (qbinom (p = ' + p + ', size = ' + getValue ("size") + ', prob = ' + getValue ("prob") + ', ' + getValue ("lower") + ', ' + getValue ("logp") + '))\n');
 }
 
 function printout () {
diff --git a/rkward/plugins/distributions/binomial_tail_probabilities.xml b/rkward/plugins/distributions/binomial_tail_probabilities.xml
index 9404e98..79842c6 100644
--- a/rkward/plugins/distributions/binomial_tail_probabilities.xml
+++ b/rkward/plugins/distributions/binomial_tail_probabilities.xml
@@ -1,14 +1,18 @@
 <!DOCTYPE rkplugin>
 <document>
 	<code file="binomial_tail_probabilities.js" />
+	<logic>
+		<insert snippet="dialog_logic"/>
+	</logic>
 	<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>
+		<snippet id="ui_note"><text>Note: For the binomial distribution, quantiles can be interpreted as number of successes.</text></snippet>
 		<include file="dist_snippets.xml"/>
 	</snippets>
 	<dialog label="Binomial tail probability" >
-		<insert snippet="probabilities_layout"/>
+		<insert snippet="dialog_layout"/>
 	</dialog>
 </document>
diff --git a/rkward/plugins/distributions/dist_snippets.xml b/rkward/plugins/distributions/dist_snippets.xml
index 8c8c8ed..c1f4f2e 100644
--- a/rkward/plugins/distributions/dist_snippets.xml
+++ b/rkward/plugins/distributions/dist_snippets.xml
@@ -1,38 +1,44 @@
-<!-- Snippets for the XYZ quantiles and probabilities plugins -->
+<!-- Snippets for the distribution calculator plugins -->
 <document>
-	<snippet id="probabilities_layout">
-		<row>
-			<column>
-				<input required="true" initial="0.95" id="q" label="Vector of quantiles"/>
-				<insert snippet="dist_options"/>
-			</column>
-			<column>
-				<radio id="tail" label="Choose type of probability" >
-					<option value="lower.tail=TRUE" label="lower tail" />
-					<option value="lower.tail=FALSE" label="upper tail" />
-				</radio>
-				<radio id="logp" label="return probabilities p as:" >
-					<option value="log.p = FALSE" label="not log(p)" />
-					<option value="log.p = TRUE" label="log(p)" />
-				</radio>
-				<stretch/>
-			</column>
-		</row>
+	<snippet id="dialog_logic">
+		<convert id="do_d" mode="equals" sources="mode.string" standard="d"/>
+		<convert id="do_q" mode="equals" sources="mode.string" standard="q"/>
+
+		<connect client="lower.enabled" governor="do_d.not"/>
+		<connect client="logp.enabled" governor="do_d.not"/>
+		<connect client="q.visible" governor="do_q.not"/>
+		<connect client="p.visible" governor="do_q"/>
 	</snippet>
-	<snippet id="quantiles_layout">
-		<row>
-			<column>
-				<matrix id="p" columns="1" min_rows="1" fixed_width="true" allow_user_resize_columns="false" mode="real" label="Vector of probabilities" horiz_headers=""/>
-				<radio id="tail" label="Type of probability" >
-					<option value="lower.tail=TRUE" label="lower tail" />
-					<option value="lower.tail=FALSE" label="upper tail" />
-				</radio>
-				<checkbox id="logp" label="probabilities p are given as log(p)" value="log.p = TRUE" value_unchecked="log.p = FALSE"/>
-			</column>
-			<column>
-				<insert snippet="dist_options"/>
-				<stretch/>
-			</column>
-		</row>
+	<snippet id="dialog_layout">
+		<dropdown id="mode" label="Mode">
+			<option value="p" label="Calculate probabilities for given quantiles"/>
+			<option value="d" label="Calculate densities at given quantiles"/>
+			<option value="q" label="Calculate quantiles for given probabilities"/>
+		</dropdown>
+			<row>
+				<frame>
+					<column>
+						<matrix columns="1" allow_user_resize_columns="false" min_rows="1" required="true" mode="real" fixed_width="true" min="0" id="q" label="Vector of quantiles"/>
+						<matrix columns="1" allow_user_resize_columns="false" min_rows="1" required="true" mode="real" fixed_width="true" id="p" label="Vector of probabilities"/>
+						<checkbox id="logp" label="log probabilities" />
+						<checkbox id="lower" label="Lower tail" checked="true" />
+						<stretch/>
+					</column>
+				</frame>
+				<frame>
+					<column>
+						<insert snippet="dist_options"/>
+						<stretch/>
+					</column>
+				</frame>
+			</row>
+			<insert snippet="ui_note"/>
+	</snippet>
+	<snippet id="dialog_settings">
+		<setting id="mode">Specify the quantitiy to be calculated (probabilites, densities, or quantiles), and the quantity given (probabilities or quantiles)</setting>
+		<setting id="q">When calculating densities or probabilites, specify one or more quantiles.</setting>
+		<setting id="p">When calculating quantiles, specify one or more probabilities (optionally logarithmic; see below).</setting>
+		<setting id="logp">When calculating probabilities, return these as log (p). When specifying probabilites, these are supplied as log (p).</setting>
+		<setting id="lower">If checked (the default) probabilities are given are P[X ≤ x]. Otherwise (upper tail) probabilities are  P[X > x]</setting>
 	</snippet>
 </document>


------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
rkward-cvs mailing list
rkward-cvs at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rkward-cvs


More information about the rkward-tracker mailing list