Manuel B. Garcia

Manuel B. Garcia serves as the Senior Director for Educational Technology and Digital Learning at FEU Institute of Technology, Manila, Philippines. Read More

Contact Info

1607, FEU Tech Building,
P. Paredes St, Sampaloc,
Manila, Philippines
mbgarcia@feutech.edu.ph

Follow Me

Can Generative AI Perform a Sample Size Calculation Correctly?

Generative AI can assist with sample size calculations, but the result depends on the statistical test, effect size, power, and research design. Learn how to verify AI-generated estimates before planning data collection.

411
Can AI Calculate Sample Size? Guide 411 of 1196
01 · The Question

Can You Ask Generative AI How Many Participants Your Research Needs?

You are preparing a research proposal and need to determine how many participants to recruit. Your study will compare the academic performance of students receiving AI-assisted instruction with those receiving conventional instruction.

You ask a generative AI tool: "How many respondents do I need for my study?"

It recommends 100 participants, perhaps explaining that this number should be sufficient for statistical analysis. Another prompt produces 200. When you ask for a power analysis, the system provides a more precise number and describes it as the minimum required sample size.

Which answer should you trust? Can AI perform the calculation correctly, and how would you know whether it has used assumptions appropriate to your research?

Sample size planning is consequential because an inadequate sample may produce imprecise findings, while unnecessary recruitment can consume resources and impose avoidable burdens on participants. The calculation should therefore follow the scientific purpose of the study rather than an arbitrary numerical convention.

02 · The Short Answer

AI Can Calculate Sample Size, but Only After the Design and Assumptions Are Specified

In Brief

Generative AI can perform sample size and statistical power calculations when it uses an appropriate computational method and correctly specified inputs, including the research design, statistical procedure, effect size or precision target, significance level, and desired power where relevant. However, it may produce misleading sample sizes when it assumes missing information, selects an unsuitable formula, or overlooks clustering, repeated measurements, attrition, or other design characteristics.

A sample size calculation is conditional on its assumptions, not a universal determination of how many participants a study needs. Researchers should justify the inputs, independently reproduce the calculation, and distinguish the required analyzable sample from the number of participants who must initially be recruited.

03 · What You Need to Know

How Generative AI Calculates Research Sample Sizes

What Does a Sample Size Calculation Actually Determine?

A sample size calculation estimates how much information a study may need to achieve a specified statistical objective under stated assumptions.

That objective might be detecting a particular effect with a chosen statistical power, estimating a population parameter with a desired level of precision, or obtaining sufficient information for a planned model.

These objectives are not interchangeable. A sample size appropriate for estimating a population proportion within a particular margin of error may not be adequate for detecting a difference between two groups.

Likewise, a study designed to estimate an overall mean may require a different sample size from one intended to compare several subgroups.

Lakens (2022), in Sample Size Justification, explains that researchers can justify sample sizes through several approaches, including power analysis, precision-based planning, resource constraints, and near-complete population measurement. The central issue is whether the planned sample can provide useful information for the research objective. The published review provides a detailed discussion of these approaches.

AI should therefore begin by asking what the researcher wants the sample to accomplish rather than immediately applying a formula.

What Information Does AI Need Before Calculating Sample Size?

The necessary inputs depend on the analytical objective and statistical method.

Input What it means Why it matters
Research design Whether observations are independent, paired, repeated, clustered, or otherwise structured. Determines how information accumulates and which calculation is appropriate.
Primary outcome The main variable or endpoint the study intends to analyze. Different outcome types may require different statistical models.
Primary analysis The statistical procedure planned for the main research question. Power and precision depend on the estimator or test.
Effect size The effect magnitude the study is designed to detect or evaluate. Smaller target effects generally require more information.
Significance level The prespecified Type I error threshold for a hypothesis test. Affects the rejection criterion and required sample size.
Statistical power The probability of rejecting the null hypothesis under a specified alternative and model. Higher desired power generally increases the required sample size.
Allocation ratio The planned relative sizes of comparison groups. Unequal allocation can change statistical efficiency.
Attrition or missingness Expected loss of usable observations. May require recruiting more participants than the analyzable sample target.

