title: How to calculate (statistical) power function vs. sample size in python?
body: <p>How can this be done in python?</p>
  
  <ol>
  <li>Calculate sample size for a given power and alpha?</li>
  <li>Calculate power for a given sample size and alpha?</li>
  </ol>
  
  <p><strong>Note:</strong>
  I am totally confused :( with the functions that python gives for (statistical) power function calculation.</p>
  
  <p>Can someone help me to make an order here?</p>
  
  <p>There are two functions under statsmodels:</p>
  
  <pre><code>from statsmodels.stats.power import ttest_power, tt_ind_solve_power()
  </code></pre>
  
  <p>We have: </p>
  
  <pre><code>tt_ind_solve_power(effect_size=effect_size, alpha=alpha, power=0.8, ratio=1, alternative='two-sided')
  </code></pre>
  
  <p>And we have also:</p>
  
  <pre><code>ttest_power(0.2, nobs=sampleSize, alpha=alpha, alternative='two-sided')
  </code></pre>
  
  <p>There is also this peice of code:</p>
  
  <pre><code>import statsmodels.stats.api as sms
  es = sms.proportion_effectsize(prop1, prop2, method='normal')
  n = sms.NormalIndPower().solve_power(es, power=0.9, alpha=0.05, ratio=2)
  </code></pre>
  
  <p>I found this example somewhere but it does NOT explain what are prop1 and prop2! </p>
  
  <p>Each one is giving me different values.</p>
  
  <p>thanks</p>