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

kapatp at users.sourceforge.net kapatp at users.sourceforge.net
Sat Mar 17 08:12:41 UTC 2007


Revision: 1611
          http://svn.sourceforge.net/rkward/?rev=1611&view=rev
Author:   kapatp
Date:     2007-03-17 01:12:41 -0700 (Sat, 17 Mar 2007)

Log Message:
-----------

* removed rhelp link to rug() from Binomial CLT
* added Geometric CLT

Modified Paths:
--------------
    trunk/rkward/rkward/plugins/distributions/clt/plot_binomial_clt.rkh
    trunk/rkward/rkward/plugins/distributions.pluginmap
    trunk/rkward/rkward/plugins/under_development.pluginmap

Added Paths:
-----------
    trunk/rkward/rkward/plugins/distributions/clt/plot_geometric_clt.php
    trunk/rkward/rkward/plugins/distributions/clt/plot_geometric_clt.rkh
    trunk/rkward/rkward/plugins/distributions/clt/plot_geometric_clt.xml

Modified: trunk/rkward/rkward/plugins/distributions/clt/plot_binomial_clt.rkh
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_binomial_clt.rkh	2007-03-17 07:33:41 UTC (rev 1610)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_binomial_clt.rkh	2007-03-17 08:12:41 UTC (rev 1611)
@@ -33,7 +33,6 @@
 			<li><link href="rkward://rhelp/Normal"/></li>
 			<li><link href="rkward://rhelp/hist"/></li>
 			<li><link href="rkward://rhelp/rect"/></li>
-			<li><link href="rkward://rhelp/rug"/></li>
 		</ul>
 	</related>
 </document>

Added: trunk/rkward/rkward/plugins/distributions/clt/plot_geometric_clt.php
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_geometric_clt.php	                        (rev 0)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_geometric_clt.php	2007-03-17 08:12:41 UTC (rev 1611)
@@ -0,0 +1,121 @@
+<?php
+function preprocess () {
+}
+
+function calculate () {
+}
+
+function printout () {
+	doPrintout (true);
+}
+
+function preview () {
+	preprocess ();
+	calculate ();
+	doPrintout (false);
+}
+
+function doPrintout ($final) {
+	$fun = getRK_val ("function");
+	$prob = getRK_val ("prob");
+	$nAvg = getRK_val ("nAvg"); // number of observations to calculate the averages
+	$nDist = getRK_val ("nDist"); // number of sample to construct the distribution
+
+	$scalenorm = getRK_val ("scalenorm"); // if variables should to normalised..
+	$drawnorm = getRK_val ("drawnorm");
+
+	$distExp = (1-$prob)/$prob; // mean of the distribution of sample averages
+	$distVar = (1-$prob)/($prob*$prob*$nAvg); // variance of the distribution of sample averages
+
+	if ($scalenorm) {
+		$normMu = 0; // mean for normal
+		$normSigma = 1; // std dev for normal
+	} else {
+		$normMu = $distExp;
+		$normSigma = sqrt($distVar);
+	}
+
+	$plotoptions = getRK_val("plotoptions.code.printout");
+	if ($fun == "hist") {
+		$normFun = "dnorm"; // draw normal density on the histogram
+		$histcalcoptions = getRK_val ("histogram_opt.code.calculate"); // options that goes into hist() function
+		$histplotoptions = getRK_val ("histogram_opt.code.printout"); // options that goes into plot.histogram()
+		$histplotoptions .= $plotoptions; // generic plot options
+	} elseif ($fun == "dist") {
+		$ecdfoptions = "";
+		$col_y0 = getRK_val ("col_y0.code.printout");
+		$col_y1 = getRK_val ("col_y1.code.printout");
+		if (($col_y0 != "") && ($col_y1 != "")) {
+			$ecdfoptions .= ", col.01line=c({$col_y0},{$col_y1})";
+		} elseif (($col_y0 != "") || ($col_y1 != "")) {
+			$ecdfoptions .= ", col.01line={$col_y0}{$col_y1}";
+		} // col.01line option to plot.ecdf()
+
+		$normFun = "pnorm"; // draw normal cdf on the ecdf plot
+		$plotoptions .= $ecdfoptions . getRK_val ("dist_stepfun.code.printout"); // plot.ecdf() and plot.stepfun() options
+	}
+
+	$yLim = ""; // initialise the ylim option
+?>
+# generate the entire data:
+data <- matrix(rgeom(n=<? echo ($nAvg*$nDist); ?>, prob=<? echo ($prob); ?>), nrow=<? echo ($nAvg); ?>);
+# get the sample averages:
+avg <- colMeans(data);
+<?
+	if ($scalenorm) {
+?>
+# mean for the sample averages:
+dist.mean <- <? echo ($distExp); ?>;
+# variance for the sample averages:
+dist.var <- <? echo ($distVar); ?>;
+# normalise the variables:
+avg <- (avg - dist.mean)/sqrt(dist.var);
+<?
+	}
+	if ($drawnorm) {
+?>
+# generate random normal samples:
+normX <- seq(from=min(avg), to=max(avg), length=<? echo ($nDist); ?>);
+normY <- <? echo ($normFun); ?> (normX, mean = <? echo ($normMu); ?>, sd = <? echo ($normSigma); ?>);
+<?
+	}
+	if ($fun == "hist") {
+?>
+dist.hist <- hist(avg, plot=FALSE<? echo ($histcalcoptions); ?>);
+<?
+	if ($drawnorm) {
+?>
+# calculate the ylims appropriately:
+ylim <- c(0,max(c(dist.hist$density, normY)));
+<?
+		$yLim = ', ylim=ylim';
+		}
+	}
+	if ($final) {
+?>
+rk.graph.on ()
+try ({
+<?
+	}
+  	if ($fun == "hist") {
+?>
+	plot(dist.hist<? echo ($yLim); echo ($histplotoptions); ?>)
+<?
+	} elseif ($fun == "dist") {
+?>
+	plot(ecdf(avg)<? echo ($plotoptions); ?>)
+<?
+	}
+	if ($drawnorm) {
+?>
+	lines (x=normX, y=normY, type="<? getRK ("normpointtype"); ?>"<? getRK ("normlinecol.code.printout"); ?>)
+<?
+	}
+	if ($final) {
+?>
+	})
+rk.graph.off ()
+<?
+	}
+}
+?>

