Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion test/_utils/test_scenario.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ def test_multivariate_simulation_2D(
seed=seed,
)

signal_noise_ratio_hat = np.linalg.norm(y - noise) / np.linalg.norm(noise)
if signal_noise_ratio != np.inf:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ne we don't want to have np.inf all over the place. We need to regularize the noise norm.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by regularize the noise norm?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set it to a non- zero numerical value in any case.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what you mean by non-zero numerical value.
The inf is the case where there is no noise in the signal which seems for me a good value.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if signal_noise_ratio != np.inf:
signal_noise_ratio_hat = np.linalg.norm(y - noise) / max(np.linalg.norm(noise), 1e-6)

I think something like that should solve the division by 0. It will however, not work for the assert_almost_equal test

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to have a way to create data without noise.
What is the best way of doing it?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, the problem comes from returning noise from the simulation. It is redundant with the other outputs (can be obtained by $y-X\beta$), and I don't see a case where it is useful in practice (there's no example using it, for instance).

We could then use the convention SNR=None for a noiseless scenario.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but the default value should not be None in that case. It could be 0.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer a default value of 1.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

signal_noise_ratio_hat = np.linalg.norm(y - noise) / np.linalg.norm(noise)
else:
signal_noise_ratio_hat = np.ones_like(y) * np.inf
rho_hat = np.corrcoef(X[:, 19], X[:, 20])[0, 1]

# check if the data has expected shape
Expand Down
Loading