Specialized designs may require additional parameters. For example, cluster-randomized studies need information about cluster sizes and intraclass correlation, while longitudinal studies may require assumptions about correlations between repeated measurements.

When these inputs are missing, AI should identify the uncertainty instead of silently choosing convenient defaults.

What Is Statistical Power, and Why Does It Affect Sample Size?

Statistical power is the probability that a hypothesis test rejects its null hypothesis under a specified alternative hypothesis and statistical model.

For example, a study planned with 80% power to detect a particular effect has an 80% probability of obtaining a statistically significant result under the assumed effect and model, when the other design assumptions hold.

It does not mean that there is an 80% probability the research hypothesis is true or that the study has an 80% chance of producing scientifically important findings.

Power is conditional on assumptions about the effect magnitude, variability, statistical procedure, and other design features.

Researchers often use 80% or 90% as planning targets, but these are conventions rather than universal requirements. The appropriate target depends on the consequences of missed effects, the research purpose, and resource constraints.

AI should not assume that 80% power is automatically sufficient for every study.

Why Is the Assumed Effect Size So Important?

The assumed effect size is often among the most influential inputs in a power-based sample size calculation.

For a simple comparison of two independent means, detecting a smaller standardized difference generally requires more participants than detecting a larger one, holding other conditions constant.

Suppose a researcher expects AI-assisted instruction to produce a standardized mean difference of 0.50. That assumption will lead to a different sample size from an assumed difference of 0.20.

Neither value should be chosen merely because it corresponds to a familiar small, medium, or large effect-size convention.

Ideally, the planning effect should be informed by relevant prior research, a substantively meaningful minimum effect, pilot evidence interpreted cautiously, or another defensible justification.

Lakens (2022) emphasizes the importance of considering the smallest effect size of interest and the informational value of the proposed study.

AI may help calculate or explain standardized effect sizes, but the researcher must justify which effect magnitude should inform the sample size calculation.

Can AI Calculate Sample Size for an Independent-Samples t-Test?

Yes. When the design and parameters are specified, a computational AI system can calculate sample size using statistical power functions.

For a conventional equal-allocation comparison of two independent means, a useful normal-approximation formula illustrates how the main inputs influence the required sample size.

Approximate Sample Size for Two Independent Means
n ≈ 2 × (Z1−α/2 + Z1−β)² / d²
n is the approximate number of participants per group; α is the two-sided significance level; 1 − β is the target power; d is the assumed standardized mean difference; and Z denotes the corresponding standard normal quantile. The approximation assumes independent groups, equal allocation, and an appropriate common standardization scale.
For α =.05, power =.80, and d = 0.50, the approximate calculation is 2 × (1.96 + 0.84)² / 0.50² = 62.72, rounded up to 63 participants per group.

This is an approximate planning calculation, not an exact noncentral-t power analysis. An exact calculation for the conventional pooled-variance independent-samples t-test may require a slightly larger sample.

For these inputs, a standard noncentral-t calculation gives approximately 64 participants per group, or 128 analyzable participants in total.

The distinction matters because AI may present a normal approximation as though it were the exact result from statistical software.

Official statsmodels documentation identifies the effect size, group allocation ratio, significance level, power, and test alternative as inputs to its independent-samples t-test power calculation.

Why Does a Paired Study Need a Different Sample Size Calculation?

In a paired study, the same participants are measured more than once or observations are otherwise meaningfully matched.

The relevant variability for a paired mean comparison is the standard deviation of the within-pair differences.

Two studies may have the same pretest and posttest means and standard deviations but different correlations between measurements. Their paired-difference variability, and therefore their required sample sizes, can differ.

For example, highly correlated pretest and posttest scores may produce relatively precise estimates of within-participant change when the correlation is positive.

AI should therefore not calculate sample size for a paired study using an independent-groups formula without justification.

Researchers must establish whether observations are paired or independent and specify the relevant effect-size definition.

