[rkward-cvs] SF.net SVN: rkward: [1666] trunk/rkward/rkward/plugins
kapatp at users.sourceforge.net
kapatp at users.sourceforge.net
Tue Mar 20 21:00:52 UTC 2007
Revision: 1666
http://svn.sourceforge.net/rkward/?rev=1666&view=rev
Author: kapatp
Date: 2007-03-20 14:00:52 -0700 (Tue, 20 Mar 2007)
Log Message:
-----------
Continuous distribution CLT plugins
Modified Paths:
--------------
trunk/rkward/rkward/plugins/under_development.pluginmap
Added Paths:
-----------
trunk/rkward/rkward/plugins/distributions/clt/plot_beta_clt.php
trunk/rkward/rkward/plugins/distributions/clt/plot_beta_clt.rkh
trunk/rkward/rkward/plugins/distributions/clt/plot_beta_clt.xml
trunk/rkward/rkward/plugins/distributions/clt/plot_chi_squared_clt.php
trunk/rkward/rkward/plugins/distributions/clt/plot_chi_squared_clt.rkh
trunk/rkward/rkward/plugins/distributions/clt/plot_chi_squared_clt.xml
trunk/rkward/rkward/plugins/distributions/clt/plot_exponential_clt.php
trunk/rkward/rkward/plugins/distributions/clt/plot_exponential_clt.rkh
trunk/rkward/rkward/plugins/distributions/clt/plot_exponential_clt.xml
trunk/rkward/rkward/plugins/distributions/clt/plot_f_clt.php
trunk/rkward/rkward/plugins/distributions/clt/plot_f_clt.rkh
trunk/rkward/rkward/plugins/distributions/clt/plot_f_clt.xml
trunk/rkward/rkward/plugins/distributions/clt/plot_gamma_clt.php
trunk/rkward/rkward/plugins/distributions/clt/plot_gamma_clt.rkh
trunk/rkward/rkward/plugins/distributions/clt/plot_gamma_clt.xml
trunk/rkward/rkward/plugins/distributions/clt/plot_logistic_clt.php
trunk/rkward/rkward/plugins/distributions/clt/plot_logistic_clt.rkh
trunk/rkward/rkward/plugins/distributions/clt/plot_logistic_clt.xml
trunk/rkward/rkward/plugins/distributions/clt/plot_lognormal_clt.php
trunk/rkward/rkward/plugins/distributions/clt/plot_lognormal_clt.rkh
trunk/rkward/rkward/plugins/distributions/clt/plot_lognormal_clt.xml
trunk/rkward/rkward/plugins/distributions/clt/plot_normal_clt.php
trunk/rkward/rkward/plugins/distributions/clt/plot_normal_clt.rkh
trunk/rkward/rkward/plugins/distributions/clt/plot_normal_clt.xml
trunk/rkward/rkward/plugins/distributions/clt/plot_uniform_clt.php
trunk/rkward/rkward/plugins/distributions/clt/plot_uniform_clt.rkh
trunk/rkward/rkward/plugins/distributions/clt/plot_uniform_clt.xml
Added: trunk/rkward/rkward/plugins/distributions/clt/plot_beta_clt.php
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_beta_clt.php (rev 0)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_beta_clt.php 2007-03-20 21:00:52 UTC (rev 1666)
@@ -0,0 +1,122 @@
+<?php
+function preprocess () {
+}
+
+function calculate () {
+}
+
+function printout () {
+ doPrintout (true);
+}
+
+function preview () {
+ preprocess ();
+ calculate ();
+ doPrintout (false);
+}
+
+function doPrintout ($final) {
+ $fun = getRK_val ("function");
+ $a = getRK_val ("a");
+ $b = getRK_val ("b");
+ $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 = $a/($a+$b); // mean of the distribution of sample averages
+ $distVar = ($a*$b)/(($a+$b)*($a+$b)*($a+$b+1)*$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(rbeta(n=<? echo ($nAvg*$nDist); ?>, shape1=<? echo ($a); ?>, shape2=<? echo ($b); ?>), 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_beta_clt.rkh
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_beta_clt.rkh (rev 0)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_beta_clt.rkh 2007-03-20 21:00:52 UTC (rev 1666)
@@ -0,0 +1,36 @@
+<!DOCTYPE rkhelp>
+<document>
+ <summary>
+ Normal approximation to Beta 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 Beta parameter, the sample sizes needed for CLT and a choice of function.
+ </usage>
+ <settings>
+ <caption id="tab_plot_distrib_clt"/>
+ <setting id="frame_betaparam">See RKWard help on <link href="rkward://component/plot_beta_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_beta_distribution"/></li>
+ <li><link href="rkward://rhelp/Beta"/></li>
+ <li><link href="rkward://rhelp/Normal"/></li>
+ </ul>
+ </related>
+</document>
Added: trunk/rkward/rkward/plugins/distributions/clt/plot_beta_clt.xml
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_beta_clt.xml (rev 0)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_beta_clt.xml 2007-03-20 21:00:52 UTC (rev 1666)
@@ -0,0 +1,95 @@
+<!DOCTYPE rkplugin>
+<document>
+ <code file="plot_beta_clt.php" />
+ <help file="plot_beta_clt.rkh" />
+ <logic>
+ <set id="plotoptions.allow_log" to="false"/>
+ <set id="plotoptions.allow_type" to="false"/>
+ <set id="plotoptions.default_main" to="Beta"/>
+ <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_dopoints" to="false" />
+ <set id="dist_stepfun.default_verticals" to="true" />
+
+ <set id="col_y0.argument" to=""/>
+ <set id="col_y1.argument" to=""/>
+</logic>
+ <dialog label="Central Limit Theorem: Beta 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_betaparam" label="Beta Parameters">
+ <spinbox default_precision="2" type="real" id="a" initial="2" min="0.01" label="Shape1 (a)" />
+ <spinbox default_precision="2" type="real" id="b" initial="2" min="0.01" label="Shape2 (b)" />
+ </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>
Added: trunk/rkward/rkward/plugins/distributions/clt/plot_chi_squared_clt.php
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_chi_squared_clt.php (rev 0)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_chi_squared_clt.php 2007-03-20 21:00:52 UTC (rev 1666)
@@ -0,0 +1,122 @@
+<?php
+function preprocess () {
+}
+
+function calculate () {
+}
+
+function printout () {
+ doPrintout (true);
+}
+
+function preview () {
+ preprocess ();
+ calculate ();
+ doPrintout (false);
+}
+
+function doPrintout ($final) {
+ $fun = getRK_val ("function");
+ $ncp = getRK_val ("ncp");
+ $df = getRK_val ("df");
+ $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 = $df+$ncp; // mean of the distribution of sample averages
+ $distVar = 2*($df+2*$ncp)/$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(rchisq(n=<? echo ($nAvg*$nDist); ?>, df=<? echo ($df); ?>, ncp=<? echo ($ncp); ?>), 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_chi_squared_clt.rkh
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_chi_squared_clt.rkh (rev 0)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_chi_squared_clt.rkh 2007-03-20 21:00:52 UTC (rev 1666)
@@ -0,0 +1,36 @@
+<!DOCTYPE rkhelp>
+<document>
+ <summary>
+ Normal approximation to Chi-Squared 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 Chi-Squared parameter, the sample sizes needed for CLT and a choice of function.
+ </usage>
+ <settings>
+ <caption id="tab_plot_distrib_clt"/>
+ <setting id="frame_chisqparam">See RKWard help on <link href="rkward://component/plot_chi_squared_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_chi_squared_distribution"/></li>
+ <li><link href="rkward://rhelp/Chisquare"/></li>
+ <li><link href="rkward://rhelp/Normal"/></li>
+ </ul>
+ </related>
+</document>
Added: trunk/rkward/rkward/plugins/distributions/clt/plot_chi_squared_clt.xml
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_chi_squared_clt.xml (rev 0)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_chi_squared_clt.xml 2007-03-20 21:00:52 UTC (rev 1666)
@@ -0,0 +1,94 @@
+<!DOCTYPE rkplugin>
+<document>
+ <code file="plot_chi_squared_clt.php" />
+ <help file="plot_chi_squared_clt.rkh" />
+ <logic>
+ <set id="plotoptions.allow_log" to="false"/>
+ <set id="plotoptions.allow_type" to="false"/>
+ <set id="plotoptions.default_main" to="Chi-Squared"/>
+ <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: Chi squared 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_chisqparam" label="Chi squared 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>
+ </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>
Added: trunk/rkward/rkward/plugins/distributions/clt/plot_exponential_clt.php
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_exponential_clt.php (rev 0)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_exponential_clt.php 2007-03-20 21:00:52 UTC (rev 1666)
@@ -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");
+ $rate = getRK_val ("rate");
+ $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/$rate; // mean of the distribution of sample averages
+ $distVar = 1/($rate*$rate*$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(rexp(n=<? echo ($nAvg*$nDist); ?>, rate=<? echo ($rate); ?>), 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_exponential_clt.rkh
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_exponential_clt.rkh (rev 0)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_exponential_clt.rkh 2007-03-20 21:00:52 UTC (rev 1666)
@@ -0,0 +1,36 @@
+<!DOCTYPE rkhelp>
+<document>
+ <summary>
+ Normal approximation to Exponential 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 Exponential parameter, the sample sizes needed for CLT and a choice of function.
+ </usage>
+ <settings>
+ <caption id="tab_plot_distrib_clt"/>
+ <setting id="frame_expparam">See RKWard help on <link href="rkward://component/plot_exponential_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_exponential_distribution"/></li>
+ <li><link href="rkward://rhelp/Exponential"/></li>
+ <li><link href="rkward://rhelp/Normal"/></li>
+ </ul>
+ </related>
+</document>
Added: trunk/rkward/rkward/plugins/distributions/clt/plot_exponential_clt.xml
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_exponential_clt.xml (rev 0)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_exponential_clt.xml 2007-03-20 21:00:52 UTC (rev 1666)
@@ -0,0 +1,93 @@
+<!DOCTYPE rkplugin>
+<document>
+ <code file="plot_exponential_clt.php" />
+ <help file="plot_exponential_clt.rkh" />
+ <logic>
+ <set id="plotoptions.allow_log" to="false"/>
+ <set id="plotoptions.allow_type" to="false"/>
+ <set id="plotoptions.default_main" to="Exponential"/>
+ <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: Exponential 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_expparam" label="Exponential Parameters">
+ <spinbox default_precision="2" type="real" id="rate" initial="1" min="0.01" label="Rate" />
+ </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>
Added: trunk/rkward/rkward/plugins/distributions/clt/plot_f_clt.php
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_f_clt.php (rev 0)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_f_clt.php 2007-03-20 21:00:52 UTC (rev 1666)
@@ -0,0 +1,124 @@
+<?php
+function preprocess () {
+}
+
+function calculate () {
+}
+
+function printout () {
+ doPrintout (true);
+}
+
+function preview () {
+ preprocess ();
+ calculate ();
+ doPrintout (false);
+}
+
+function doPrintout ($final) {
+ $fun = getRK_val ("function");
+ $ncp = getRK_val ("ncp");
+ $df1 = getRK_val ("df1");
+ $df2 = getRK_val ("df2");
+ $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");
+
+ // For variance we need df2 > 4: That has been taken care of in the xml file: bounded below by 4.01
+ $distExp = ($df2*($df1+$ncp))/($df1*($df2-2)); // mean of the distribution of sample averages
+ $distVar = (2*$df2*$df2*(($df1+$ncp)*($df1+$ncp) + ($df1+2*$ncp)*($df2-2))) / ($df1*$df1*($df2-2)*($df2-2)*($df2-4)*$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(rf(n=<? echo ($nAvg*$nDist); ?>, df1=<? echo ($df1); ?>, df2=<? echo ($df2); ?>, ncp=<? echo ($ncp); ?>), 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_f_clt.rkh
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_f_clt.rkh (rev 0)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_f_clt.rkh 2007-03-20 21:00:52 UTC (rev 1666)
@@ -0,0 +1,36 @@
+<!DOCTYPE rkhelp>
+<document>
+ <summary>
+ Normal approximation to F 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 F parameter, the sample sizes needed for CLT and a choice of function.
+ </usage>
+ <settings>
+ <caption id="tab_plot_distrib_clt"/>
+ <setting id="frame_fparam">See RKWard help on <link href="rkward://component/plot_f_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_f_distribution"/></li>
+ <li><link href="rkward://rhelp/FDist"/></li>
+ <li><link href="rkward://rhelp/Normal"/></li>
+ </ul>
+ </related>
+</document>
Added: trunk/rkward/rkward/plugins/distributions/clt/plot_f_clt.xml
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_f_clt.xml (rev 0)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_f_clt.xml 2007-03-20 21:00:52 UTC (rev 1666)
@@ -0,0 +1,96 @@
+<!DOCTYPE rkplugin>
+<document>
+ <code file="plot_f_clt.php" />
+ <help file="plot_f_clt.rkh" />
+ <logic>
+ <set id="plotoptions.allow_log" to="false"/>
+ <set id="plotoptions.allow_type" to="false"/>
+ <set id="plotoptions.default_main" to="F"/>
+ <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: F 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_fparam" label="F Parameters">
+ <spinbox default_precision="2" type="real" min="0.01" id="df1" initial="5" label="Numerator degrees of freedom" />
+<!-- For variance we need df2 > 4 -->
+ <spinbox default_precision="2" type="real" min="4.01" id="df2" initial="5" label="Denominator degrees of freedom" />
+ <spinbox default_precision="0" type="real" min="0" id="ncp" initial="0" label="Non-centrality parameter" />
+ </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>
Added: trunk/rkward/rkward/plugins/distributions/clt/plot_gamma_clt.php
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_gamma_clt.php (rev 0)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_gamma_clt.php 2007-03-20 21:00:52 UTC (rev 1666)
@@ -0,0 +1,122 @@
+<?php
+function preprocess () {
+}
+
+function calculate () {
+}
+
+function printout () {
+ doPrintout (true);
+}
+
+function preview () {
+ preprocess ();
+ calculate ();
+ doPrintout (false);
+}
+
+function doPrintout ($final) {
+ $fun = getRK_val ("function");
+ $shape = getRK_val ("shape");
+ $rate = getRK_val ("rate");
+ $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 = $shape/$rate; // mean of the distribution of sample averages
+ $distVar = $shape/($rate*$rate*$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(rgamma(n=<? echo ($nAvg*$nDist); ?>, shape=<? echo ($shape); ?>, rate=<? echo ($rate); ?>), 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_gamma_clt.rkh
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_gamma_clt.rkh (rev 0)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_gamma_clt.rkh 2007-03-20 21:00:52 UTC (rev 1666)
@@ -0,0 +1,36 @@
+<!DOCTYPE rkhelp>
+<document>
+ <summary>
+ Normal approximation to Gamma 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 Gamma parameter, the sample sizes needed for CLT and a choice of function.
+ </usage>
+ <settings>
+ <caption id="tab_plot_distrib_clt"/>
+ <setting id="frame_gammaparam">See RKWard help on <link href="rkward://component/plot_gamma_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_gamma_distribution"/></li>
+ <li><link href="rkward://rhelp/GammaDist"/></li>
+ <li><link href="rkward://rhelp/Normal"/></li>
+ </ul>
+ </related>
+</document>
Added: trunk/rkward/rkward/plugins/distributions/clt/plot_gamma_clt.xml
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_gamma_clt.xml (rev 0)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_gamma_clt.xml 2007-03-20 21:00:52 UTC (rev 1666)
@@ -0,0 +1,94 @@
+<!DOCTYPE rkplugin>
+<document>
+ <code file="plot_gamma_clt.php" />
+ <help file="plot_gamma_clt.rkh" />
+ <logic>
+ <set id="plotoptions.allow_log" to="false"/>
+ <set id="plotoptions.allow_type" to="false"/>
+ <set id="plotoptions.default_main" to="Gamma"/>
+ <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: Gamma 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_gammaparam" label="Gamma Parameters">
+ <spinbox default_precision="2" type="real" id="shape" initial="1" min="0.01" label="Shape" />
+ <spinbox default_precision="2" type="real" id="rate" initial="1" min="0.01" label="Rate (lambda)" label="Rate or 1/Scale" />
+ </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>
Added: trunk/rkward/rkward/plugins/distributions/clt/plot_logistic_clt.php
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_logistic_clt.php (rev 0)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_logistic_clt.php 2007-03-20 21:00:52 UTC (rev 1666)
@@ -0,0 +1,122 @@
+<?php
+function preprocess () {
+}
+
+function calculate () {
+}
+
+function printout () {
+ doPrintout (true);
+}
+
+function preview () {
+ preprocess ();
+ calculate ();
+ doPrintout (false);
+}
+
+function doPrintout ($final) {
+ $fun = getRK_val ("function");
+ $loc = getRK_val ("loc");
+ $scale = getRK_val ("scale");
+ $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 = $loc; // mean of the distribution of sample averages
+ $distVar = M_PI*M_PI*$scale*$scale/(3*$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(rlogis(n=<? echo ($nAvg*$nDist); ?>, location=<? echo ($loc); ?>, scale=<? echo ($scale); ?>), 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_logistic_clt.rkh
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_logistic_clt.rkh (rev 0)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_logistic_clt.rkh 2007-03-20 21:00:52 UTC (rev 1666)
@@ -0,0 +1,36 @@
+<!DOCTYPE rkhelp>
+<document>
+ <summary>
+ Normal approximation to Logistic 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 Logistic parameter, the sample sizes needed for CLT and a choice of function.
+ </usage>
+ <settings>
+ <caption id="tab_plot_distrib_clt"/>
+ <setting id="frame_logisparam">See RKWard help on <link href="rkward://component/plot_logistic_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_logistic_distribution"/></li>
+ <li><link href="rkward://rhelp/Logistic"/></li>
+ <li><link href="rkward://rhelp/Normal"/></li>
+ </ul>
+ </related>
+</document>
Added: trunk/rkward/rkward/plugins/distributions/clt/plot_logistic_clt.xml
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_logistic_clt.xml (rev 0)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_logistic_clt.xml 2007-03-20 21:00:52 UTC (rev 1666)
@@ -0,0 +1,94 @@
+<!DOCTYPE rkplugin>
+<document>
+ <code file="plot_logistic_clt.php" />
+ <help file="plot_logistic_clt.rkh" />
+ <logic>
+ <set id="plotoptions.allow_log" to="false"/>
+ <set id="plotoptions.allow_type" to="false"/>
+ <set id="plotoptions.default_main" to="Logistic"/>
+ <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: Logistic 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_logisparam" label="Logistic 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>
+ </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>
Added: trunk/rkward/rkward/plugins/distributions/clt/plot_lognormal_clt.php
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_lognormal_clt.php (rev 0)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_lognormal_clt.php 2007-03-20 21:00:52 UTC (rev 1666)
@@ -0,0 +1,122 @@
+<?php
+function preprocess () {
+}
+
+function calculate () {
+}
+
+function printout () {
+ doPrintout (true);
+}
+
+function preview () {
+ preprocess ();
+ calculate ();
+ doPrintout (false);
+}
+
+function doPrintout ($final) {
+ $fun = getRK_val ("function");
+ $sd = getRK_val ("sd");
+ $mean = getRK_val ("mean");
+ $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 = exp($mean+$sd*$sd/2); // mean of the distribution of sample averages
+ $distVar = exp(2*$mean+$sd*$sd)*(exp($sd*$sd)-1)/$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(rlnorm(n=<? echo ($nAvg*$nDist); ?>, meanlog=<? echo ($mean); ?>, sdlog=<? echo ($sd); ?>), 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_lognormal_clt.rkh
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_lognormal_clt.rkh (rev 0)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_lognormal_clt.rkh 2007-03-20 21:00:52 UTC (rev 1666)
@@ -0,0 +1,36 @@
+<!DOCTYPE rkhelp>
+<document>
+ <summary>
+ Normal approximation to Lognormal 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 Lognormal parameter, the sample sizes needed for CLT and a choice of function.
+ </usage>
+ <settings>
+ <caption id="tab_plot_distrib_clt"/>
+ <setting id="frame_lnormparam">See RKWard help on <link href="rkward://component/plot_lognormal_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_lognormal_distribution"/></li>
+ <li><link href="rkward://rhelp/Lognormal"/></li>
+ <li><link href="rkward://rhelp/Normal"/></li>
+ </ul>
+ </related>
+</document>
Added: trunk/rkward/rkward/plugins/distributions/clt/plot_lognormal_clt.xml
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_lognormal_clt.xml (rev 0)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_lognormal_clt.xml 2007-03-20 21:00:52 UTC (rev 1666)
@@ -0,0 +1,94 @@
+<!DOCTYPE rkplugin>
+<document>
+ <code file="plot_lognormal_clt.php" />
+ <help file="plot_lognormal_clt.rkh" />
+ <logic>
+ <set id="plotoptions.allow_log" to="false"/>
+ <set id="plotoptions.allow_type" to="false"/>
+ <set id="plotoptions.default_main" to="Lognormal"/>
+ <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: Lognormal 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_lnormparam" label="Lognormal Parameters (in log-scale)">
+ <spinbox default_precision="2" type="real" id="mean" initial="0" label="Mean" />
+ <spinbox default_precision="2" type="real" id="sd" initial="1" min="0.01" label="Standard deviation" />
+ </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>
Added: trunk/rkward/rkward/plugins/distributions/clt/plot_normal_clt.php
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_normal_clt.php (rev 0)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_normal_clt.php 2007-03-20 21:00:52 UTC (rev 1666)
@@ -0,0 +1,122 @@
+<?php
+function preprocess () {
+}
+
+function calculate () {
+}
+
+function printout () {
+ doPrintout (true);
+}
+
+function preview () {
+ preprocess ();
+ calculate ();
+ doPrintout (false);
+}
+
+function doPrintout ($final) {
+ $fun = getRK_val ("function");
+ $mean = getRK_val ("mean");
+ $sd = getRK_val ("sd");
+ $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 = $mean; // mean of the distribution of sample averages
+ $distVar = ($sd*$sd)/$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(rnorm(n=<? echo ($nAvg*$nDist); ?>, mean=<? echo ($mean); ?>, sd=<? echo ($sd); ?>), 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_normal_clt.rkh
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_normal_clt.rkh (rev 0)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_normal_clt.rkh 2007-03-20 21:00:52 UTC (rev 1666)
@@ -0,0 +1,35 @@
+<!DOCTYPE rkhelp>
+<document>
+ <summary>
+ Normal approximation to Normal 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 Normal parameter, the sample sizes needed for CLT and a choice of function.
+ </usage>
+ <settings>
+ <caption id="tab_plot_distrib_clt"/>
+ <setting id="frame_normalparam">See RKWard help on <link href="rkward://component/plot_normal_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_normal_distribution"/></li>
+ <li><link href="rkward://rhelp/Normal"/></li>
+ </ul>
+ </related>
+</document>
Added: trunk/rkward/rkward/plugins/distributions/clt/plot_normal_clt.xml
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_normal_clt.xml (rev 0)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_normal_clt.xml 2007-03-20 21:00:52 UTC (rev 1666)
@@ -0,0 +1,94 @@
+<!DOCTYPE rkplugin>
+<document>
+ <code file="plot_normal_clt.php" />
+ <help file="plot_normal_clt.rkh" />
+ <logic>
+ <set id="plotoptions.allow_log" to="false"/>
+ <set id="plotoptions.allow_type" to="false"/>
+ <set id="plotoptions.default_main" to="Normal"/>
+ <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: Normal 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_normalparam" label="Normal Parameters">
+ <spinbox default_precision="2" type="real" id="mean" initial="0" label="Mean" />
+ <spinbox default_precision="2" type="real" id="sd" min="0.01" initial="1" label="Standard deviation"/>
+ </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>
Added: trunk/rkward/rkward/plugins/distributions/clt/plot_uniform_clt.php
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_uniform_clt.php (rev 0)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_uniform_clt.php 2007-03-20 21:00:52 UTC (rev 1666)
@@ -0,0 +1,122 @@
+<?php
+function preprocess () {
+}
+
+function calculate () {
+}
+
+function printout () {
+ doPrintout (true);
+}
+
+function preview () {
+ preprocess ();
+ calculate ();
+ doPrintout (false);
+}
+
+function doPrintout ($final) {
+ $fun = getRK_val ("function");
+ $llim = getRK_val ("llim");
+ $ulim = getRK_val ("ulim");
+ $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 = ($llim+$ulim)/2; // mean of the distribution of sample averages
+ $distVar = ($ulim-$llim)*($ulim-$llim)/(12*$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(runif(n=<? echo ($nAvg*$nDist); ?>, min=<? echo ($llim); ?>, max=<? echo ($ulim); ?>), 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_uniform_clt.rkh
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_uniform_clt.rkh (rev 0)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_uniform_clt.rkh 2007-03-20 21:00:52 UTC (rev 1666)
@@ -0,0 +1,36 @@
+<!DOCTYPE rkhelp>
+<document>
+ <summary>
+ Normal approximation to Uniform 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 Uniform parameter, the sample sizes needed for CLT and a choice of function.
+ </usage>
+ <settings>
+ <caption id="tab_plot_distrib_clt"/>
+ <setting id="frame_unifparam">See RKWard help on <link href="rkward://component/plot_uniform_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_uniform_distribution"/></li>
+ <li><link href="rkward://rhelp/Uniform"/></li>
+ <li><link href="rkward://rhelp/Normal"/></li>
+ </ul>
+ </related>
+</document>
Added: trunk/rkward/rkward/plugins/distributions/clt/plot_uniform_clt.xml
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_uniform_clt.xml (rev 0)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_uniform_clt.xml 2007-03-20 21:00:52 UTC (rev 1666)
@@ -0,0 +1,94 @@
+<!DOCTYPE rkplugin>
+<document>
+ <code file="plot_uniform_clt.php" />
+ <help file="plot_uniform_clt.rkh" />
+ <logic>
+ <set id="plotoptions.allow_log" to="false"/>
+ <set id="plotoptions.allow_type" to="false"/>
+ <set id="plotoptions.default_main" to="Uniform"/>
+ <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: Uniform 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_unifparam" label="Uniform Parameters">
+ <spinbox default_precision="2" type="real" id="llim" initial="0" label="Minimum" />
+ <spinbox default_precision="2" type="real" id="ulim" initial="1" label="Maximum" />
+ </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/under_development.pluginmap
===================================================================
--- trunk/rkward/rkward/plugins/under_development.pluginmap 2007-03-20 20:40:23 UTC (rev 1665)
+++ trunk/rkward/rkward/plugins/under_development.pluginmap 2007-03-20 21:00:52 UTC (rev 1666)
@@ -9,6 +9,16 @@
<component type="standard" id="plot_poisson_clt" file="distributions/clt/plot_poisson_clt.xml" label="Poisson CLT" />
<component type="standard" id="plot_wilcoxon_clt" file="distributions/clt/plot_wilcoxon_clt.xml" label="Wilcoxon CLT" />
+ <component type="standard" id="plot_beta_clt" file="distributions/clt/plot_beta_clt.xml" label="Beta CLT" />
+ <component type="standard" id="plot_chi_squared_clt" file="distributions/clt/plot_chi_squared_clt.xml" label="Chi-squared CLT" />
+ <component type="standard" id="plot_exponential_clt" file="distributions/clt/plot_exponential_clt.xml" label="Exponential CLT" />
+ <component type="standard" id="plot_f_clt" file="distributions/clt/plot_f_clt.xml" label="F CLT" />
+ <component type="standard" id="plot_gamma_clt" file="distributions/clt/plot_gamma_clt.xml" label="Gamma CLT" />
+ <component type="standard" id="plot_logistic_clt" file="distributions/clt/plot_logistic_clt.xml" label="Logistic CLT" />
+ <component type="standard" id="plot_log_normal_clt" file="distributions/clt/plot_lognormal_clt.xml" label="Log Normal CLT" />
+ <component type="standard" id="plot_normal_clt" file="distributions/clt/plot_normal_clt.xml" label="Normal CLT" />
+ <component type="standard" id="plot_uniform_clt" file="distributions/clt/plot_uniform_clt.xml" label="Uniform 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" />
<component type="standard" id="agostino_test" file="analysis/moments/agostino_test.xml" label="D'Agostino test of skewness" />
@@ -76,6 +86,33 @@
</menu>
<menu id="distributions" label="Distributions" index="7">
<menu id="univariate_continuous_distributions" label="Univariate continuous distributions" index="2">
+ <menu id="beta_distribution" label="Beta">
+ <entry component="plot_beta_clt" label="Beta CLT" index="2"/>
+ </menu>
+ <menu id="chi_squared_distribution" label="Chi-squared">
+ <entry component="plot_chi_squared_clt" label="Chi-squared CLT" index="2"/>
+ </menu>
+ <menu id="exponential_distribution" label="Exponential">
+ <entry component="plot_exponential_clt" label="Exponential CLT" index="2"/>
+ </menu>
+ <menu id="f_distribution" label="F">
+ <entry component="plot_f_clt" label="F CLT" index="2"/>
+ </menu>
+ <menu id="gamma_distribution" label="Gamma">
+ <entry component="plot_gamma_clt" label="Gamma CLT" index="2"/>
+ </menu>
+ <menu id="logistic_distribution" label="Logistic">
+ <entry component="plot_logistic_clt" label="Logistic CLT" index="2"/>
+ </menu>
+ <menu id="log_normal_distribution" label="Log Normal">
+ <entry component="plot_log_normal_clt" label="Log Normal CLT" index="2"/>
+ </menu>
+ <menu id="normal_distribution" label="Normal">
+ <entry component="plot_normal_clt" label="Normal CLT" index="2"/>
+ </menu>
+ <menu id="uniform_distribution" label="Uniform">
+ <entry component="plot_uniform_clt" label="Uniform CLT" index="2"/>
+ </menu>
</menu>
<menu id="univariate_discrete_distributions" label="Univariate discrete distributions" index="2">
<menu id="binomial_distribution" label="Binomial" index="0">
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