Added: trunk/rkward/rkward/plugins/distributions/clt/plot_geometric_clt.rkh
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_geometric_clt.rkh	                        (rev 0)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_geometric_clt.rkh	2007-03-17 08:12:41 UTC (rev 1611)
@@ -0,0 +1,40 @@
+<!DOCTYPE rkhelp>
+<document>
+	<summary>
+		Normal approximation to Geometric Sample averages. For any generic option refer to the RKWard help page on <link href="rkward://component/plot_binomial_clt"/> for detailed descriptions.
+	</summary>
+	<usage>
+		Choose the Geometric parameter, the sample sizes needed for CLT and a choice of function.
+	</usage>
+	<settings>
+		<caption id="tab_plot_distrib_clt"/>
+		<setting id="frame_geomparam">See RKWard help on <link href="rkward://component/plot_geometric_distribution"/>.</setting>
+		<setting id="nAvg"></setting>
+		<setting id="nDist"></setting>
+		<setting id="function"></setting>
+		<setting id="scalenorm"></setting>
+		<setting id="drawnorm">For all the above see 'Binomial CLT'.</setting>
+		<setting id="normpointtype">Pointtype for the Normal curve.</setting>
+		<setting id="normlinecol">Color of the Normal curve.</setting>
+		<setting id="plotoptions">Various plot options.</setting>
+		<setting id="preview">Preview button.</setting>
+		<caption id="tab_histoptions"/>
+		<setting id="histogram_opt">See Binomial CLT for details.</setting>
+		<caption id="tab_distfunction"/>
+		<setting id="dist_stepfun">See Binomial CLT for details.</setting>
+		<setting id="frame_col_y0"></setting>
+		<setting id="frame_col_y1">See Binomial CLT for details.</setting>
+	</settings>
+	<related>
+		<ul>
+			<li><link href="rkward://component/plot_binomial_clt"/></li>
+			<li><link href="rkward://component/plot_geometric_distribution"/></li>
+			<li><link href="rkward://component/plot_stepfun_options"/></li>
+			<li><link href="rkward://rhelp/Geometric"/></li>
+			<li><link href="rkward://rhelp/Normal"/></li>
+			<li><link href="rkward://rhelp/hist"/></li>
+			<li><link href="rkward://rhelp/rect"/></li>
+		</ul>
+	</related>
+</document>
+

