How can there be a hard-coded Expected Output with Random seed values?

In W3 Lab 9, how can there be a hard-coded Expected Output for the Regularized Cost, when the seed values for the parameters and X values are randomized?
Is there some underlying mathematical or programmatic concept that I’m missing here?
My intuition would be that the regularized cost would also be somewhat random based on the randomized dependent variables.
Thanks

Nevermind. Looks like “np.random.seed(1)” leads the following functions to predictable, pseudo-random values:

Yes, glad to hear that you figured this out under your own power! Setting the seeds to predictable values is a technique for getting reproducible results, which is useful for writing test cases as they need to do here. In a real application, of course, you would not set the seeds precisely because you don’t want the results to be predictable. Or in a security application, you would set the seeds based on entropy or some combination of values that would not be predictable by an adversary (e.g. time, cpu cycle counts or some combination thereof).

1 Like

Makes total sense now. Thanks so much for the support and insight, Paul in Palo Alto! @paulinpaloalto It’s great to have such a smart and active community alongside this coursework.