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

kapatp at users.sourceforge.net kapatp at users.sourceforge.net
Fri Mar 23 03:01:52 UTC 2007


Revision: 1710
          http://svn.sourceforge.net/rkward/?rev=1710&view=rev
Author:   kapatp
Date:     2007-03-22 20:01:52 -0700 (Thu, 22 Mar 2007)

Log Message:
-----------
Modularised CLTs. This hopefully fixes the indentations too.

Modified Paths:
--------------
    trunk/rkward/rkward/plugins/distributions/clt/plot_beta_clt.php
    trunk/rkward/rkward/plugins/distributions/clt/plot_beta_clt.xml
    trunk/rkward/rkward/plugins/distributions/clt/plot_binomial_clt.php
    trunk/rkward/rkward/plugins/distributions/clt/plot_chi_squared_clt.php
    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.xml
    trunk/rkward/rkward/plugins/distributions/clt/plot_f_clt.php
    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.xml
    trunk/rkward/rkward/plugins/distributions/clt/plot_geometric_clt.php
    trunk/rkward/rkward/plugins/distributions/clt/plot_hypergeometric_clt.php
    trunk/rkward/rkward/plugins/distributions/clt/plot_logistic_clt.php
    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.xml
    trunk/rkward/rkward/plugins/distributions/clt/plot_negbinomial_clt.php
    trunk/rkward/rkward/plugins/distributions/clt/plot_negbinomial_clt.xml
    trunk/rkward/rkward/plugins/distributions/clt/plot_normal_clt.php
    trunk/rkward/rkward/plugins/distributions/clt/plot_normal_clt.xml
    trunk/rkward/rkward/plugins/distributions/clt/plot_poisson_clt.php
    trunk/rkward/rkward/plugins/distributions/clt/plot_poisson_clt.xml
    trunk/rkward/rkward/plugins/distributions/clt/plot_t_clt.php
    trunk/rkward/rkward/plugins/distributions/clt/plot_t_clt.xml
    trunk/rkward/rkward/plugins/distributions/clt/plot_uniform_clt.php
    trunk/rkward/rkward/plugins/distributions/clt/plot_uniform_clt.xml
    trunk/rkward/rkward/plugins/distributions/clt/plot_weibull_clt.php
    trunk/rkward/rkward/plugins/distributions/clt/plot_weibull_clt.xml
    trunk/rkward/rkward/plugins/distributions/clt/plot_wilcoxon_clt.php

Added Paths:
-----------
    trunk/rkward/rkward/plugins/distributions/clt/plot_clt_common.php

Modified: trunk/rkward/rkward/plugins/distributions/clt/plot_beta_clt.php
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_beta_clt.php	2007-03-22 22:58:20 UTC (rev 1709)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_beta_clt.php	2007-03-23 03:01:52 UTC (rev 1710)
@@ -1,113 +1,25 @@
 <?php
-function preprocess () {
-}
+include ("plot_clt_common.php");
 
-function calculate () {
+function doParameters () {
+?>
+shape1 <- <? echo(getRK_val ("a")); ?>; shape2 <- <? echo(getRK_val ("b")); ?>;
+<?
 }
 
-function printout () {
-	doPrintout (true);
+function doExpVar () {
+	global $nAvg;
+?>
+avg.exp <- shape1/(shape1 + shape2);
+avg.var <- (shape1*shape2/((shape1+shape2)^2*(shape1+shape2+1)))/<? echo ($nAvg); ?>;
+<?
 }
 
-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") {
-		$normFun = "pnorm"; // draw normal cdf on the ecdf plot
-		$plotoptions .= getRK_val ("dist_stepfun.code.printout"); // plot.ecdf() and plot.stepfun() options
-	}
-
-	$yLim = ""; // initialise the ylim option
+function doGenerateData () {
+	global $nAvg;
+	global $nDist;
 ?>
-# 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);
+data <- matrix(rbeta(n=<? echo ($nAvg*$nDist); ?>, shape1=shape1, shape2=shape2), nrow=<? echo ($nAvg); ?>);
 <?
-	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 ()
-<?
-	}
 }
 ?>

Modified: trunk/rkward/rkward/plugins/distributions/clt/plot_beta_clt.xml
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_beta_clt.xml	2007-03-22 22:58:20 UTC (rev 1709)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_beta_clt.xml	2007-03-23 03:01:52 UTC (rev 1710)
@@ -38,8 +38,8 @@
 							<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)" />
+							<spinbox default_precision="1" type="real" id="a" initial="2" min="0.01" label="Shape1 (a)" />
+							<spinbox default_precision="1" type="real" id="b" initial="2" min="0.01" label="Shape2 (b)" />
 						</frame>
 					</column>
 					<column>

Modified: trunk/rkward/rkward/plugins/distributions/clt/plot_binomial_clt.php
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_binomial_clt.php	2007-03-22 22:58:20 UTC (rev 1709)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_binomial_clt.php	2007-03-23 03:01:52 UTC (rev 1710)
@@ -1,113 +1,25 @@
 <?php
-function preprocess () {
-}
+include ("plot_clt_common.php");
 