A calculation based on the wrong observation structure may produce a precise-looking but inappropriate recruitment target.

Can AI Calculate Sample Size for Correlation or Regression?

AI can assist with sample size planning for correlation and regression, but these analyses require different assumptions from a simple comparison of means.

For correlation, a power calculation may depend on the population correlation the researcher wants to detect, the significance level, the test alternative, and the desired power.

For regression, the required sample size depends on the specific inferential objective. Testing one regression coefficient is not necessarily equivalent to testing an entire model.

Logistic regression introduces additional considerations, including the outcome frequency, predictor distributions, model complexity, and potential separation.

Prediction-model development also requires attention to overfitting, expected model performance, and the intended validation strategy.

Rules such as recruiting a fixed number of participants per predictor are not universal substitutes for a study-specific justification.

AI should first identify the regression model and analytical objective before recommending a sample size method.

Why Can AI Underestimate Sample Size for Clustered Studies?

Clustered studies involve observations grouped within classrooms, schools, hospitals, or other units.

Participants within a cluster may be more similar than independently sampled individuals. As a result, the information provided by a clustered sample may be lower than that of an equally sized independent sample for some estimators.

A commonly used approximation for equal-sized clusters is:

Approximate Cluster Design Effect
Design effect = 1 + (m − 1) × ICC
m is the number of observations per cluster, and ICC is the intraclass correlation coefficient. This approximation applies under simplifying assumptions about cluster size and within-cluster dependence.
If each classroom contains 25 students and ICC = 0.05, the approximate design effect is 1 + (25 − 1) × 0.05 = 2.20.

For estimators and designs to which the approximation applies, the variance may be approximately 2.2 times the corresponding independent-sampling variance.

This does not mean that every cluster-randomized study can obtain its final sample size simply by multiplying an individual-level calculation by 2.20.

Cluster-randomized trials also require attention to the number of clusters, allocation, cluster-size variation, and the level at which treatment is assigned.

Researchers should ensure that AI recognizes repeated-measures or clustered data before accepting a sample size recommendation.

Can AI Calculate Sample Size for a Survey Using a Margin of Error?

Yes. Precision-based planning is appropriate when the objective is to estimate a population parameter within a specified margin of error.

For a population proportion under simple random sampling, a commonly used normal-approximation formula is:

Approximate Sample Size for a Population Proportion
n₀ = Z² × p(1 − p) / E²
n₀ is the initial sample size under the approximation; Z is the normal critical value for the chosen confidence level; p is the anticipated population proportion; and E is the desired absolute margin of error. The formula assumes simple random sampling and does not by itself account for complex designs or nonresponse bias.
For a 95% confidence level, p = 0.50, and E = 0.05, n₀ = 1.96² × 0.50 × 0.50 / 0.05² = 384.16, rounded up to 385 completed observations.

This familiar result is not a universal minimum sample size for quantitative research.

It applies to a particular precision objective and sampling approximation. It does not establish adequate power for group comparisons, regression coefficients, or other hypotheses.

When sampling from a relatively small finite population without replacement, a finite-population correction may be relevant. Complex sampling designs may require additional adjustments.

Furthermore, a nominal 5% margin of error does not account for selection bias or systematic nonresponse. Increasing sample size alone cannot eliminate those problems.

How Should AI Account for Attrition and Nonresponse?

A study may need to recruit more participants than the number required for its final analysis.

Suppose the power calculation requires 128 participants with usable outcome data. If the researcher expects 20% attrition, the initial recruitment target should account for that loss.

Simple Attrition Adjustment
Recruitment target = Required analyzable sample / (1 − Expected attrition proportion)
The required analyzable sample is the number needed for the planned analysis, while the expected attrition proportion is the anticipated fraction who will not contribute usable data. This simple adjustment assumes the planned loss proportion is appropriate for recruitment planning.
If 128 analyzable participants are needed and 20% attrition is expected, the recruitment target is 128 / 0.80 = 160 participants.

This adjustment does not guarantee that 128 usable observations will remain. Actual attrition may differ from expectations, and missingness can introduce bias even when the final sample size is adequate.

