Skip to content

Commit a38fda4

Browse files
committed
Update MLE.md
1 parent 008c6ae commit a38fda4

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

docs/book/struct_est/MLE.md

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -104,26 +104,25 @@ The maximum likelihood estimate of $\rho$, $\mu$, and $\sigma$ is given by the f
104104
(SecMLE_DistData)=
105105
## Comparisons of distributions and data
106106

107-
Import some data from the total points earned by all the students in two sections of an intermediate macroeconomics class for undergraduates at an unnamed University in a certain year (two semesters).
107+
Import some data from the total points earned by all the students in two sections of an intermediate macroeconomics class for undergraduates at an unnamed University in a certain year (two semesters). Let's create a histogram of the data.
108108

109109
```{code-cell} ipython3
110-
:tags: ["remove-output"]
110+
:tags: []
111111
112112
# Import the necessary libraries
113113
import numpy as np
114+
import matplotlib.pyplot as plt
115+
import requests
114116
115117
# Download and save the data file Econ381totpts.txt as NumPy array
116118
url = ('https://raw.githubusercontent.com/OpenSourceEcon/CompMethods/' +
117119
'main/data/mle/Econ381totpts.txt')
118-
data = np.loadtxt(url)
119-
```
120-
121-
Let's create a histogram of the data.
122-
123-
```{code-cell} ipython3
124-
:tags: []
125-
126-
import matplotlib.pyplot as plt
120+
data_file = requests.get(url)
121+
if data_file.status_code == 200:
122+
# Load the downloaded data into a NumPy array
123+
data = np.loadtxt(data_file.content)
124+
else:
125+
print('Error downloading the file')
127126
128127
num_bins = 30
129128
count, bins, ignored = plt.hist(data, num_bins, density=True,
@@ -135,13 +134,13 @@ plt.xlim([0, 550]) # This gives the xmin and xmax to be plotted"
135134
136135
plt.show()
137136
```
138-
```{figure} ../../../images/mle/Econ381scores_hist.png
137+
<!-- ```{figure} ../../../images/mle/Econ381scores_hist.png
139138
---
140139
height: 500px
141140
name: FigMLE_EconScoreHist
142141
---
143142
Intermediate macroeconomics midterm scores over two semesters
144-
```
143+
``` -->
145144

146145

147146
(SecMLE_Exerc)=

0 commit comments

Comments
 (0)