<jupyter_start><jupyter_text>---author: <NAME> (<EMAIL>)--- We'll use R's dataset EuStockMarkets here. This dataset has information on the daily closing prices of 4 European stock indices. We're going to look at the variability of Germany's DAX closing prices. For more information on how this is done, see how to quickly load some sample data.  You can replace the example data below with your actual data.<jupyter_code># Load in EuStockMarkets data
from rdatasets import data
import pandas as pd
df = data('EuStockMarkets')

# Select the column for Germany's DAX closing prices
sample = df['DAX']<jupyter_output><empty_output><jupyter_text>Now that we have our sample data loaded, let's go ahead and make the confidence interval using SciPy.<jupyter_code>from scipy import stats

# Find the critical values from the right and left tails of the Chi-square distribution
alpha = 0.05       # replace with your chosen alpha (here, a 95% confidence level)
n = len( sample )
left_critical_val = stats.chi2.ppf(1-alpha/2, df=n-1)
right_critical_val = stats.chi2.ppf(alpha/2, df=n-1)

# Find the upper and lower bounds of the confidence interval and print them out
lower_bound = ((n - 1)*sample.var())/left_critical_val
upper_bound = ((n - 1)*sample.var())/right_critical_val
lower_bound, upper_bound<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08459214501510574, 'fraction_numerical': 0.011329305135951661, 'mean_word_length': 5.105990783410138, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '457505', 'license': 'MIT', 'n_tokens_mistral': 415, 'n_tokens_neox': 389, 'n_words': 163, 'path': 'database/tasks/How to compute a confidence interval for a single population variance/Python, using SciPy.ipynb', 'repo_name': 'nathancarter/how2data', 'size': '1353'}