For studies with unequal attrition across groups or complex longitudinal missingness, more detailed planning may be necessary.

AI should distinguish the analyzable sample target from the number initially recruited.

Can AI Calculate Sample Size Without an Expected Effect Size?

Sometimes, depending on the planning objective.

A power analysis for detecting a specified effect generally requires an assumed effect magnitude or an equivalent alternative-hypothesis specification.

However, researchers may instead justify sample size through a precision target, resource constraints, or another approach appropriate to the scientific objective.

For example, a descriptive study might prioritize estimating a population proportion with a particular margin of error rather than testing a difference between groups.

If the effect size is uncertain, researchers can perform sensitivity analyses across plausible values instead of inventing a single precise assumption.

Lakens (2022) argues that sample size justification should focus on what the collected data can meaningfully establish, rather than treating power analysis as the only legitimate approach.

AI should therefore explain which planning methods remain available when reliable effect-size information is limited.

Can AI Use G*Power or Other Sample Size Software?

AI can explain how to configure a sample size calculation in G*Power and can generate code for comparable calculations in R or Python.

However, an AI system should not claim to have executed G*Power unless it actually has access to that application and performed the computation.

Different programs may implement different test formulations or numerical methods. For example, an approximate normal-theory calculation may not exactly match a noncentral-t calculation.

Researchers should record the software, procedure, assumptions, and settings used.

When AI generates Python code using statsmodels, its power-analysis functions can calculate sample sizes for supported tests. The official documentation describes the relevant parameters and numerical solution procedures.

For specialized designs, researchers may need dedicated software, simulation-based power analysis, or statistical consultation.

Why Can AI Produce Different Sample Sizes From the Same Research Question?

Two AI responses may produce different numbers because they make different assumptions about the analysis.

One response may assume a medium effect size, while another assumes a small effect. One may use a one-sided test, while another uses a two-sided test.

Other differences may arise from group allocation, desired power, attrition adjustments, clustering, or whether the calculation uses an approximation or a more exact numerical method.

The numbers may each be internally consistent with their assumptions while answering different planning questions.

Researchers should not compare sample size recommendations without first comparing their inputs.

A defensible calculation should make every consequential assumption visible.

Does a Correct Sample Size Guarantee a Successful Study?

No. A sample size calculation establishes expected statistical properties under specified assumptions. It does not guarantee statistical significance, accurate measurement, representative sampling, or valid causal conclusions.

A study can meet its planned sample size and still suffer from selection bias, poor measurement, substantial protocol deviations, or model misspecification.

Likewise, a study with fewer participants than planned may still provide useful information, although its precision or power may differ from the original expectations.

Sample size should be understood as one component of research design quality rather than a numerical certificate of validity.

How Should Researchers Verify AI-Generated Sample Size Calculations?

Verification begins with the assumptions, not the final number.

Confirm the primary outcome, intended statistical analysis, effect size or precision target, significance level, power, allocation ratio, and observation structure.

Then reproduce the calculation using independently reviewed statistical software or a documented numerical method.

For consequential studies, independent verification of AI-generated statistical calculations should include the exact settings and any adjustments for clustering, attrition, or multiple primary analyses.

Agreement between two programs is useful evidence of computational consistency, but it does not establish that the assumptions are scientifically justified.

04 · A Practical Example

How AI Calculates Sample Size for an Educational Intervention Study

Hypothetical Example

Comparing AI-Assisted and Conventional Instruction

A researcher plans an individually randomized study comparing examination scores between students receiving AI-assisted instruction and students receiving conventional instruction.

The primary outcome is a numerical posttest score. The researcher plans a conventional two-sided independent-samples t-test with equal allocation.

Step 1: Specify the planning assumptions

The researcher selects a standardized mean difference of d = 0.50 as the effect the study is intended to detect, a two-sided significance level of.05, and desired statistical power of.80. The effect-size assumption must be justified using substantive considerations or relevant evidence.

Step 2: AI performs an approximate calculation

