public virtual void ComputeEffect()
{
double requiredPower = Power;
// Attempt to locate the optimal sample size
// to attain the required power by locating
// a zero in the difference function:
double sol = BrentSearch.FindRoot(eff =>
{
Effect = eff;
ComputePower();
return requiredPower - Power;
},
lowerBound: 1e-5,
upperBound: 1e+5);
// Check it
Effect = sol;
ComputePower();
double newPower = Power;
Power = requiredPower;
if (Math.Abs(requiredPower - newPower) > 1e-5)
Effect = Double.NaN;
}