[rkward-cvs] SF.net SVN: rkward: [1872] trunk/rkward/rkward/plugins/distributions

tfry at users.sourceforge.net tfry at users.sourceforge.net
Mon May 7 15:52:46 UTC 2007


Revision: 1872
          http://svn.sourceforge.net/rkward/?rev=1872&view=rev
Author:   tfry
Date:     2007-05-07 08:52:46 -0700 (Mon, 07 May 2007)

Log Message:
-----------
Small fix, and convert cauchy and chi squared

Modified Paths:
--------------
    trunk/rkward/rkward/plugins/distributions/plot_cauchy_distribution.php
    trunk/rkward/rkward/plugins/distributions/plot_cauchy_distribution.rkh
    trunk/rkward/rkward/plugins/distributions/plot_cauchy_distribution.xml
    trunk/rkward/rkward/plugins/distributions/plot_chi_squared_distribution.php
    trunk/rkward/rkward/plugins/distributions/plot_chi_squared_distribution.rkh
    trunk/rkward/rkward/plugins/distributions/plot_chi_squared_distribution.xml

Modified: trunk/rkward/rkward/plugins/distributions/plot_cauchy_distribution.php
===================================================================
--- trunk/rkward/rkward/plugins/distributions/plot_cauchy_distribution.php	2007-05-07 15:23:52 UTC (rev 1871)
+++ trunk/rkward/rkward/plugins/distributions/plot_cauchy_distribution.php	2007-05-07 15:52:46 UTC (rev 1872)
@@ -1,58 +1,29 @@
 <?
-function preprocess () {
-}
+include ("plot_dist_common.php");
 