Added: trunk/rkward/rkward/plugins/distributions/clt/plot_geometric_clt.xml
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_geometric_clt.xml	                        (rev 0)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_geometric_clt.xml	2007-03-17 08:12:41 UTC (rev 1611)
@@ -0,0 +1,93 @@
+<!DOCTYPE rkplugin>
+<document>
+	<code file="plot_geometric_clt.php" />
+	<help file="plot_geometric_clt.rkh" />
+	<logic>
+		<set id="plotoptions.allow_log" to="false"/>
+		<set id="plotoptions.allow_type" to="false"/>
+		<set id="plotoptions.default_main" to="Geometric"/>
+		<set id="plotoptions.default_xlab" to="Sample Averages"/>
+
+		<set id="normlinecol.default_color" to="red" />
+
+		<set id="histogram_opt.varname" to="avg" />
+		<set id="histogram_opt.allow_freq" to="false" />
+		<set id="histogram_opt.allow_barlabels" to="true" />
+		<set id="histogram_opt.allow_addtoplot" to="false" />
+
+		<convert id="isHistogram" sources="function.string" mode="equals" standard="hist"/>
+		<connect client="tab_histoptions.enabled" governor="isHistogram"/>
+
+		<convert id="isDist" sources="function.string" mode="equals" standard="dist"/>
+		<connect client="tab_distfunction.enabled" governor="isDist"/>
+
+		<connect client="normpointtype.enabled" governor="drawnorm.state"/>
+		<connect client="normlinecol.color.enabled" governor="drawnorm.state"/>
+
+		<set id="dist_stepfun.allow_addtoplot" to="false" />
+		<set id="dist_stepfun.default_verticals" to="false" />
+
+		<set id="col_y0.argument" to=""/>
+		<set id="col_y1.argument" to=""/>
+</logic>
+	<dialog label="Central Limit Theorem: Geometric to Normal" >
+		<tabbook>
+			<tab id="tab_plot_distrib_clt" label="Parameters" >
+				<row>
+					<column>
+						<frame label="CLT Samples" >
+							<spinbox type="integer" min = "1" id="nAvg" initial="10" label="Samples for Average" />
+							<spinbox type="integer" min = "10" id="nDist" initial="1000" label="Samples for distribution" />
+						</frame>
+						<frame id="frame_geomparam" label="Geometric Parameters">
+							<spinbox default_precision="2" type="real" id="prob" initial="0.5" min="0" max="1" label="Probability of success on each trial" />
+						</frame>
+					</column>
+					<column>
+						<radio id="function" label="Choose type of function plot" >
+							<option value="hist" label="Histogram and Density"  checked="true"/>
+							<option value="dist" label="ECDF and Distribution"/>
+						</radio>
+						<checkbox id="scalenorm" label="Use normalised random variable" value="1" value_unchecked="0"/>
+						<frame id="frame_lineoptions" label="Nomral Curve Options">
+							<checkbox id="drawnorm" label="Draw normal curve" value="1" value_unchecked="0" checked="true"/>
+							<dropdown id="normpointtype" label="Type of points/lines" >
+								<option value="p" label="Individual points " />
+								<option value="l" label="Lines" checked="true"/>
+								<option value="b" label="Points connected by lines (both)" />
+								<option value="o" label="Points overlaid by lines " />
+								<option value="h" label="Vertical lines (high-density)" />
+								<option value="s" label="Step-function on left edge" />
+								<option value="S" label="Step-function on right edge" />
+							</dropdown>
+							<embed id="normlinecol" component="rkward::color_chooser" label="Color" />
+						</frame>
+					</column>
+				</row>
+			<stretch/>
+				<row>
+					<embed id="plotoptions" component="rkward::plot_options" as_button="true" label="Plot Options" />
+					<preview id="preview" label="Preview"/>
+				</row>
+			</tab>
+
+			<tab id="tab_histoptions" label="Histogram">
+				<embed id="histogram_opt" component="rkward::histogram_options" label="Histogram Options"/>
+			</tab>
+
+			<tab id="tab_distfunction" label="ECDF options">
+				<embed id="dist_stepfun" component="rkward::plot_stepfun_options" label=""/>
+				<row>
+						<frame id="frame_col_y0" label="For y = 0 line">
+							<embed id="col_y0" component="rkward::color_chooser" label="Color"/>
+						</frame>
+						<frame id="frame_col_y1" label="For y = 1 line">
+							<embed id="col_y1" component="rkward::color_chooser" label="Color"/>
+						</frame>
+				</row>
+				<stretch/>
+			</tab>
+
+		</tabbook>
+	</dialog>
+</document>