-function calculate () {
+function doParameters () {
+?>
+size <- <? echo(getRK_val ("size")); ?>; prob <- <? echo(getRK_val ("prob")); ?>;
+<?
 }
 
-function printout () {
-	doPrintout (true);
+function doExpVar () {
+	global $nAvg;
+?>
+avg.exp <- size*prob;
+avg.var <- (size*prob*(1-prob))/<? echo ($nAvg); ?>;
+<?
 }
 
-function preview () {
-	preprocess ();
-	calculate ();
-	doPrintout (false);
-}
-
-function doPrintout ($final) {
-	$fun = getRK_val ("function");
-	$size = getRK_val ("size");
-	$prob = getRK_val ("prob");
-	$nAvg = getRK_val ("nAvg"); // number of observations to calculate the averages
-	$nDist = getRK_val ("nDist"); // number of sample to construct the distribution
-
-	$scalenorm = getRK_val ("scalenorm"); // if variables should to normalised..
-	$drawnorm = getRK_val ("drawnorm");
-
-	$distExp = $size*$prob; // mean of the distribution of sample averages
-	$distVar = $size*$prob*(1-$prob)/$nAvg; // variance of the distribution of sample averages
-
-	if ($scalenorm) {
-		$normMu = 0; // mean for normal
-		$normSigma = 1; // std dev for normal
-	} else {
-		$normMu = $distExp;
-		$normSigma = sqrt($distVar);
-	}
-
-	$plotoptions = getRK_val("plotoptions.code.printout");
-	if ($fun == "hist") {
-		$normFun = "dnorm"; // draw normal density on the histogram
-		$histcalcoptions = getRK_val ("histogram_opt.code.calculate"); // options that goes into hist() function
-		$histplotoptions = getRK_val ("histogram_opt.code.printout"); // options that goes into plot.histogram()
-		$histplotoptions .= $plotoptions; // generic plot options
-	} elseif ($fun == "dist") {
-		$normFun = "pnorm"; // draw normal cdf on the ecdf plot
-		$plotoptions .= getRK_val ("dist_stepfun.code.printout"); // plot.ecdf() and plot.stepfun() options
-	}
-
-	$yLim = ""; // initialise the ylim option
+function doGenerateData () {
+	global $nAvg;
+	global $nDist;
 ?>
-# generate the entire data:
-data <- matrix(rbinom(n=<? echo ($nAvg*$nDist); ?>, size = <? echo ($size); ?>, prob=<? echo ($prob); ?>), nrow=<? echo ($nAvg); ?>);
-# get the sample averages:
-avg <- colMeans(data);
+data <- matrix(rbinom(n=<? echo ($nAvg*$nDist); ?>, size=size, prob=prob), nrow=<? echo ($nAvg); ?>);
 <?
-	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 ()
-<?
-	}
 }
 ?>

Modified: trunk/rkward/rkward/plugins/distributions/clt/plot_chi_squared_clt.php
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_chi_squared_clt.php	2007-03-22 22:58:20 UTC (rev 1709)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_chi_squared_clt.php	2007-03-23 03:01:52 UTC (rev 1710)
@@ -1,113 +1,33 @@
 <?php
-function preprocess () {
-}
+include ("plot_clt_common.php");
 
-function calculate () {
+function doParameters () {
+?>
+df <- <? echo(getRK_val ("df")); ?>; ncp <- <? echo(getRK_val ("ncp")); ?>;
+<?
 }
 
-function printout () {
-	doPrintout (true);
-}
+function doExpVar () {
+	global $nAvg;
 
-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") {
-		$normFun = "pnorm"; // draw normal cdf on the ecdf plot
-		$plotoptions .= getRK_val ("dist_stepfun.code.printout"); // plot.ecdf() and plot.stepfun() options
-	}
-
-	$yLim = ""; // initialise the ylim option
+	if (getRK_val ("ncp") == 0) {
 ?>
-# 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);
+avg.exp <- df;
+avg.var <- (2*df)/<? echo ($nAvg); ?>;
 <?
-	if ($scalenorm) {
+	} else {
 ?>
-# 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);
+avg.exp <- df + ncp;
+avg.var <- (2*df + 4*ncp)/<? echo ($nAvg); ?>;
 <?
 	}
-	if ($drawnorm) {
+}
+
+function doGenerateData () {
+	global $nAvg;
+	global $nDist;
 ?>
-# 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); ?>);
+data <- matrix(rchisq(n=<? echo ($nAvg*$nDist); ?>, df=df, ncp=ncp), nrow=<? echo ($nAvg); ?>);
 <?
-	}
-	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 ()
-<?
-	}
 }
 ?>

Modified: trunk/rkward/rkward/plugins/distributions/clt/plot_chi_squared_clt.xml
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_chi_squared_clt.xml	2007-03-22 22:58:20 UTC (rev 1709)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_chi_squared_clt.xml	2007-03-23 03:01:52 UTC (rev 1710)
@@ -38,8 +38,8 @@
 							<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" />
+							<spinbox default_precision="1" type="real" min="0.01" id="df" initial="4.0" label="Degrees of freedom" />
+							<spinbox default_precision="1" type="real" min="0" id="ncp" initial="0" label="Non-centrality parameter" />
 						</frame>
 					</column>
 					<column>

Added: trunk/rkward/rkward/plugins/distributions/clt/plot_clt_common.php
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_clt_common.php	                        (rev 0)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_clt_common.php	2007-03-23 03:01:52 UTC (rev 1710)
@@ -0,0 +1,119 @@
+<?php
+function preprocess () {
+}
+
+function calculate () {
+}
+
+function printout () {
+	doPrintout (true);
+}
+
+function preview () {
+	preprocess ();
+	calculate ();
+	doPrintout (false);
+}
+
+function doPrintout ($final) {
+	global $nAvg;
+	global $nDist;
+
+	$fun = getRK_val ("function");
+	$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");
+
+?>
+# parameters:
+<?
+	doParameters (); // get the parameters from xml file and store them R varaibles
+
+	if ($scalenorm || $drawnorm) {
+?>
+# mean and variances of the distribution of sample averages:
+<?
+		doExpVar (); // calculate the expectation and varaince of the distribution of smaple averages
+	}
+
+	// Mean and Std.deviantion of Normal distribution:
+	if ($scalenorm) $normMuSigma_tag = ""; // defaults to mean=0, sd=1.
+	else $normMuSigma_tag = ", mean = avg.exp, sd = sqrt(avg.var)";
+
+	$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") {
+		$normFun = "pnorm"; // draw normal cdf on the ecdf plot
+		$plotoptions .= getRK_val ("dist_stepfun.code.printout"); // plot.ecdf() and plot.stepfun() options
+	}
+
+	$yLim = ""; // initialise the ylim option
+
+?>
+# generate the entire data:
+<?
+	doGenerateData (); // generate the random samples
+
+?>
+# get the sample averages:
+avg <- colMeans(data);
+<?
+	if ($scalenorm) {
+?>
+# normalise the variables:
+avg <- (avg - avg.exp)/sqrt(avg.var);
+<?
+	}
+	if ($drawnorm) {
+?>
+# generate random normal samples:
+normX <- seq(from=min(avg), to=max(avg), length=<? echo ($nDist); ?>);
+normY <- <? echo ($normFun); ?> (normX<? echo ($normMuSigma_tag); ?>);
+<?
+	}
+	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 ()
+<?
+	}
+}
+?>
\ No newline at end of file

Modified: trunk/rkward/rkward/plugins/distributions/clt/plot_exponential_clt.php
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_exponential_clt.php	2007-03-22 22:58:20 UTC (rev 1709)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_exponential_clt.php	2007-03-23 03:01:52 UTC (rev 1710)
@@ -1,112 +1,25 @@
 <?php
-function preprocess () {
-}
+include ("plot_clt_common.php");
 
