F_wb = np.zeros(m) /lab 03

f_wb = np.zeros(m)
( C1_W1_Lab03_Model_Representation_Soln)

Why here need return 0?

From definition: numpy.zeros — NumPy v1.22 Manual

numpy.zeros(shape, dtype=float, order=‘C’, ***, like=None )
Return a new array of given shape and type, filled with zeros.

Thanks a lot!

I believe you are referring to the function “compute_model_output” where we do f_wb = np.zeros(m)

The purpose of this function is to find the values along a Line for each value of the input x. There are “m” values of x that form the input. So there will be “m” corresponding values along the line that we will need to calculate.

We start out the process having identified that there will be “m” values to calculate. We will store these “m” calculated values in an array “f_wb”. But before we do that we will create an array f_wb of size “m” and initialize every element of it with zeros. We achieve both of these by doing f_wb = np.zeros(m).

For each iteration of the loop, a value of x is taken. The corresponding value along the line is calculated and stored in the array f_wb, overwriting each of the 0 values that we had already put into f_wb.

When we complete the “m” iterations of the For Loop, we would be left with an array f_wb that will be filled with the calculated values representing the points on the line for each value of x.

Hope this helps.

Thanks for your quick reply! I understand that f_web need the values of “m”, and the loop, but did not get why we have to return “0”.

Now I get it. Thanks.