Modified: trunk/rkward/rkward/plugins/distributions.pluginmap
===================================================================
--- trunk/rkward/rkward/plugins/distributions.pluginmap	2007-03-17 07:33:41 UTC (rev 1610)
+++ trunk/rkward/rkward/plugins/distributions.pluginmap	2007-03-17 08:12:41 UTC (rev 1611)
@@ -179,7 +179,7 @@
 					<entry component="binomial_tail_probabilities" label="Binomial tail probabilities" index="0"/>
 					<entry component="plot_binomial_distribution" label="Plot binomial distribution" index="2"/>
 				</menu>
-				<menu id="geom_distribution" label="Geometric" index="1">
+				<menu id="geometric_distribution" label="Geometric" index="1">
 					<entry component="geom_probabilities" label="Geometric probabilities" index="0"/>
 					<entry component="geom_quantiles" label="Geometric quantiles" index="1"/>
 					<entry component="plot_geometric_distribution" label="Plot Geometric distribution" index="2"/>

Modified: trunk/rkward/rkward/plugins/under_development.pluginmap
===================================================================
--- trunk/rkward/rkward/plugins/under_development.pluginmap	2007-03-17 07:33:41 UTC (rev 1610)
+++ trunk/rkward/rkward/plugins/under_development.pluginmap	2007-03-17 08:12:41 UTC (rev 1611)
@@ -3,6 +3,7 @@
 <document base_prefix="" namespace="rkward">
 	<components>
 		<component type="standard" id="plot_binomial_clt" file="distributions/clt/plot_binomial_clt.xml" label="Binomial CLT" />
+		<component type="standard" id="plot_geometric_clt" file="distributions/clt/plot_geometric_clt.xml" label="Geometric CLT" />
 
 		<component type="standard" id="moment" file="analysis/moments/moment.xml" label="Moment" />
 		<component type="standard" id="bonett_test" file="analysis/moments/bonett_test.xml" label="Bonett-Seier test of Geary's kurtosis" />
@@ -69,19 +70,22 @@
 		</menu>
 		<menu id="distributions" label="Distributions" index="7">
 			<menu id="univariate_continuous_distributions" label="Univariate continuous distributions" index="2">
-      </menu>
+			</menu>
 			<menu id="univariate_discrete_distributions" label="Univariate discrete distributions" index="2">
 				<menu id="binomial_distribution" label="Binomial" index="0">
 					<entry component="plot_binomial_clt" label="Binomial CLT" index="2"/>
 				</menu>
-      </menu>
+				<menu id="geometric_distribution" label="Geometric" index="1">
+					<entry component="plot_geometric_clt" label="Geometric CLT" index="2"/>
+				</menu>
+			</menu>
 		</menu>
 	</hierarchy>
 
-  <context id="x11">
-    <menu id="edit" label="Edit" index="3">
-      <entry component="x11grid" />
-    </menu>
-  </context>
+	<context id="x11">
+		<menu id="edit" label="Edit" index="3">
+			<entry component="x11grid" />
+		</menu>
+	</context>
 </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