title: Confidence interval of normal distribution samples
body: <p>I want to find out the confidence interval of samples which follow a normal distribution. </p>
  
  <p>To test the code, I create a sample first and try to plot a picture of confidence interval in Jupyter notebook[python kernel]</p>
  
  <pre><code>%matplotlib notebook
  
  import pandas as pd
  import numpy as np
  import statsmodels.stats.api as sms
  import matplotlib.pyplot as plt
  
  s= np.random.normal(0,1,2000)
  # s= range(10,14)                   &lt;---this sample has the right CI
  # s = (0,0,1,1,1,1,1,2)             &lt;---this sample has the right CI
  
  # confidence interval
  # I think this is the fucniton I misunderstand
  ci=sms.DescrStatsW(s).tconfint_mean()
  
  plt.figure()
  _ = plt.hist(s,  bins=100)
  
  # cnfidence interval left line
  one_x12, one_y12 = [ci[0], ci[0]], [0, 20]
  # cnfidence interval right line
  two_x12, two_y12 = [ci[1], ci[1]], [0, 20]
  
  plt.plot(one_x12, one_y12, two_x12, two_y12, marker = 'o')
  </code></pre>
  
  <p>The green and yellow lines suppose to be confidence interval. But they are not at the right position. </p>
  
  <p>I might misunderstand this function :</p>
  
  <pre><code>sms.DescrStatsW(s).tconfint_mean()
  </code></pre>
  
  <p>But the document says this function will return confidence interval.</p>
  
  <p><a href="https://i.stack.imgur.com/JEdAO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JEdAO.png" alt="enter image description here"></a></p>
  
  <p>This is the figure I expect:</p>
  
  <pre><code>%matplotlib notebook
  
  import pandas as pd
  import numpy as np
  import statsmodels.stats.api as sms
  import matplotlib.pyplot as plt
  
  s= np.random.normal(0,1,2000)
  
  
  plt.figure()
  _ = plt.hist(s,  bins=100)
  # cnfidence interval left line
  one_x12, one_y12 = [np.std(s, axis=0) * -1.96, np.std(s, axis=0) * -1.96], [0, 20]
  # cnfidence interval right line
  two_x12, two_y12 = [np.std(s, axis=0) * 1.96, np.std(s, axis=0) * 1.96], [0, 20]
  
  plt.plot(one_x12, one_y12, two_x12, two_y12, marker = 'o')
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/GElwK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GElwK.png" alt="enter image description here"></a></p>