-function calculate () {
-}
+function getParameters () {
+	global $options;
 
-function printout () {
-	doPrintout (true);
-}
+	$options['loc'] = getRK_val ("loc");
+	$options['scale'] = getRK_val ("scale");
+	getContRangeParameters ();
 
-function preview () {
-	preprocess ();
-	calculate ();
-	doPrintout (false);
-}
-
-function doPrintout ($final) {
-
-	$fun = getRK_val ("function");
-	$log_option = "";
-	if ($fun == "dcauchy") {
-		$label = "density";
-		$lower_tag = "";
-		$tail_tag = "";
-		if (getRK_val ("log")) $log_option = ", log=TRUE";
+	if ($options['is_density']) {
+		$options['fun'] = "dcauchy";
 	} else {
-		$label = "distribution";
-		if (getRK_val("lower") == "1") {
-			$lower_tag = ", lower.tail = TRUE";
-			$tail_tag = ", \"Tail\",\"Lower\"";
-		} else {
-			$lower_tag = ", lower.tail = FALSE";
-			$tail_tag = ", \"Tail\",\"Upper\"";
-		}
-		if (getRK_val ("log")) $log_option = ", log.p=TRUE";
+		$options['fun'] = "pcauchy";
 	}
-	if (getRK_val ("log") == "1") $log_label="logarithmic";
-	else $log_label="normal";
-	$n = getRK_val ("n");
-	$min = getRK_val ("min");
-	$max = getRK_val ("max");
-	$loc = getRK_val ("loc");
-	$scale = getRK_val ("scale");
+}
 
-	if ($final) { ?>
-rk.header ("Cauchy <? echo ($label); ?> function", list ("Number of Observations", "<? echo ($n); ?>", "Lower quantile", "<? echo ($min); ?>","Upper quantile", "<? echo ($max); ?>", "Location", "<? echo ($loc); ?>", "Scale", "<? echo ($scale); ?>", "Scaling", "<? echo ($log_label); ?>"<? echo ($tail_tag); ?>, "Function", "<? echo ($fun); ?>"));
+function doHeader () {
+	global $options;
 
-rk.graph.on ()
-<? }
-?>
-try (curve (<? echo ($fun); ?> (x, location = <? echo ($loc); ?>, scale = <? echo ($scale); ?><? echo ($log_option) ?><? echo ($lower_tag); ?>), from=<? echo ($min); ?>, to=<? echo ($max); ?>, n=<? echo ($n); ?><? getRK ("plotoptions.code.printout"); ?>))
+	echo ('rk.header ("Cauchy ' . $options['label'] . ' function", list ("Number of Observations", "' . $options['n'] . '", "Lower quantile", "' . $options['min'] . '", "Upper quantile", "' . $options['max'] . '", "Location", "' . $options['loc'] . '", "Scale", "' . $options['scale'] . '"' . $options['log_label'] . $options['tail_label'] . ', "Function", "' . $options['fun'] . '"));' . "\n");
+}
 
-<?	if ($final) { ?>
-rk.graph.off ()
-<? }
+function doFunCall () {
+	global $options;
+
+	echo ($options['fun'] . '(x, location=' . $options['loc'] . ', scale=' . $options['scale'] . $options['log_option'] . $options['tail_option'] . ')'); 
 }
 ?>

Modified: trunk/rkward/rkward/plugins/distributions/plot_cauchy_distribution.rkh
===================================================================
--- trunk/rkward/rkward/plugins/distributions/plot_cauchy_distribution.rkh	2007-05-07 15:23:52 UTC (rev 1871)
+++ trunk/rkward/rkward/plugins/distributions/plot_cauchy_distribution.rkh	2007-05-07 15:52:46 UTC (rev 1872)
@@ -1,32 +1,25 @@
 <!DOCTYPE rkhelp>
 <document>
+	<snippets>
+		<include file="plot_dist_common_snippets.xml"/>
+	</snippets>
+
 	<summary>
 Density and distribution function plots for the Cauchy distribution.
 	</summary>
 
-	<usage>
-Choose appropriate values for the various parameters of the distribution and select the type of function. The "Submit" button will export the plot to the "Output" window. To dynamically visualise the plot check the "Preview" box.
-	</usage>
+	<insert snippet="general_usage_help"/>
 
 	<settings>
-		<setting id="function">
-			<li> Density Function, or </li>
-			<li> Distribution Function </li>
-		</setting>
-		<setting id="n">Number of observations (points) for constructing the plot (n).</setting>
-		<setting id="min">Smallest value at which the function is to be plotted.</setting>
-		<setting id="max">Largest value at which the function is to be plotted. So, the function will be evaluated at 'n' equally spaced points between the lower quantile and the upper quantile (inclusive of end points).</setting>
+		<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="log">See the description given on Plot Beta distribution help page.</setting>
-		<setting id="lower">See the description given on Plot Beta  distribution help page.</setting>
-		<setting id="preview">See the description given on Plot Beta  distribution help page.</setting>
-		<setting id="plotoptions">Various plotting parameter settings for the plot. See the help page of "Plot Options" for more details.</setting>
+		<insert snippet="common_options_help"/>
 	</settings>
 	<related>
 		<ul>
 			<li><link href="rkward://rhelp/Cauchy"/></li>
-			<li><link href="rkward://component/plot_beta_distribution"/></li>
 			<li><link href="rkward://component/plot_options"/></li>
 			<li><link href="rkward://rhelp/curve"/></li>
 		</ul>

Modified: trunk/rkward/rkward/plugins/distributions/plot_cauchy_distribution.xml
===================================================================
--- trunk/rkward/rkward/plugins/distributions/plot_cauchy_distribution.xml	2007-05-07 15:23:52 UTC (rev 1871)
+++ trunk/rkward/rkward/plugins/distributions/plot_cauchy_distribution.xml	2007-05-07 15:52:46 UTC (rev 1872)
@@ -1,46 +1,29 @@
 <!DOCTYPE rkplugin>
-<!--This is the simple "Plot cauchy probabilities" plugin--><document>
+<document>
 	<code file="plot_cauchy_distribution.php" />
 	<help file="plot_cauchy_distribution.rkh" />
 	<logic>
-		<convert id="dodist" mode="equals" sources="function.string" standard="pcauchy" />
-		<connect client="lower.enabled" governor="dodist" />
-		<set id="plotoptions.allow_log" to="false"/>
+		<insert snippet="common_logic"/>
 	</logic>
+	<snippets>
+		<snippet id="range_options">
+			<spinbox type="integer" id="n" min="2" initial="100" label="Number of Observations" />
+			<frame label="Range" >
+				<spinbox default_precision="2" type="real" id="min" initial="-3.29" label="Lower quantile" />
+				<spinbox default_precision="2" type="real" id="max" initial="3.29" label="Upper quantile" />
+			</frame>
+		</snippet>
+		<snippet id="dist_options">
+			<frame label="Parameters">
+				<frame label="Parameters">
+					<spinbox default_precision="2" type="real" id="loc" initial="0" label="Location" />
+					<spinbox default_precision="2" type="real" id="scale" initial="1" min="0.01" label="Scale" />
+				</frame>
+			</frame>
+		</snippet>
+		<include file="plot_dist_common_snippets.xml"/>
+	</snippets>
 	<dialog label="Plot Cauchy probabilities" >
-		<tabbook>
-			<tab label="Plot Cauchy probabilities" >
-				<row>
-					<column>
-						<row>
-							<spinbox type="integer" id="n" min="2" initial="100" label="Number of Observations" />
-						</row>
-						<row>
-							<frame label="Range" >
-								<spinbox default_precision="2" type="real" id="min" initial="-3.29" label="Lower quantile" />
-								<spinbox default_precision="2" type="real" id="max" initial="3.29" label="Upper quantile" />
-							</frame>
-						</row>
-						<row>
-							<frame label="Parameters">
-							<spinbox default_precision="2" type="real" id="loc" initial="0" label="Location" />
-							<spinbox default_precision="2" type="real" id="scale" initial="1" min="0.01" label="Scale" />
-						</frame>
-						</row>
-					</column>
-					<column>
-						<radio id="function" label="Choose type of function plot" >
-							<option value="dcauchy" label="Plot density function" />
-							<option value="pcauchy" label="Plot distribution" />
-						</radio>
-						<checkbox id="log" label="Logarithmic" value="1" value_unchecked="0"/>
-						<checkbox id="lower" label="Lower Tail" value="1" value_unchecked="0" checked="true"/>
-						<stretch/>
-						<preview id="preview" label="Preview"/>
-						<embed id="plotoptions" component="rkward::plot_options" as_button="true" label="Plot Options" />
-					</column>
-				</row>
-			</tab>
-		</tabbook>
+		<include file="plot_dist_common_dialog_layout.xml"/>
 	</dialog>
 </document>

Modified: trunk/rkward/rkward/plugins/distributions/plot_chi_squared_distribution.php
===================================================================
--- trunk/rkward/rkward/plugins/distributions/plot_chi_squared_distribution.php	2007-05-07 15:23:52 UTC (rev 1871)
+++ trunk/rkward/rkward/plugins/distributions/plot_chi_squared_distribution.php	2007-05-07 15:52:46 UTC (rev 1872)
@@ -1,58 +1,29 @@
 <?
-function preprocess () {
-}
+include ("plot_dist_common.php");
 
-function calculate () {
-}
+function getParameters () {
+	global $options;
 
-function printout () {
-	doPrintout (true);
-}
+	$options['df'] = getRK_val ("df");
+	$options['ncp'] = getRK_val ("ncp");
+	getContRangeParameters ();
 
-function preview () {
-	preprocess ();
-	calculate ();
-	doPrintout (false);
-}
-
-function doPrintout ($final) {
-
-	$fun = getRK_val ("function");
-	$log_option = "";
-	if ($fun == "dchisq") {
-		$label = "density";
-		$lower_tag = "";
-		$tail_tag = "";
-		if (getRK_val ("log")) $log_option = ", log=TRUE";
+	if ($options['is_density']) {
+		$options['fun'] = "dchisq";
 	} else {
-		$label = "distribution";
-		if (getRK_val("lower") == "1") {
-			$lower_tag = ", lower.tail = TRUE";
-			$tail_tag = ", \"Tail\",\"Lower\"";
-		} else {
-			$lower_tag = ", lower.tail = FALSE";
-			$tail_tag = ", \"Tail\",\"Upper\"";
-		}
-		if (getRK_val ("log")) $log_option = ", log.p=TRUE";
+		$options['fun'] = "pchisq";
 	}
-	if (getRK_val ("log") == "1") $log_label="logarithmic";
-	else $log_label="normal";
-	$n = getRK_val ("n");
-	$min = getRK_val ("min");
-	$max = getRK_val ("max");
-  $ncp = getRK_val ("ncp");
-	$df = getRK_val ("df");
+}
 
-	if ($final) { ?>
-rk.header ("Chisquare <? echo ($label); ?> function", list ("Number of Observations", "<? echo ($n); ?>", "Lower quantile", "<? echo ($min); ?>", "Upper quantile", "<? echo ($max); ?>", "Degrees of freedom", "<? echo ($df); ?>", "Non-centrality", "<? echo ($ncp); ?>", "Scaling", "<? echo ($log_label); ?>"<? echo ($tail_tag); ?>, "Function", "<? echo ($fun); ?>"));
+function doHeader () {
+	global $options;
 
-rk.graph.on ()
-<? }
-?>
-try (curve (<? echo ($fun); ?> (x, df = <? echo ($df); ?>, ncp = <? echo ($ncp); ?><? echo ($log_option) ?><? echo ($lower_tag); ?>), from=<? echo ($min); ?>, to=<? echo ($max); ?>, n=<? echo ($n); ?><? getRK ("plotoptions.code.printout"); ?>))
+	echo ('rk.header ("Chisquare ' . $options['label'] . ' function", list ("Number of Observations", "' . $options['n'] . '", "Lower quantile", "' . $options['min'] . '", "Upper quantile", "' . $options['max'] . '", "Degrees of freedom", "' . $options['df'] . '", "Non-centrality parameter", "' . $options['ncp'] . '"' . $options['log_label'] . $options['tail_label'] . ', "Function", "' . $options['fun'] . '"));' . "\n");
+}
 
-<?	if ($final) { ?>
-rk.graph.off ()
-<? }
+function doFunCall () {
+	global $options;
+
+	echo ($options['fun'] . '(x, df=' . $options['df'] . ', ncp=' . $options['ncp'] . $options['log_option'] . $options['tail_option'] . ')');
 }
 ?>

Modified: trunk/rkward/rkward/plugins/distributions/plot_chi_squared_distribution.rkh
===================================================================
--- trunk/rkward/rkward/plugins/distributions/plot_chi_squared_distribution.rkh	2007-05-07 15:23:52 UTC (rev 1871)
+++ trunk/rkward/rkward/plugins/distributions/plot_chi_squared_distribution.rkh	2007-05-07 15:52:46 UTC (rev 1872)
@@ -1,32 +1,26 @@
 <!DOCTYPE rkhelp>
 <document>
+	<snippets>
+		<include file="plot_dist_common_snippets.xml"/>
+	</snippets>
+
 	<summary>
 Density and distribution function plots for the Chi-squared distribution.
 	</summary>
 
-	<usage>
-Choose appropriate values for the various parameters of the distribution and select the type of function. The "Submit" button will export the plot to the "Output" window. To dynamically visualise the plot check the "Preview" box.
-	</usage>
+	<insert snippet="general_usage_help"/>
 
 	<settings>
-		<setting id="function">
-			<li> Density Function, or </li>
-			<li> Distribution Function </li>
-		</setting>
-		<setting id="n">Number of observations (points) for constructing the plot (n).</setting>
-		<setting id="min">Smallest value at which the function is to be plotted.</setting>
-		<setting id="max">Largest value at which the function is to be plotted. So, the function will be evaluated at 'n' equally spaced points between the lower quantile and the upper quantile (inclusive of end points).</setting>
+		<insert snippet="density_help"/>
+		<insert snippet="cont_range_help"/>
 		<setting id="df">See R reference on Chi-squared distribution.</setting>
 		<setting id="ncp">See R reference on Chi-squared distribution.</setting>
-		<setting id="log">See the description given on Plot Beta distribution help page.</setting>
-		<setting id="lower">See the description given on Plot Beta  distribution help page.</setting>
-		<setting id="preview">See the description given on Plot Beta  distribution help page.</setting>
-		<setting id="plotoptions">Various plotting parameter settings for the plot. See the help page of "Plot Options" for more details.</setting>
+		<insert snippet="common_options_help"/>
 	</settings>
+
 	<related>
 		<ul>
 			<li><link href="rkward://rhelp/Chisquare"/></li>
-			<li><link href="rkward://component/plot_beta_distribution"/></li>
 			<li><link href="rkward://component/plot_options"/></li>
 			<li><link href="rkward://rhelp/curve"/></li>
 		</ul>

Modified: trunk/rkward/rkward/plugins/distributions/plot_chi_squared_distribution.xml
===================================================================
--- trunk/rkward/rkward/plugins/distributions/plot_chi_squared_distribution.xml	2007-05-07 15:23:52 UTC (rev 1871)
+++ trunk/rkward/rkward/plugins/distributions/plot_chi_squared_distribution.xml	2007-05-07 15:52:46 UTC (rev 1872)
@@ -3,44 +3,25 @@
 	<code file="plot_chi_squared_distribution.php" />
 	<help file="plot_chi_squared_distribution.rkh" />
 	<logic>
-		<convert id="dodist" mode="equals" sources="function.string" standard="pchisq" />
-		<connect client="lower.enabled" governor="dodist" />
-		<set id="plotoptions.allow_log" to="false"/>
+		<insert snippet="common_logic"/>
 	</logic>
+	<snippets>
+		<snippet id="range_options">
+			<spinbox type="integer" id="n" initial="100" min="1" label="Number of Observations" />
+			<frame label="Range" >
+				<spinbox default_precision="2" type="real" id="min" min="0" initial="0.30" label="Lower quantile" />
+				<spinbox default_precision="2" type="real" id="max" min="0" initial="24.10" label="Upper quantile" />
+			</frame>
+		</snippet>
+		<snippet id="dist_options">
+			<frame label="Parameters">
+				<spinbox default_precision="2" type="real" min="0.01" id="df" initial="4.0" label="Degrees of freedom" />
+				<spinbox default_precision="2" type="real" min="0" id="ncp" initial="0" label="Non-centrality parameter" />
+			</frame>
+		</snippet>
+		<include file="plot_dist_common_snippets.xml"/>
+	</snippets>
 	<dialog label="Plot Chi-squared probabilities" >
-		<tabbook>
-			<tab label="Plot Chi-squared probabilities" >
-				<row>
-					<column>
-						<row>
-							<spinbox type="integer" id="n" initial="100" min="1" label="Number of Observations" />
-						</row>
-						<row>
-							<frame label="Range" >
-								<spinbox default_precision="2" type="real" id="min" min="0" initial="0.30" label="Lower quantile" />
-								<spinbox default_precision="2" type="real" id="max" min="0" initial="24.10" label="Upper quantile" />
-							</frame>
-						</row>
-							<row>
-						<frame label="Parameters">
-								<spinbox default_precision="2" type="real" min="0.01" id="df" initial="4.0" label="Degrees of freedom" />
-								<spinbox default_precision="2" type="real" min="0" id="ncp" initial="0" label="Non-centrality parameter" />
-						</frame>
-							</row>
-					</column>
-					<column>
-						<radio id="function" label="Choose type of function plot" >
-							<option value="dchisq" label="Plot density function" />
-							<option value="pchisq" label="Plot distribution" />
-						</radio>
-						<checkbox id="log" label="Logarithmic" value="1" value_unchecked="0"/>
-						<checkbox id="lower" label="Lower Tail" value="1" value_unchecked="0" checked="true"/>
-						<stretch/>
-						<preview id="preview" label="Preview"/>
-						<embed id="plotoptions" component="rkward::plot_options" as_button="true" label="Plot Options" />
-					</column>
-				</row>
-			</tab>
-		</tabbook>
+		<include file="plot_dist_common_dialog_layout.xml"/>
 	</dialog>
 </document>


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the rkward-tracker mailing list