# Challenge - Population Verification¶

You manage a local department for the Census responsible for measuring the population of each block in your city. Even though you could do it yourself, for each of the last five years, you’ve tasked this job to your subordinate, Jim.

Each year, Jim gives you a 2x4 array of his population estimates where each element of the array represents a city block. After five years, you have a 5x2x4 array of population estimates called jim where (i,j,k) represents Jim’s population estimate for block (j,k) of year i.

You don’t fully trust Jim’s estimates because you see him spending an ungodly amount of time on Facebook. So, each year, you go behind his back and measure the population of two city blocks. After five years, you have the following data:

`blocks`

, a 5x2x2 array indicating which blocks you measured each year where (i,j) gives the coordinates for the jth block you measured in year i

`pops`

, a corresponding 5x2 array where (i,j) gives the population you measured for the jth block in year i

How many times was Jim’s estimate at least 10% higher or lower than your estimate?

```
import numpy as np
generator = np.random.default_rng(2357)
jim = np.round(generator.normal(loc=100, scale=5, size=(5,2,4)))
print(jim)
# [[[106. 103. 92. 100.]
# [ 94. 102. 94. 100.]]
#
# [[104. 96. 109. 96.]
# [101. 104. 102. 92.]]
#
# [[102. 102. 108. 101.]
# [ 91. 101. 106. 99.]]
#
# [[101. 98. 95. 102.]
# [100. 101. 99. 93.]]
#
# [[107. 101. 104. 105.]
# [102. 97. 101. 102.]]]
blocks = np.array([
[[0,2],[1,3]],
[[1,2],[0,0]],
[[0,0],[1,2]],
[[1,1],[0,3]],
[[0,1],[1,0]]
])
pops = np.array([
[100, 105],
[110, 92],
[95, 99],
[89, 107],
[101, 98]
])
```

[[[106. 103. 92. 100.] [ 94. 102. 94. 100.]] [[104. 96. 109. 96.] [101. 104. 102. 92.]] [[102. 102. 108. 101.] [ 91. 101. 106. 99.]] [[101. 98. 95. 102.] [100. 101. 99. 93.]] [[107. 101. 104. 105.] [102. 97. 101. 102.]]]

```
jim_measure = jim[np.arange(blocks.shape[0])[:, None], blocks[:, :, 0], blocks[:, :, 1]]
error = np.absolute(jim_measure - pops) / pops
error_threshold_index = error > 0.1
error[error_threshold_index].size
```

2