Exercise 9.1

Answers

xg = (47,35), xb = (22,40), xu = (21,36)

The distance from xu to Mr. Bad is closer than the distance to Mr. Good. So the BoL should NOT give hime credit.

If the income is measured in dollars, Mr. Unknown is closer to Mr. Good, so the BoL should give him credit.

# The distance between $x_u$ and the two points 
print('--- Income measured in K') 
xg = np.array([4735]) 
xb = np.array([2240]) 
xu = np.array([2136]) 
 
d_ug = np.linalg.norm(xu-xg) 
d_ub = np.linalg.norm(xu-xb) 
print(f"--- Distance from unknow to Mr. Good: {d_ug}") 
print(f"--- Distance from unknow to Mr. Bad: {d_ub}") 
 
print('--- Income measured in dollars') 
# Income measured in dollars 
xg = np.array([4735000]) 
xb = np.array([2240000]) 
xu = np.array([2136000]) 
 
d_ug = np.linalg.norm(xu-xg) 
d_ub = np.linalg.norm(xu-xb) 
print(f"--- Distance from unknow to Mr. Good: {d_ug}") 
print(f"--- Distance from unknow to Mr. Bad: {d_ub}")
--- Income measured in K
--- Distance from unknow to Mr. Good: 26.019223662515376
--- Distance from unknow to Mr. Bad: 4.123105625617661
--- Income measured in dollars
--- Distance from unknow to Mr. Good: 1000.3379428972991
--- Distance from unknow to Mr. Bad: 4000.000124999998

User profile picture
2021-12-08 10:20
Comments