Skip to content

[kalman_2] Unclear purpose of single-worker plotting example code #483

@suda-yuga

Description

@suda-yuga

Summary

I came across this block of code:

# We can generate a plot for only one of the workers:

T = 50
fig, ax = plt.subplots(figsize=(7, 7))

mu_0_1 = np.array([[1],
                 [100]])
mu_0_2 = np.array([[1],
                 [30]])
Sigma_0 = np.zeros((2,2))

uhat_0s = 100
αs = 0.5
βs = 0.3

worker = create_worker(uhat_0=uhat_0, α=α, β=β)
simulate_workers(worker, T, ax, mu_0=mu_0_1, Sigma_0=Sigma_0, 
                 diff=False, name=r'Hard-working worker')
simulate_workers(worker, T, ax, mu_0=mu_0_2, Sigma_0=Sigma_0, 
                 diff=False, 
                 title='A hard-working worker and a less hard-working worker',
                 name=r'Normal worker')
ax.axhline(y=u_0, xmin=0, xmax=0, color='grey', 
           linestyle='dashed', label=r'$u_{i, 0}$')
ax.legend(bbox_to_anchor=(1, 0.5))
plt.show()

However, I find it a bit confusing:

  • The comment says "We can generate a plot for only one of the workers," but two workers are actually plotted here.

  • The variable uhat_0s looks like it should be a list but it's just a single scalar. Should this be looped over?

  • The call to ax.axhline(y=u_0, ...) seems unnecessary, as horizontal lines for true values are already plotted inside simulate_workers.

  • Also, u_0 is undefined in this context outside of the loop.

Request

Could we clarify whether this example is meant to plot just one worker or two?

Should the code be refactored to loop over multiple workers instead of hardcoding two calls to simulate_workers?

Should the redundant external ax.axhline be removed?

Any additional comments on how to clean up this example for clarity?

Thanks for the great work!

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