-function calculate () {
+function doParameters () {
+?>
+rate <- <? echo(getRK_val ("rate")); ?>;
+<?
 }
 
-function printout () {
-	doPrintout (true);
+function doExpVar () {
+	global $nAvg;
+?>
+avg.exp <- 1/rate;
+avg.var <- (1/(rate^2))/<? echo ($nAvg); ?>;
+<?
 }
 
-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") {
-		$normFun = "pnorm"; // draw normal cdf on the ecdf plot
-		$plotoptions .= getRK_val ("dist_stepfun.code.printout"); // plot.ecdf() and plot.stepfun() options
-	}
-
-	$yLim = ""; // initialise the ylim option
+function doGenerateData () {
+	global $nAvg;
+	global $nDist;
 ?>
-# generate the entire data:
-data <- matrix(rexp(n=<? echo ($nAvg*$nDist); ?>, rate=<? echo ($rate); ?>), nrow=<? echo ($nAvg); ?>);
-# get the sample averages:
-avg <- colMeans(data);
+data <- matrix(rexp(n=<? echo ($nAvg*$nDist); ?>, rate=rate), nrow=<? echo ($nAvg); ?>);
 <?
-	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 ()
-<?
-	}
 }
 ?>

Modified: trunk/rkward/rkward/plugins/distributions/clt/plot_exponential_clt.xml
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_exponential_clt.xml	2007-03-22 22:58:20 UTC (rev 1709)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_exponential_clt.xml	2007-03-23 03:01:52 UTC (rev 1710)
@@ -38,7 +38,7 @@
 							<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" />
+							<spinbox default_precision="1" type="real" id="rate" initial="1" min="0.01" label="Rate" />
 						</frame>
 					</column>
 					<column>

Modified: trunk/rkward/rkward/plugins/distributions/clt/plot_f_clt.php
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_f_clt.php	2007-03-22 22:58:20 UTC (rev 1709)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_f_clt.php	2007-03-23 03:01:52 UTC (rev 1710)
@@ -1,113 +1,33 @@
 <?php
-function preprocess () {
-}
+include ("plot_clt_common.php");
 
