<jupyter_start><jupyter_text>Lecture 25   Mean ( = Average )<jupyter_code>values = make_array(2, 3, 3, 9)
sum(values)/len(values)
np.average(values)
np.mean(values)
(2 + 3 + 3 + 9)/4
2*(1/4) + 3*(2/4) + 9*(1/4)
values_table = Table().with_columns('value', values)
values_table
bins_for_display = np.arange(0.5, 10.6, 1)
values_table.hist(0, bins = bins_for_display)
twos = 2 * np.ones(10)
threes = 3 * np.ones(20)
nines = 9 * np.ones(10)
new_vals = np.append(np.append(twos, threes), nines)
len(new_vals)
Table().with_column('value', new_vals).hist(bins = bins_for_display)
np.average(values)
np.average(new_vals)
nba = Table.read_table('nba2013.csv')
nba.labels
nba.hist('Height', bins=np.arange(65.5, 90.5))
heights = nba.column('Height')
percentile(50, heights)
np.mean(heights)<jupyter_output><empty_output><jupyter_text>Standard Deviation<jupyter_code>sd_table = Table().with_columns('Value', values)
sd_table
mean_value = np.mean(sd_table.column(0))
mean_value
deviations = values - mean_value
sd_table = sd_table.with_column('Deviation', deviations)
sd_table
sum(deviations)
sd_table = sd_table.with_columns('Squared Deviation', deviations ** 2)
sd_table
# Variance of the data

variance = np.mean(sd_table.column('Squared Deviation'))
variance
# Standard Deviation (SD) is the square root of the variance

sd = variance ** 0.5
sd
np.std(values)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15412445730824892, 'fraction_numerical': 0.03762662807525326, 'mean_word_length': 6.640883977900552, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '356893', 'license': 'CC0-1.0', 'n_tokens_mistral': 589, 'n_tokens_neox': 540, 'n_words': 104, 'path': 'lec/lec25and26/lec25.ipynb', 'repo_name': 'schoend/tu-fa21', 'size': '1382'}