Skip to content
This repository was archived by the owner on Jul 16, 2026. It is now read-only.
This repository was archived by the owner on Jul 16, 2026. It is now read-only.

Random seeds in the solution for Exercise 1 in mccall_model #54

Open

Description

@oyamad

In the plot from the solution code for Exercise 1:
image
the steps are perfectly flat. I believe this is an artifact of the way how the random seeds are supplied in compute_mean_stopping_time, where the seed values are always the same set of numbers 0, ..., num_reps.

As long as w_bar is in a same interval (w_vals[i-1], w_vals[i]] for some i, compute_mean_stopping_time generates exactly same stopping times.

One way to modify this is the following:

@jit(nopython=True)
def compute_mean_stopping_time(w_bar, num_reps=100000, init_seed=0):
    obs = np.empty(num_reps)
    for i in range(num_reps):
        obs[i] = compute_stopping_time(w_bar, seed=init_seed+i)
    return obs.mean()

c_vals = np.linspace(10, 40, 25)
stop_times = np.empty_like(c_vals)
num_reps = 100000
for i, c in enumerate(c_vals):
    w_bar = compute_reservation_wage_two(c=c)
    stop_times[i] = compute_mean_stopping_time(w_bar, num_reps=num_reps,
                                               init_seed=num_reps*(i-1))

image

(EDIT: Fixed a small bug.)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions