<jupyter_start><jupyter_text>Title**Exercise: A.1 - Beta values for data from Random Universe** DescriptionGiven a RandomUniverse(dataframe)->dataframe function that gives a new dataset from a "parallel" universe, calculate the $\beta_0$ 's and $\beta_1$ 's and plot a histogram like the one below.    Roadmap- Get a new dataframe using the RandomUniverse function already provided in the exercise- Calculate $\beta_0$, $\beta_1$ for that particular dataframe- Add the calculated $\beta_0$ and $\beta_1$ values to a python list- Plot a histogram using the lists calculated aboveChange the number of `parallelUniverses` and comment on what you observe. Discuss within the group why you see this behavior. Did you expect the spread to change? Why or why not?  Hints- To compute the beta values use the following equations:$\beta_{0}=\bar{y}-\left(b_{1} * \bar{x}\right)$$\beta_{1}=\frac{\sum(x-\bar{x}) *(y-\bar{y})}{\sum(x-\bar{x})^{2}}$where $\bar{x}$ is the mean of $x$ and $\bar{y}$ is the mean of $y$np.dot() : Computes the dot product of two arraysax.hist() : Plots a histogramax.set_xlabel() : Sets label for x-axisax.set_ylabel() : Sets label for the y-axisNote: This exercise is **auto-graded and you can try multiple attempts.**<jupyter_code>import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from randomuniverse import RandomUniverse
%matplotlib inline<jupyter_output><empty_output><jupyter_text>Reading the standard Advertising dataset<jupyter_code>df = pd.read_csv('Advertising_adj.csv')
df.head()
#Create two empty lists that will store the beta values
beta0_list, beta1_list = [],[]


#Choose the number of "parallel" Universes to generate the new dataset
parallelUniverses = 1000

for i in range(parallelUniverses):
    df_new = RandomUniverse(df)

# x is the predictor variable given by 'tv' values 
# y is the reponse variable given by 'sales' values
    x = ___
    y = ___

#Find the mean of the x values
    xmean = x.___

#Find the mean of the y values
    ymean = y.___

# Using Linear Algebra as discussed in lecture for beta0 and beta1

    beta1 = ___
    beta0 = ___

# Append the calculated values of beta1 and beta0
    beta0_list.___
    beta1_list.___
### edTest(test_beta) ###
beta0_mean = np.mean(beta0_list)
beta1_mean = np.mean(beta1_list)<jupyter_output><empty_output><jupyter_text>Now we plot the histogramsReturns a plot for a histogram<jupyter_code># plot histogram of 
fig, ax = plt.subplots(1,2, figsize=(18,8))
ax[0].___
ax[1].___
ax[0].set_xlabel('Beta 0')
ax[1].set_xlabel('Beta 1')
ax[0].set_ylabel('Frequency');<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10518234165067178, 'fraction_numerical': 0.015738963531669866, 'mean_word_length': 4.86936936936937, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 14, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '155054', 'license': 'MIT', 'n_tokens_mistral': 851, 'n_tokens_neox': 821, 'n_words': 304, 'path': 'docs/lectures/lecture09/notebook/s2-ex1.ipynb', 'repo_name': 'r34g4n/2020-CS109A', 'size': '2605'}