%mathpiper,def="SampleSizeForTheMean"

//Retract("SampleSizeForTheMean",*);

SampleSizeForTheMean(standardDeviation,confidenceLevel,marginOfError) :=
[
    Local(minimumSampleSize);
    
    zScore := ConfidenceLevelToZScore(confidenceLevel);
    
    minimumSampleSize := N(((zScore*standardDeviation)/marginOfError)^2);
];


%/mathpiper

    %output,preserve="false"
      Result: True
.   %/output





%mathpiper_docs,name="SampleSizeForTheMean",categories="User Functions;Statistics & Probability",access="experimental"
*CMD SampleSizeForTheMean --- calculates the sample size for the mean
*STD
*CALL
	SampleSizeForTheMean(standardDeviation,confidenceLevel,marginOfError)
*PARMS
{standardDeviation} -- the standard deviation of the sample
{confidenceLevel} -- the desired level of confidence
{marginOfError} -- the desired margin of error

*DESC
This function calculates the minimum sample size for the mean to provide
a specific margin of error for a given confidence level.

*E.G.
In> SampleSizeForTheMean(37.50,.95,8)
Result: 84.40706911
%/mathpiper_docs

    %output,preserve="false"
      
.   %/output


