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

kapatp at users.sourceforge.net kapatp at users.sourceforge.net
Thu Mar 22 19:26:21 UTC 2007


Revision: 1704
          http://svn.sourceforge.net/rkward/?rev=1704&view=rev
Author:   kapatp
Date:     2007-03-22 12:26:21 -0700 (Thu, 22 Mar 2007)

Log Message:
-----------
Fixes:
* Indentation for F,t,Weibull
* if ( == 0) for t
* More transparency for F

Modified Paths:
--------------
    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_t_clt.php
    trunk/rkward/rkward/plugins/distributions/clt/plot_t_clt.xml
    trunk/rkward/rkward/plugins/distributions/clt/plot_weibull_clt.php
    trunk/rkward/rkward/plugins/distributions/clt/plot_weibull_clt.xml

Modified: trunk/rkward/rkward/plugins/distributions/clt/plot_f_clt.php
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_f_clt.php	2007-03-22 19:24:37 UTC (rev 1703)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_f_clt.php	2007-03-22 19:26:21 UTC (rev 1704)
@@ -17,26 +17,28 @@
 
 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
+	// For variance we need df2 > 4: That has been taken care of in the xml file's logic section
+?>
+# parameters:
+df1 <- <? echo(getRK_val ("df1")); ?>; df2 <- <? echo(getRK_val ("df2")); ?>; ncp <- <? echo(getRK_val ("ncp")); ?>;
+<?
+	if ($scalenorm || $drawnorm) {
+?>
+# 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); ?>
 
-	if ($scalenorm) {
-		$normMu = 0; // mean for normal
-		$normSigma = 1; // std dev for normal
-	} else {
-		$normMu = $distExp;
-		$normSigma = sqrt($distVar);
+<?
 	}
+	// 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") {
@@ -52,37 +54,33 @@
 	$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); ?>);