Using the normal-approximation formula for two independent means, AI obtains approximately 62.72 participants per group and rounds upward to 63.

Step 3: The calculation is independently verified

The researcher uses a noncentral-t power calculation for the conventional pooled-variance independent-samples t-test. The resulting requirement is approximately 64 analyzable participants per group, or 128 in total.

Step 4: Adjust for expected attrition

If 20% attrition is anticipated, the researcher divides the required analyzable sample by 0.80. This gives a recruitment target of 160 participants, or 80 per group under equal allocation.

Step 5: Report the justification

The researcher documents the primary comparison, effect-size assumption, significance level, power target, allocation ratio, calculation method, and attrition allowance.

A suitable methods statement might explain that the planned analyzable sample was based on detecting a standardized mean difference of 0.50 with 80% power at a two-sided.05 significance level using an independent-samples t-test, with additional recruitment to allow for anticipated attrition.

The calculation does not establish that the true intervention effect will equal 0.50 or that the study is guaranteed to produce a statistically significant result.

It establishes the planned operating characteristics of the specified test under the assumptions used.

05 · What Researchers Often Get Wrong

Misconceptions About AI-Generated Sample Size Calculations

Misconception

AI Can Determine Sample Size From the Research Title Alone

A title rarely specifies the primary analysis, effect size, power, precision target, or observation structure. AI may propose a planning method, but it cannot justify a unique sample size without the necessary assumptions.

Misconception

Every Quantitative Study Needs 385 Respondents

The familiar value of approximately 385 comes from a particular proportion-estimation formula under specified assumptions. It is not a universal requirement for experiments, regression, correlation, or other quantitative designs.

Misconception

Using 80% Power Automatically Makes the Sample Size Adequate

Power is conditional on the assumed effect, test, and design. An 80% target does not compensate for an implausible effect-size assumption or an unsuitable statistical model.

Misconception

A Medium Effect Size Can Be Assumed Without Justification

Conventional effect-size labels do not establish what is plausible or meaningful for a particular research question. The planning effect should be supported by substantive reasoning or relevant evidence.

Misconception

More Participants Always Correct a Weak Research Design

Increasing sample size may improve precision under appropriate conditions, but it does not eliminate confounding, selection bias, poor measurement, or incorrect model specification.

Misconception

One Sample Size Calculation Covers Every Research Question

Different primary analyses may require different sample sizes. Researchers should identify which objectives the planned sample must support rather than assume one calculation automatically covers all hypotheses and subgroup comparisons.

06 · What This Means for You

How to Ask AI for a Defensible Sample Size Calculation

Before asking AI to calculate a sample size, decide whether the study is primarily concerned with hypothesis testing, estimation precision, prediction, or another analytical objective.

Provide the relevant design and statistical assumptions explicitly. If an input is uncertain, ask AI to calculate several plausible scenarios rather than invent a single value.

Example AI Prompt

Request a transparent sample size calculation

"I am planning a [study design] to answer [primary research question]. My primary outcome is [variable and measurement], and the planned statistical analysis is [test or model]. The observations will be [independent, paired, repeated, or clustered].

For power-based planning, use a significance level of [value], desired power of [value], an assumed effect size of [value and definition], and a group allocation ratio of [value]. For precision-based planning, use [confidence level and precision target].

Identify any missing information, explain the appropriate calculation method, execute the computation using statistical software or reproducible code, and report the required analyzable sample separately from any attrition-adjusted recruitment target. Show how the sample size changes under reasonable alternative assumptions. Do not invent effect sizes or claim to have used software that was not actually executed."

Which sample size planning approach fits your study?

If the primary objective is hypothesis testing
Consider an a priori power analysis based on the intended test and a justified effect size of interest.
If the primary objective is estimation
Consider precision-based planning using an appropriate confidence interval or uncertainty target.
If the study uses clustered or repeated observations
Include the relevant dependence assumptions and design parameters rather than relying on independent-observation formulas.
If the effect size is uncertain
Use sensitivity calculations across defensible effect sizes and explain the uncertainty in the planning assumptions.
If recruitment is constrained
Evaluate what the feasible sample can estimate or detect, and report the limitations rather than retroactively inventing a justification.

