Suppose we conduct a Chi Squared test for standard deviation and the
result is borderline, a legitimate question to ask is "How large
would the sample size have to be in order to produce a definitive result?"

The class template chi_squared_distribution
has a static method find_degrees_of_freedom
that will calculate this value for some acceptable risk of type I failure
alpha, type II failure beta,
and difference from the standard deviation diff.
Please note that the method used works on variance, and not standard
deviation as is usual for the Chi Squared Test.

And defines a table of significance levels for which we'll calculate
sample sizes:

doublealpha[]={0.5,0.25,0.1,0.05,0.01,0.001,0.0001,0.00001};

For each value of alpha we can calculate two sample sizes: one where
the sample variance is less than the true value by diff
and one where it is greater than the true value by diff.
Thanks to the asymmetric nature of the Chi Squared distribution these
two values will not be the same, the difference in their calculation
differs only in the sign of diff that's passed
to find_degrees_of_freedom.
Finally in this example we'll simply things, and let risk level beta
be the same as alpha:

For some example output, consider the silicon
wafer data from the NIST/SEMATECH
e-Handbook of Statistical Methods.. In this scenario a supplier
of 100 ohm.cm silicon wafers claims that his fabrication process can
produce wafers with sufficient consistency so that the standard deviation
of resistivity for the lot does not exceed 10 ohm.cm. A sample of N
= 10 wafers taken from the lot has a standard deviation of 13.97 ohm.cm,
and the question we ask ourselves is "How large would our sample
have to be to reliably detect this difference?".

To use our procedure above, we have to convert the standard deviations
to variance (square them), after which the program output looks like
this:

In this case we are interested in a upper single sided test. So for
example, if the maximum acceptable risk of falsely rejecting the null-hypothesis
is 0.05 (Type I error), and the maximum acceptable risk of failing
to reject the null-hypothesis is also 0.05 (Type II error), we estimate
that we would need a sample size of 51.