+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) {
 ?>
-# 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 <- (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, mean = <? echo ($normMu); ?>, sd = <? echo ($normSigma); ?>);
+normY <- <? echo ($normFun); ?> (normX<? echo ($normMuSigma_tag); ?>);
 <?
 	}
 	if ($fun == "hist") {
 ?>
 dist.hist <- hist(avg, plot=FALSE<? echo ($histcalcoptions); ?>);
 <?
-	if ($drawnorm) {
+		if ($drawnorm) {
 ?>
 # calculate the ylims appropriately:
 ylim <- c(0,max(c(dist.hist$density, normY)));
 <?
-		$yLim = ', ylim=ylim';
+			$yLim = ', ylim=ylim';
 		}
 	}
 	if ($final) {
@@ -91,7 +89,7 @@
 try ({
 <?
 	}
-  	if ($fun == "hist") {
+  if ($fun == "hist") {
 ?>
 	plot(dist.hist<? echo ($yLim); echo ($histplotoptions); ?>)
 <?

Modified: trunk/rkward/rkward/plugins/distributions/clt/plot_f_clt.xml
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_f_clt.xml	2007-03-22 19:24:37 UTC (rev 1703)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_f_clt.xml	2007-03-22 19:26:21 UTC (rev 1704)
@@ -8,6 +8,10 @@
 		<set id="plotoptions.default_main" to="F"/>
 		<set id="plotoptions.default_xlab" to="Sample Averages"/>
 
+		<convert id="is_df2_gt4" sources="df2.real" mode="range" min="4.01" require_true="true"/>
+		<convert id="is_df2_leq4" sources="is_df2_gt4" mode="equals" standard="false"/>
+		<connect client="df2_gt4_err.visible" governor="is_df2_leq4"/>
+
 		<set id="normlinecol.default_color" to="red" />
 
 		<set id="histogram_opt.varname" to="avg" />
@@ -38,10 +42,9 @@
 							<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" />
+							<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" id="ncp" initial="0" label="Non-centrality parameter" />
 						</frame>
 					</column>
 					<column>
@@ -65,6 +68,7 @@
 						</frame>
 					</column>
 				</row>
+				<text id="df2_gt4_err" type="error">ERROR: For a F distribution variance exists only when its denominator degress of freedom > 4.</text>
 			<stretch/>
 				<row>
 					<embed id="plotoptions" component="rkward::plot_options" as_button="true" label="Plot Options" />

Modified: trunk/rkward/rkward/plugins/distributions/clt/plot_t_clt.php
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_t_clt.php	2007-03-22 19:24:37 UTC (rev 1703)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_t_clt.php	2007-03-22 19:26:21 UTC (rev 1704)
@@ -17,6 +17,7 @@
 
 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
 
@@ -26,11 +27,10 @@
 	// We need df>2 for variance to exist. Taken care of in xml file: using "is_var_gt2" in <logic>
 ?>
 # parameters:
-df <- <? echo(getRK_val ("df")."\n"); ?>
-ncp <- <? echo(getRK_val ("ncp")."\n"); ?>
+df <- <? echo(getRK_val ("df")); ?>; ncp <- <? echo($ncp."\n"); ?>
 <?
 	if ($scalenorm || $drawnorm) {
-		if ($ncp == "0") { // mean and variance of the distribution of sample averages
+		if ($ncp == 0) { // mean and variance of the distribution of sample averages
 ?>
 # mean and variances of the distribution of sample averages:
 avg.exp <- 0;
@@ -42,6 +42,7 @@
 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); ?>
+
 <?
 		}
 	}
@@ -84,12 +85,12 @@
 ?>
 dist.hist <- hist(avg, plot=FALSE<? echo ($histcalcoptions); ?>);
 <?
-	if ($drawnorm) {
+		if ($drawnorm) {
 ?>
 # calculate the ylims appropriately:
 ylim <- c(0,max(c(dist.hist$density, normY)));
 <?
-		$yLim = ', ylim=ylim';
+			$yLim = ', ylim=ylim';
 		}
 	}
 	if ($final) {
@@ -98,7 +99,7 @@
 try ({
 <?
 	}
-  	if ($fun == "hist") {
+	if ($fun == "hist") {
 ?>
 	plot(dist.hist<? echo ($yLim); echo ($histplotoptions); ?>)
 <?

Modified: trunk/rkward/rkward/plugins/distributions/clt/plot_t_clt.xml
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_t_clt.xml	2007-03-22 19:24:37 UTC (rev 1703)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_t_clt.xml	2007-03-22 19:26:21 UTC (rev 1704)
@@ -42,8 +42,8 @@
 							<spinbox type="integer" min = "10" id="nDist" initial="1000" label="Samples for distribution" />
 						</frame>
 						<frame id="frame_tparam" label="t Parameters">
-								<spinbox default_precision="2" type="real" id="df" min="0.01" initial="2.01" label="Degrees of freedom" />
-								<spinbox default_precision="2" type="real" id="ncp" initial="0" label="Non-centrality parameter" />
+								<spinbox default_precision="1" type="real" id="df" min="0.00001" initial="3" label="Degrees of freedom" />
+								<spinbox default_precision="1" type="real" id="ncp" initial="0" label="Non-centrality parameter" />
 						</frame>
 					</column>
 					<column>
@@ -67,7 +67,7 @@
 						</frame>
 					</column>
 				</row>
-				<text id="var_gt2_warn">ERROR: Variance for t distribution exists only when the degress freedom > 2.</text>
+				<text id="var_gt2_warn" type="error">ERROR: For a t distribution variance exists only when its degress of freedom > 2.</text>
 			<stretch/>
 				<row>
 					<embed id="plotoptions" component="rkward::plot_options" as_button="true" label="Plot Options" />

Modified: trunk/rkward/rkward/plugins/distributions/clt/plot_weibull_clt.php
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_weibull_clt.php	2007-03-22 19:24:37 UTC (rev 1703)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_weibull_clt.php	2007-03-22 19:26:21 UTC (rev 1704)
@@ -25,8 +25,7 @@
 
 ?>
 # parameters:
-scale <- <? echo(getRK_val ("scale")."\n"); ?>
-shape <- <? echo(getRK_val ("shape")."\n"); ?>
+scale <- <? echo(getRK_val ("scale")); ?>; shape <- <? echo(getRK_val ("shape")); ?>;
 <?
 	if ($scalenorm || $drawnorm) {
 ?>
@@ -75,12 +74,12 @@
 ?>
 dist.hist <- hist(avg, plot=FALSE<? echo ($histcalcoptions); ?>);
 <?
-	if ($drawnorm) {
+		if ($drawnorm) {
 ?>
 # calculate the ylims appropriately:
 ylim <- c(0,max(c(dist.hist$density, normY)));
 <?
-		$yLim = ', ylim=ylim';
+			$yLim = ', ylim=ylim';
 		}
 	}
 	if ($final) {
@@ -89,7 +88,7 @@
 try ({
 <?
 	}
-  	if ($fun == "hist") {
+  if ($fun == "hist") {
 ?>
 	plot(dist.hist<? echo ($yLim); echo ($histplotoptions); ?>)
 <?

Modified: trunk/rkward/rkward/plugins/distributions/clt/plot_weibull_clt.xml
===================================================================
--- trunk/rkward/rkward/plugins/distributions/clt/plot_weibull_clt.xml	2007-03-22 19:24:37 UTC (rev 1703)
+++ trunk/rkward/rkward/plugins/distributions/clt/plot_weibull_clt.xml	2007-03-22 19:26:21 UTC (rev 1704)
@@ -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="2" type="real" id="shape" initial="2" min ="0.01" label="Shape" />
-							<spinbox default_precision="2" type="real" id="scale" initial="1" min ="0.01" label="Scale" />
+							<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" />
 						</frame>
 					</column>
 					<column>


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