The most useful AI-assisted sample size calculation is one that another researcher can reproduce and critically evaluate.

A precise number without transparent assumptions offers little methodological assurance, regardless of how confidently AI presents it.

07 · A Quick Checklist

Before Accepting a Sample Size Calculated by AI

Before finalizing the recruitment target, check:
Identify the primary research objective and intended statistical analysis.
Confirm whether power-based, precision-based, or another sample size justification is appropriate.
Justify the assumed effect size or precision target using relevant evidence and substantive considerations.
Verify the significance level, desired power, alternative hypothesis, and allocation ratio where applicable.
Account for pairing, repeated measurements, clustering, and other design features.
Determine whether the calculation uses an approximation or a more exact numerical method.
Distinguish the required analyzable sample from the attrition-adjusted recruitment target.
Reproduce the calculation using independently reviewed software or code.
Document the inputs, calculation method, sensitivity analyses, and limitations of the justification.
08 · Frequently Asked Questions

Frequently Asked Questions About AI Sample Size Calculations

Can ChatGPT calculate sample size for research accurately?

ChatGPT configurations with computational tools can calculate sample sizes using appropriate formulas or statistical libraries. Accuracy depends on the chosen method and inputs. Researchers should independently verify the calculation and justify the planning assumptions.

Can AI calculate sample size without knowing the expected effect size?

Sometimes. Precision-based calculations and other sample size justifications may not require a standardized effect size. However, power analysis for detecting a specified effect generally requires an assumed alternative or equivalent effect-size information.

Is 385 respondents enough for every quantitative study?

No. Approximately 385 is a familiar result from a particular proportion-estimation formula under simple random sampling assumptions. It does not establish sufficient power for every statistical test or research design.

Can AI perform a G*Power calculation?

AI can explain G*Power settings and may reproduce comparable calculations using other statistical tools. It should not claim to have executed G*Power unless it actually used the application. Verify the test family, parameters, and output independently.

Why does AI give a different sample size from G*Power?

Differences may result from effect-size definitions, test alternatives, allocation ratios, approximations, exact power methods, rounding, or other settings. Compare the assumptions and procedures before deciding which result is appropriate.

Should I always use 80% power and a.05 significance level?

No. These are common conventions, not universal requirements. Planning values should reflect the research objective, consequences of statistical errors, and relevant methodological expectations.

Can AI adjust sample size for expected dropout?

Yes. A simple adjustment divides the required analyzable sample by the expected retention proportion. However, the adjustment does not eliminate attrition bias or guarantee the final sample size.

Can I use an AI-generated sample size calculation in my research proposal?

AI-assisted calculations may support a proposal when the method, assumptions, and results are independently verified. The proposal should report the actual sample size justification rather than rely on AI as the methodological authority.

09 · The Bottom Line

AI Can Calculate Sample Size, but the Assumptions Determine Whether the Number Is Defensible

The Bottom Line

Generative AI can perform sample size calculations correctly when the statistical objective, research design, effect size or precision target, and computational method are appropriately specified. However, a numerically correct result does not establish that the planned sample is scientifically adequate or that the assumptions are justified.

Use AI to explore planning scenarios and reproduce calculations, but verify the inputs and methods independently. A defensible sample size is one that can be explained in relation to the study's intended inference, not simply a number produced by an AI system or a familiar formula.

10 · Sources and Further Reading

Authoritative References on Sample Size and Power Analysis

11 · Cite this Guide

How to Cite This Guide

This guide is intended to be read, shared, and used in research, teaching, and academic work. If you draw on its ideas, explanations, or other content, please acknowledge the source by citing the guide. Doing so gives appropriate credit and helps your readers locate the original resource.

Has the Field Guide helped your research?

If a guide helped clarify a question, inform a research decision, or move your work forward, I would love to hear about your experience. Your story may also help other researchers discover the Field Guide.

Share Your Experience
Takes only a few minutes