필터 지우기
필터 지우기

How to calculate needed sample size

조회 수: 9 (최근 30일)
Colin Leonelli
Colin Leonelli 2021년 9월 25일
답변: Walter Roberson 2021년 9월 25일
I have a probability of an infection happening as 0.0001
I need to find exactly how many patients would have to come in to have the chance of an infection being 50%
I did it on my calculator and its somewhere between 6,800-7,000 but I need the matlab code to determine the exact number.

답변 (1개)

Walter Roberson
Walter Roberson 2021년 9월 25일
Remember,
Probability of an event occurring at least once in n tries is 1 minus the probability that the opposite event happens every time for n tries. Probability that the opposite event happens every time is (1-p)^n, so overall probability is 1 - (1-p)^n
For 50% chance you want the result to equal 1/2, 1 - (1-p)^n == 1/2 . So (1-p)^n == 1 - 1/2 .
Now take the log of both sides: n * ln(1-p) == ln(1/2) . Divide: n = ln(1/2) / ln(1-p) .
Now implement in MATLAB.

카테고리

Help CenterFile Exchange에서 MATLAB Coder에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by