-function calculate () {
+function doParameters () {
+?>
+df1 <- <? echo(getRK_val ("df1")); ?>; df2 <- <? echo(getRK_val ("df2")); ?>; ncp <- <? echo(getRK_val ("ncp")); ?>;
+<?
 }
 
-function printout () {
-	doPrintout (true);
-}
+function doExpVar () {
+	global $nAvg;
 
-function preview () {
-	preprocess ();
-	calculate ();
-	doPrintout (false);
-}
-
-function doPrintout ($final) {
-	$fun = getRK_val ("function");
-	$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's logic section
+	if (getRK_val ("ncp") == 0) {
 ?>
-# parameters:
-df1 <- <? echo(getRK_val ("df1")); ?>; df2 <- <? echo(getRK_val ("df2")); ?>; ncp <- <? echo(getRK_val ("ncp")); ?>;
+avg.exp <- df2*df1/(df1*(df2-2));
+avg.var <- (2*df2^2*(df1+df2-2)/(df1*(df2-2)^2*(df2-4)))/<? echo($nAvg); ?>;
 <?
-	if ($scalenorm || $drawnorm) {
+	} else {
 ?>
-# mean and variances of the distribution of sample averages:
-avg.exp <- df2*(df1+ncp)/(df1*(df2-2))
-avg.var <- (2*df2^2*((df1+ncp)^2  + (df1+2*ncp)*(df2-2)) / (df1^2*(df2-2)^2*(df2-4)))/<? echo($nAvg); ?>
-
+avg.exp <- df2*(df1+ncp)/(df1*(df2-2));
+avg.var <- (2*df2^2*((df1+ncp)^2  + (df1+2*ncp)*(df2-2)) / (df1^2*(df2-2)^2*(df2-4)))/<? echo($nAvg); ?>;
 <?
 	}
-	// Mean and Std.deviantion of Normal distribution:
-	if ($scalenorm) $normMuSigma_tag = "";
-	else $normMuSigma_tag = ", mean = avg.exp, sd = sqrt(avg.var)";
+}
 
-	$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") {
-		$normFun = "pnorm"; // draw normal cdf on the ecdf plot
-		$plotoptions .= getRK_val ("dist_stepfun.code.printout"); // plot.ecdf() and plot.stepfun() options
-	}
-
-	$yLim = ""; // initialise the ylim option
+function doGenerateData () {
+	global $nAvg;
+	global $nDist;
 ?>
-# generate the entire data:
 data <- matrix(rf(n=<? echo ($nAvg*$nDist); ?>, df1=df1, df2=df2, ncp=ncp), nrow=<? echo ($nAvg); ?>);
-# get the sample averages:
-avg <- colMeans(data);
 <?
-	if ($scalenorm) {
-?>
-# normalise the variables:
-avg <- (avg - avg.exp)/sqrt(avg.var);
-<?
-	}
-	if ($drawnorm) {
-?>
-# generate random normal samples:
-normX <- seq(from=min(avg), to=max(avg), length=<? echo ($nDist); ?>);
-normY <- <? echo ($normFun); ?> (normX<? echo ($normMuSigma_tag); ?>);
-<?
-	}
-	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 ()
-<?
-	}
 }
 ?>

Modified: trunk/rkward/rkward/plugins/distributions/clt/plot_f_clt.xml
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_f_clt.xml	2007-03-22 22:58:20 UTC (rev 1709)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_f_clt.xml	2007-03-23 03:01:52 UTC (rev 1710)
@@ -38,8 +38,8 @@
 							<spinbox type="integer" min = "10" id="nDist" initial="1000" label="Samples for distribution" />
 						</frame>
 						<frame id="frame_fparam" label="F Parameters">
-							<spinbox default_precision="1" type="real" min="0.00001" id="df1" initial="5" label="Numerator degrees of freedom" />
-							<spinbox default_precision="1" type="real" min="0.00001" id="df2" initial="5" label="Denominator degrees of freedom" />
+							<spinbox default_precision="1" type="real" min="0.01" id="df1" initial="5" label="Numerator degrees of freedom" />
+							<spinbox default_precision="1" type="real" min="4.01" id="df2" initial="5" label="Denominator degrees of freedom" />
 							<spinbox default_precision="1" type="real" min="0" id="ncp" initial="0" label="Non-centrality parameter" />
 						</frame>
 					</column>

Modified: trunk/rkward/rkward/plugins/distributions/clt/plot_gamma_clt.php
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_gamma_clt.php	2007-03-22 22:58:20 UTC (rev 1709)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_gamma_clt.php	2007-03-23 03:01:52 UTC (rev 1710)
@@ -1,113 +1,25 @@
 <?php
-function preprocess () {
-}
+include ("plot_clt_common.php");
 
-function calculate () {
+function doParameters () {
+?>
+shape <- <? echo(getRK_val ("shape")); ?>; rate <- <? echo(getRK_val ("rate")); ?>;
+<?
 }
 
-function printout () {
-	doPrintout (true);
+function doExpVar () {
+	global $nAvg;
+?>
+avg.exp <- shape/rate;
+avg.var <- (shape/(rate^2))/<? echo ($nAvg); ?>;
+<?
 }
 
-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") {
-		$normFun = "pnorm"; // draw normal cdf on the ecdf plot
-		$plotoptions .= getRK_val ("dist_stepfun.code.printout"); // plot.ecdf() and plot.stepfun() options
-	}
-
-	$yLim = ""; // initialise the ylim option
+function doGenerateData () {
+	global $nAvg;
+	global $nDist;
 ?>
-# 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);
+data <- matrix(rgamma(n=<? echo ($nAvg*$nDist); ?>, shape=shape, rate=rate), nrow=<? echo ($nAvg); ?>);
 <?
-	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 ()
-<?
-	}
 }
 ?>

Modified: trunk/rkward/rkward/plugins/distributions/clt/plot_gamma_clt.xml
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_gamma_clt.xml	2007-03-22 22:58:20 UTC (rev 1709)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_gamma_clt.xml	2007-03-23 03:01:52 UTC (rev 1710)
@@ -38,8 +38,8 @@
 							<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" />
+							<spinbox default_precision="1" type="real" id="shape" initial="1" min="0.01" label="Shape" />
+							<spinbox default_precision="1" type="real" id="rate" initial="1" min="0.01" label="Rate (lambda)" label="Rate or 1/Scale" />
 						</frame>
 					</column>
 					<column>

Modified: trunk/rkward/rkward/plugins/distributions/clt/plot_geometric_clt.php
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_geometric_clt.php	2007-03-22 22:58:20 UTC (rev 1709)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_geometric_clt.php	2007-03-23 03:01:52 UTC (rev 1710)
@@ -1,112 +1,25 @@
 <?php
-function preprocess () {
-}
+include ("plot_clt_common.php");
 
-function calculate () {
+function doParameters () {
+?>
+prob <- <? echo(getRK_val ("prob")); ?>;
+<?
 }
 
-function printout () {
-	doPrintout (true);
+function doExpVar () {
+	global $nAvg;
+?>
+avg.exp <- (1-prob)/prob;
+avg.var <- ((1-prob)/(prob^2))/<? echo ($nAvg); ?>;
+<?
 }
 
-function preview () {
-	preprocess ();
-	calculate ();
-	doPrintout (false);
-}
-
-function doPrintout ($final) {
-	$fun = getRK_val ("function");
-	$prob = getRK_val ("prob");
-	$nAvg = getRK_val ("nAvg"); // number of observations to calculate the averages
-	$nDist = getRK_val ("nDist"); // number of sample to construct the distribution
-
-	$scalenorm = getRK_val ("scalenorm"); // if variables should to normalised..
-	$drawnorm = getRK_val ("drawnorm");
-
-	$distExp = (1-$prob)/$prob; // mean of the distribution of sample averages
-	$distVar = (1-$prob)/($prob*$prob*$nAvg); // variance of the distribution of sample averages
-
-	if ($scalenorm) {
-		$normMu = 0; // mean for normal
-		$normSigma = 1; // std dev for normal
-	} else {
-		$normMu = $distExp;
-		$normSigma = sqrt($distVar);
-	}
-
-	$plotoptions = getRK_val("plotoptions.code.printout");
-	if ($fun == "hist") {
-		$normFun = "dnorm"; // draw normal density on the histogram
-		$histcalcoptions = getRK_val ("histogram_opt.code.calculate"); // options that goes into hist() function
-		$histplotoptions = getRK_val ("histogram_opt.code.printout"); // options that goes into plot.histogram()
-		$histplotoptions .= $plotoptions; // generic plot options
-	} elseif ($fun == "dist") {
-		$normFun = "pnorm"; // draw normal cdf on the ecdf plot
-		$plotoptions .= getRK_val ("dist_stepfun.code.printout"); // plot.ecdf() and plot.stepfun() options
-	}
-
-	$yLim = ""; // initialise the ylim option
+function doGenerateData () {
+	global $nAvg;
+	global $nDist;
 ?>
-# generate the entire data:
-data <- matrix(rgeom(n=<? echo ($nAvg*$nDist); ?>, prob=<? echo ($prob); ?>), nrow=<? echo ($nAvg); ?>);
-# get the sample averages:
-avg <- colMeans(data);
+data <- matrix(rgeom(n=<? echo ($nAvg*$nDist); ?>, prob=prob), nrow=<? echo ($nAvg); ?>);
 <?
-	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 ()
-<?
-	}
 }
 ?>

Modified: trunk/rkward/rkward/plugins/distributions/clt/plot_hypergeometric_clt.php
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_hypergeometric_clt.php	2007-03-22 22:58:20 UTC (rev 1709)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_hypergeometric_clt.php	2007-03-23 03:01:52 UTC (rev 1710)
@@ -1,114 +1,25 @@
 <?php
-function preprocess () {
-}
+include ("plot_clt_common.php");
 
-function calculate () {
+function doParameters () {
+?>
+m <- <? echo(getRK_val ("m")); ?>; k <- <? echo(getRK_val ("n")); ?>; k <- <? echo(getRK_val ("k")); ?>;
+<?
 }
 
-function printout () {
-	doPrintout (true);
+function doExpVar () {
+	global $nAvg;
+?>
+avg.exp <- k*m/(m+n);
+avg.var <- (k*m*n*(m+n-k)/((m+n)^2*(m+n-1)))/<? echo ($nAvg); ?>;
+<?
 }
 
-function preview () {
-	preprocess ();
-	calculate ();
-	doPrintout (false);
-}
-
-function doPrintout ($final) {
-	$fun = getRK_val ("function");
-	$m = getRK_val ("m");
-	$n = getRK_val ("n");
-	$k = getRK_val ("k");
-	$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 = ($k*$m)/($m+$n); // mean of the distribution of sample averages
-	$distVar = ($k*$m*$n*($m+$n-$k))/(($m+$n)*($m+$n)*($m+$n-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") {
-		$normFun = "pnorm"; // draw normal cdf on the ecdf plot
-		$plotoptions .= getRK_val ("dist_stepfun.code.printout"); // plot.ecdf() and plot.stepfun() options
-	}
-
-	$yLim = ""; // initialise the ylim option
+function doGenerateData () {
+	global $nAvg;
+	global $nDist;
 ?>
-# generate the entire data:
-data <- matrix(rhyper(nn=<? echo ($nAvg*$nDist); ?>, m=<? echo ($m); ?>, n=<? echo ($n); ?>, k=<? echo ($k); ?>), nrow=<? echo ($nAvg); ?>);
-# get the sample averages:
-avg <- colMeans(data);
+data <- matrix(rhyper(nn=<? echo ($nAvg*$nDist); ?>, m=m, n=n, k=k), nrow=<? echo ($nAvg); ?>);
 <?
-	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 ()
-<?
-	}
 }
 ?>

Modified: trunk/rkward/rkward/plugins/distributions/clt/plot_logistic_clt.php
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_logistic_clt.php	2007-03-22 22:58:20 UTC (rev 1709)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_logistic_clt.php	2007-03-23 03:01:52 UTC (rev 1710)
@@ -1,113 +1,25 @@
 <?php
-function preprocess () {
-}
+include ("plot_clt_common.php");
 
-function calculate () {
+function doParameters () {
+?>
+loc <- <? echo(getRK_val ("loc")); ?>; scale <- <? echo(getRK_val ("scale")); ?>;
+<?
 }
 
-function printout () {
-	doPrintout (true);
+function doExpVar () {
+	global $nAvg;
+?>
+avg.exp <- loc;
+avg.var <- ((pi^2/3)*scale^2)/<? echo ($nAvg); ?>;
+<?
 }
 
-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") {
-		$normFun = "pnorm"; // draw normal cdf on the ecdf plot
-		$plotoptions .= getRK_val ("dist_stepfun.code.printout"); // plot.ecdf() and plot.stepfun() options
-	}
-
-	$yLim = ""; // initialise the ylim option
+function doGenerateData () {
+	global $nAvg;
+	global $nDist;
 ?>
-# 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);
+data <- matrix(rlogis(n=<? echo ($nAvg*$nDist); ?>, location=loc, scale=scale), nrow=<? echo ($nAvg); ?>);
 <?
-	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 ()
-<?
-	}
 }
 ?>

Modified: trunk/rkward/rkward/plugins/distributions/clt/plot_logistic_clt.xml
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_logistic_clt.xml	2007-03-22 22:58:20 UTC (rev 1709)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_logistic_clt.xml	2007-03-23 03:01:52 UTC (rev 1710)
@@ -38,8 +38,8 @@
 							<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" />
+							<spinbox default_precision="1" type="real" id="loc" initial="0" label="Location" />
+							<spinbox default_precision="1" type="real" id="scale" initial="1" min="0.01" label="Scale" />
 						</frame>
 					</column>
 					<column>

Modified: trunk/rkward/rkward/plugins/distributions/clt/plot_lognormal_clt.php
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_lognormal_clt.php	2007-03-22 22:58:20 UTC (rev 1709)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_lognormal_clt.php	2007-03-23 03:01:52 UTC (rev 1710)
@@ -1,113 +1,25 @@
 <?php
-function preprocess () {
-}
+include ("plot_clt_common.php");
 
-function calculate () {
+function doParameters () {
+?>
+mean <- <? echo(getRK_val ("mean")); ?>; sd <- <? echo(getRK_val ("sd")); ?>;
+<?
 }
 
-function printout () {
-	doPrintout (true);
+function doExpVar () {
+	global $nAvg;
+?>
+avg.exp <- exp(mean+sd^2/2);
+avg.var <- (exp(2*mean+sd^2)*(exp(sd^2)-1))/<? echo ($nAvg); ?>;
+<?
 }
 
-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") {
-		$normFun = "pnorm"; // draw normal cdf on the ecdf plot
-		$plotoptions .= getRK_val ("dist_stepfun.code.printout"); // plot.ecdf() and plot.stepfun() options
-	}
-
-	$yLim = ""; // initialise the ylim option
+function doGenerateData () {
+	global $nAvg;
+	global $nDist;
 ?>
-# 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);
+data <- matrix(rlnorm(n=<? echo ($nAvg*$nDist); ?>, meanlog=mean, sdlog=sd), nrow=<? echo ($nAvg); ?>);
 <?
-	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 ()
-<?
-	}
 }
 ?>

Modified: trunk/rkward/rkward/plugins/distributions/clt/plot_lognormal_clt.xml
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_lognormal_clt.xml	2007-03-22 22:58:20 UTC (rev 1709)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_lognormal_clt.xml	2007-03-23 03:01:52 UTC (rev 1710)
@@ -38,7 +38,7 @@
 							<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="1" 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>

Modified: trunk/rkward/rkward/plugins/distributions/clt/plot_negbinomial_clt.php
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_negbinomial_clt.php	2007-03-22 22:58:20 UTC (rev 1709)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_negbinomial_clt.php	2007-03-23 03:01:52 UTC (rev 1710)
@@ -1,122 +1,33 @@
 <?php
-function preprocess () {
-}
+include ("plot_clt_common.php");
 
-function calculate () {
-}
-
-function printout () {
-	doPrintout (true);
-}
-
-function preview () {
-	preprocess ();
-	calculate ();
-	doPrintout (false);
-}
-
-function doPrintout ($final) {
-	$fun = getRK_val ("function");
-	$paramType = getRK_val ("param");
- 	if ( $paramType == "pprob") {
-		$size = getRK_val ("size_trial");
-		$prob = getRK_val ("prob");
-		$paramTag = ", prob=" . $prob;
-	} else {
-		$size = getRK_val ("size_disp");
-		$mu = getRK_val ("mu");
-		$paramTag = ", mu=" . $mu;
-		$prob = $size/($size + $mu);
-	}
-	$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 = $size*(1-$prob)/$prob; // mean of the distribution of sample averages
-	$distVar = $size*(1-$prob)/($prob*$prob*$nAvg); // variance of the distribution of sample averages
-
-	if ($scalenorm) {
-		$normMu = 0; // mean for normal
-		$normSigma = 1; // std dev for normal
-	} else {
-		$normMu = $distExp;
-		$normSigma = sqrt($distVar);
-	}
-
-	$plotoptions = getRK_val("plotoptions.code.printout");
-	if ($fun == "hist") {
-		$normFun = "dnorm"; // draw normal density on the histogram
-		$histcalcoptions = getRK_val ("histogram_opt.code.calculate"); // options that goes into hist() function
-		$histplotoptions = getRK_val ("histogram_opt.code.printout"); // options that goes into plot.histogram()
-		$histplotoptions .= $plotoptions; // generic plot options
-	} elseif ($fun == "dist") {
-		$normFun = "pnorm"; // draw normal cdf on the ecdf plot
-		$plotoptions .= getRK_val ("dist_stepfun.code.printout"); // plot.ecdf() and plot.stepfun() options
-	}
-
-	$yLim = ""; // initialise the ylim option
+function doParameters () {
+ 	if ( getRK_val ("param") == "pprob") {
+		$paramTag = ", prob=prob";
 ?>
-# generate the entire data:
-data <- matrix(rnbinom(n=<? echo ($nAvg*$nDist); ?>, size=<? echo ($size); ?><? echo ($paramTag); ?>), nrow=<? echo ($nAvg); ?>);
-# get the sample averages:
-avg <- colMeans(data);
+size <- <? echo(getRK_val ("size_trial")); ?>; prob <- <? echo(getRK_val ("prob")); ?>;
 <?
-	if ($scalenorm) {
+	} else {
+		$paramTag = ", mu=mu";
 ?>
-# 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);
+size <- <? echo(getRK_val ("size_disp")); ?>; mu <- <? echo(getRK_val ("mu")); ?>; prob <- size/(size+mu);
 <?
 	}
-	if ($drawnorm) {
+}
+
+function doExpVar () {
+	global $nAvg;
 ?>
-# 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); ?>);
+avg.exp <- size*(1-prob)/prob;
+avg.var <- (size*(1-prob)/prob^2)/<? echo ($nAvg); ?>;
 <?
-	}
-	if ($fun == "hist") {
+}
+
+function doGenerateData () {
+	global $nAvg;
+	global $nDist;
 ?>
-dist.hist <- hist(avg, plot=FALSE<? echo ($histcalcoptions); ?>);
+data <- matrix(rnbinom(n=<? echo ($nAvg*$nDist); ?>, size=size<? echo ($paramTag); ?>), nrow=<? echo ($nAvg); ?>);
 <?
-	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 ()
-<?
-	}
 }
 ?>

Modified: trunk/rkward/rkward/plugins/distributions/clt/plot_negbinomial_clt.xml
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_negbinomial_clt.xml	2007-03-22 22:58:20 UTC (rev 1709)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_negbinomial_clt.xml	2007-03-23 03:01:52 UTC (rev 1710)
@@ -46,11 +46,11 @@
 						</frame>
 						<frame id="frame_negbinomparam" label="Negative Binomial Parameters">
 							<spinbox type="integer" id="size_trial" min="1" initial="12" label="Target number of successful trials" />
-							<spinbox id="size_disp" min="0.01" initial="12.00" label="Dispersion"/>
+							<spinbox default_precision="1" type="real" id="size_disp" min="0.01" initial="12.00" label="Dispersion"/>
 							<row>
 								<column>
 									<spinbox default_precision="2" type="real" id="prob" initial="0.75" min="0" max="1" label="Success probability" />
-									<spinbox default_precision="2" type="real" id="mu" initial="4" min="0.01" label="Mean (mu)" />
+									<spinbox default_precision="1" type="real" id="mu" initial="4" min="0.01" label="Mean (mu)" />
 								</column>
 								<column>
 									<radio id="param" label="Type of Parameterization" >

Modified: trunk/rkward/rkward/plugins/distributions/clt/plot_normal_clt.php
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_normal_clt.php	2007-03-22 22:58:20 UTC (rev 1709)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_normal_clt.php	2007-03-23 03:01:52 UTC (rev 1710)
@@ -1,113 +1,25 @@
 <?php
-function preprocess () {
-}
+include ("plot_clt_common.php");
 
-function calculate () {
+function doParameters () {
+?>
+mean <- <? echo(getRK_val ("mean")); ?>; sd <- <? echo(getRK_val ("sd")); ?>;
+<?
 }
 
-function printout () {
-	doPrintout (true);
+function doExpVar () {
+	global $nAvg;
+?>
+avg.exp <- mean;
+avg.var <- (sd^2)/<? echo ($nAvg); ?>;
+<?
 }
 
-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") {
-		$normFun = "pnorm"; // draw normal cdf on the ecdf plot
-		$plotoptions .= getRK_val ("dist_stepfun.code.printout"); // plot.ecdf() and plot.stepfun() options
-	}
-
-	$yLim = ""; // initialise the ylim option
+function doGenerateData () {
+	global $nAvg;
+	global $nDist;
 ?>
-# 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);
+data <- matrix(rnorm(n=<? echo ($nAvg*$nDist); ?>, mean=mean, sd=sd), nrow=<? echo ($nAvg); ?>);
 <?
-	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 ()
-<?
-	}
 }
 ?>

Modified: trunk/rkward/rkward/plugins/distributions/clt/plot_normal_clt.xml
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_normal_clt.xml	2007-03-22 22:58:20 UTC (rev 1709)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_normal_clt.xml	2007-03-23 03:01:52 UTC (rev 1710)
@@ -38,8 +38,8 @@
 							<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"/>
+							<spinbox default_precision="1" type="real" id="mean" initial="0" label="Mean" />
+							<spinbox default_precision="1" type="real" id="sd" min="0.01" initial="1" label="Standard deviation"/>
 						</frame>
 					</column>
 					<column>

Modified: trunk/rkward/rkward/plugins/distributions/clt/plot_poisson_clt.php
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_poisson_clt.php	2007-03-22 22:58:20 UTC (rev 1709)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_poisson_clt.php	2007-03-23 03:01:52 UTC (rev 1710)
@@ -1,112 +1,25 @@
 <?php
-function preprocess () {
-}
+include ("plot_clt_common.php");
 
-function calculate () {
+function doParameters () {
+?>
+mean <- <? echo(getRK_val ("mean")); ?>;
+<?
 }
 
-function printout () {
-	doPrintout (true);
+function doExpVar () {
+	global $nAvg;
+?>
+avg.exp <- mean;
+avg.var <- (mean)/<? echo ($nAvg); ?>;
+<?
 }
 
-function preview () {
-	preprocess ();
-	calculate ();
-	doPrintout (false);
-}
-
-function doPrintout ($final) {
-	$fun = getRK_val ("function");
-	$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 = $mean; // mean of the distribution of sample averages
-	$distVar = $mean/$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") {
-		$normFun = "pnorm"; // draw normal cdf on the ecdf plot
-		$plotoptions .= getRK_val ("dist_stepfun.code.printout"); // plot.ecdf() and plot.stepfun() options
-	}
-
-	$yLim = ""; // initialise the ylim option
+function doGenerateData () {
+	global $nAvg;
+	global $nDist;
 ?>
-# generate the entire data:
-data <- matrix(rpois(n=<? echo ($nAvg*$nDist); ?>, lambda=<? echo ($mean); ?>), nrow=<? echo ($nAvg); ?>);
-# get the sample averages:
-avg <- colMeans(data);
+data <- matrix(rpois(n=<? echo ($nAvg*$nDist); ?>, lambda=mean), nrow=<? echo ($nAvg); ?>);
 <?
-	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 ()
-<?
-	}
 }
 ?>

Modified: trunk/rkward/rkward/plugins/distributions/clt/plot_poisson_clt.xml
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_poisson_clt.xml	2007-03-22 22:58:20 UTC (rev 1709)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_poisson_clt.xml	2007-03-23 03:01:52 UTC (rev 1710)
@@ -39,7 +39,7 @@
 							<spinbox type="integer" min = "10" id="nDist" initial="1000" label="Samples for distribution" />
 						</frame>
 						<frame id="frame_poissonparam" label="Poisson Parameters">
-							<spinbox type="real" id="mean" min="0.01" initial="5" label="Mean" />
+							<spinbox default_precision="1" type="real" id="mean" min="0.01" initial="5" label="Mean" />
 						</frame>
 					</column>
 					<column>

Modified: trunk/rkward/rkward/plugins/distributions/clt/plot_t_clt.php
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_t_clt.php	2007-03-22 22:58:20 UTC (rev 1709)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_t_clt.php	2007-03-23 03:01:52 UTC (rev 1710)
@@ -1,123 +1,34 @@
 <?php
-function preprocess () {
-}
+include ("plot_clt_common.php");
 
-function calculate () {
+function doParameters () {
+?>
+df <- <? echo(getRK_val ("df")); ?>; ncp <- <? getRK ("ncp"); ?>;
+<?
 }
 
-function printout () {
-	doPrintout (true);
-}
+function doExpVar () {
+	global $nAvg;
 
-function preview () {
-	preprocess ();
-	calculate ();
-	doPrintout (false);
-}
-
-function doPrintout ($final) {
-	$fun = getRK_val ("function");
-	$ncp = getRK_val ("ncp");
-	$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");
-
-	// We need df>2 for variance to exist. Taken care of in xml file: using "is_var_gt2" in <logic>
+	if (getRK_val ("ncp") == 0) {
 ?>
-# parameters:
-df <- <? echo(getRK_val ("df")); ?>; ncp <- <? echo($ncp."\n"); ?>
-<?
-	if ($scalenorm || $drawnorm) {
-		if ($ncp == 0) { // mean and variance of the distribution of sample averages
-?>
-# mean and variances of the distribution of sample averages:
 avg.exp <- 0;
-avg.var <- df/((df-2)*<? echo($nAvg); ?>)
+avg.var <- df/((df-2)*<? echo($nAvg); ?>);
 <?
-		} else {
+	} else {
 ?>
-# mean and variances of the distribution of sample averages:
-tmp.var <- gamma((df-1)/2)/gamma(df/2)
-avg.exp <- ncp*sqrt(df/2)*tmp.var
-avg.var <- (df*(1+ncp^2)/(df-2) - ncp^2*df*tmp.var^2/2)/<? echo($nAvg); ?>
-
+tmp.var <- gamma((df-1)/2)/gamma(df/2);
+avg.exp <- ncp*sqrt(df/2)*tmp.var;
+avg.var <- (df*(1+ncp^2)/(df-2) - ncp^2*df*tmp.var^2/2)/<? echo($nAvg); ?>;
 <?
-		}
 	}
-	// Mean and Std.deviantion of Normal distribution:
-	if ($scalenorm) $normMuSigma_tag = "";
-	else $normMuSigma_tag = ", mean = avg.exp, sd = sqrt(avg.var)";
+}
 
-	$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") {
-		$normFun = "pnorm"; // draw normal cdf on the ecdf plot
-		$plotoptions .= getRK_val ("dist_stepfun.code.printout"); // plot.ecdf() and plot.stepfun() options
-	}
-
-	$yLim = ""; // initialise the ylim option
+function doGenerateData () {
+	global $nAvg;
+	global $nDist;
 ?>
-# generate the entire data:
 data <- matrix(rt(n=<? echo ($nAvg*$nDist); ?>, df=df, ncp=ncp), nrow=<? echo ($nAvg); ?>);
-# get the sample averages:
-avg <- colMeans(data);
 <?
-	if ($scalenorm) {
-?>
-# normalise the variables:
-avg <- (avg - avg.exp)/sqrt(avg.var);
-<?
-	}
-	if ($drawnorm) {
-?>
-# generate random normal samples:
-normX <- seq(from=min(avg), to=max(avg), length=<? echo ($nDist); ?>);
-normY <- <? echo ($normFun); ?> (normX<? echo ($normMuSigma_tag); ?>);
-<?
-	}
-	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 ()
-<?
-	}
 }
 ?>

Modified: trunk/rkward/rkward/plugins/distributions/clt/plot_t_clt.xml
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_t_clt.xml	2007-03-22 22:58:20 UTC (rev 1709)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_t_clt.xml	2007-03-23 03:01:52 UTC (rev 1710)
@@ -38,7 +38,7 @@
 							<spinbox type="integer" min = "10" id="nDist" initial="1000" label="Samples for distribution" />
 						</frame>
 						<frame id="frame_tparam" label="t Parameters">
-								<spinbox default_precision="1" type="real" id="df" min="0.00001" initial="3" label="Degrees of freedom" />
+								<spinbox default_precision="1" type="real" id="df" min="2.01" initial="3" label="Degrees of freedom" />
 								<spinbox default_precision="1" type="real" id="ncp" initial="0" label="Non-centrality parameter" />
 						</frame>
 					</column>

Modified: trunk/rkward/rkward/plugins/distributions/clt/plot_uniform_clt.php
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_uniform_clt.php	2007-03-22 22:58:20 UTC (rev 1709)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_uniform_clt.php	2007-03-23 03:01:52 UTC (rev 1710)
@@ -1,113 +1,25 @@
 <?php
-function preprocess () {
-}
+include ("plot_clt_common.php");
 
-function calculate () {
+function doParameters () {
+?>
+llim <- <? echo(getRK_val ("llim")); ?>; ulim <- <? getRK ("ulim"); ?>;
+<?
 }
 
-function printout () {
-	doPrintout (true);
+function doExpVar () {
+	global $nAvg;
+?>
+avg.exp <- (llim+ulim)/2;
+avg.var <- ((ulim-llim)^2/12)/<? echo($nAvg); ?>;
+<?
 }
 
-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") {
-		$normFun = "pnorm"; // draw normal cdf on the ecdf plot
-		$plotoptions .= getRK_val ("dist_stepfun.code.printout"); // plot.ecdf() and plot.stepfun() options
-	}
-
-	$yLim = ""; // initialise the ylim option
+function doGenerateData () {
+	global $nAvg;
+	global $nDist;
 ?>
-# 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);
+data <- matrix(runif(n=<? echo ($nAvg*$nDist); ?>, min=llim, max=ulim), nrow=<? echo ($nAvg); ?>);
 <?
-	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 ()
-<?
-	}
 }
 ?>

Modified: trunk/rkward/rkward/plugins/distributions/clt/plot_uniform_clt.xml
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_uniform_clt.xml	2007-03-22 22:58:20 UTC (rev 1709)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_uniform_clt.xml	2007-03-23 03:01:52 UTC (rev 1710)
@@ -38,8 +38,8 @@
 							<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" />
+							<spinbox default_precision="1" type="real" id="llim" initial="0" label="Minimum" />
+							<spinbox default_precision="1" type="real" id="ulim" initial="1" label="Maximum" />
 						</frame>
 					</column>
 					<column>

Modified: trunk/rkward/rkward/plugins/distributions/clt/plot_weibull_clt.php
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_weibull_clt.php	2007-03-22 22:58:20 UTC (rev 1709)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_weibull_clt.php	2007-03-23 03:01:52 UTC (rev 1710)
@@ -1,112 +1,25 @@
 <?php
-function preprocess () {
-}
+include ("plot_clt_common.php");
 
-function calculate () {
-}
-
-function printout () {
-	doPrintout (true);
-}
-
-function preview () {
-	preprocess ();
-	calculate ();
-	doPrintout (false);
-}
-
-function doPrintout ($final) {
-	$fun = getRK_val ("function");
-	$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");
-
+function doParameters () {
 ?>
-# parameters:
 scale <- <? echo(getRK_val ("scale")); ?>; shape <- <? echo(getRK_val ("shape")); ?>;
 <?
-	if ($scalenorm || $drawnorm) {
-?>
-# mean and variances of the distribution of sample averages:
-avg.exp <- scale*gamma(1+1/shape)
-avg.var <- (scale^2*gamma(1+2/shape) - avg.exp^2)/<? echo ($nAvg); ?>
+}
 
+function doExpVar () {
+	global $nAvg;
+?>
+avg.exp <- scale*gamma(1+1/shape);
+avg.var <- (scale^2*gamma(1+2/shape) - avg.exp^2)/<? echo ($nAvg); ?>;
 <?
-	}
-	// Mean and Std.deviantion of Normal distribution:
-	if ($scalenorm) $normMuSigma_tag = "";
-	else $normMuSigma_tag = ", mean = avg.exp, sd = sqrt(avg.var)";
+}
 
-	$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") {
-		$normFun = "pnorm"; // draw normal cdf on the ecdf plot
-		$plotoptions .= getRK_val ("dist_stepfun.code.printout"); // plot.ecdf() and plot.stepfun() options
-	}
-
-	$yLim = ""; // initialise the ylim option
+function doGenerateData () {
+	global $nAvg;
+	global $nDist;
 ?>
-# generate the entire data:
 data <- matrix(rweibull(n=<? echo ($nAvg*$nDist); ?>, shape=shape, scale=scale), nrow=<? echo ($nAvg); ?>);
-# get the sample averages:
-avg <- colMeans(data);
 <?
-	if ($scalenorm) {
-?>
-# normalise the variables:
-avg <- (avg - avg.exp)/sqrt(avg.var);
-<?
-	}
-	if ($drawnorm) {
-?>
-# generate random normal samples:
-normX <- seq(from=min(avg), to=max(avg), length=<? echo ($nDist); ?>);
-normY <- <? echo ($normFun); ?> (normX<? echo ($normMuSigma_tag); ?>);
-<?
-	}
-	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 ()
-<?
-	}
 }
 ?>

Modified: trunk/rkward/rkward/plugins/distributions/clt/plot_weibull_clt.xml
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_weibull_clt.xml	2007-03-22 22:58:20 UTC (rev 1709)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_weibull_clt.xml	2007-03-23 03:01:52 UTC (rev 1710)
@@ -38,8 +38,8 @@
 							<spinbox type="integer" min = "10" id="nDist" initial="1000" label="Samples for distribution" />
 						</frame>
 						<frame id="frame_weibullparam" label="Weibull Parameters">
-							<spinbox default_precision="1" type="real" id="shape" initial="2" min ="0.00001" label="Shape" />
-							<spinbox default_precision="1" type="real" id="scale" initial="1" min ="0.00001" label="Scale" />
+							<spinbox default_precision="1" type="real" id="shape" initial="2" min ="0.01" label="Shape" />
+							<spinbox default_precision="1" type="real" id="scale" initial="1" min ="0.01" label="Scale" />
 						</frame>
 					</column>
 					<column>

Modified: trunk/rkward/rkward/plugins/distributions/clt/plot_wilcoxon_clt.php
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_wilcoxon_clt.php	2007-03-22 22:58:20 UTC (rev 1709)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_wilcoxon_clt.php	2007-03-23 03:01:52 UTC (rev 1710)
@@ -1,113 +1,25 @@
 <?php
-function preprocess () {
-}
+include ("plot_clt_common.php");
 
-function calculate () {
+function doParameters () {
+?>
+m <- <? echo(getRK_val ("nm")); ?>; n <- <? echo(getRK_val ("nn")); ?>;
+<?
 }
 
-function printout () {
-	doPrintout (true);
+function doExpVar () {
+	global $nAvg;
+?>
+avg.exp <- m*n/2;
+avg.var <- (m*n*(m+n+1)/12)/<? echo ($nAvg); ?>;
+<?
 }
 
-function preview () {
-	preprocess ();
-	calculate ();
-	doPrintout (false);
-}
-
-function doPrintout ($final) {
-	$fun = getRK_val ("function");
-	$nm = getRK_val ("nm");
-	$nn = getRK_val ("nn");
-	$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 = $nm*$nn/2; // mean of the distribution of sample averages
-	$distVar = $nm*$nn*($nm+$nn+1)/(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") {
-		$normFun = "pnorm"; // draw normal cdf on the ecdf plot
-		$plotoptions .= getRK_val ("dist_stepfun.code.printout"); // plot.ecdf() and plot.stepfun() options
-	}
-
-	$yLim = ""; // initialise the ylim option
+function doGenerateData () {
+	global $nAvg;
+	global $nDist;
 ?>
-# generate the entire data:
-data <- matrix(rwilcox(nn=<? echo ($nAvg*$nDist); ?>, m = <? echo ($nm); ?>, n = <? echo ($nn); ?>), nrow=<? echo ($nAvg); ?>);
-# get the sample averages:
-avg <- colMeans(data);
+data <- matrix(rwilcox(nn=<? echo ($nAvg*$nDist); ?>, m=m, n=n), nrow=<? echo ($nAvg); ?>);
 <?
-	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 ()
-<?
-	}
 }
 ?>


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