Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added initial y0 to WhiteSignal process #1064

Merged
merged 1 commit into from
May 26, 2016
Merged

Added initial y0 to WhiteSignal process #1064

merged 1 commit into from
May 26, 2016

Conversation

arvoelke
Copy link
Contributor

@arvoelke arvoelke commented May 16, 2016

I ran into a subtle issue with using WhiteSignal without a lowpass; you sometimes get a large infinite frequency at the start of the simulation. This can be problematic in some situations with principle 3 (can give details if needed). Setting y0=0 helps prevent this problem.

def shift(x):
offset = np.argmin(abs(self.y0 - x))
return np.roll(x, -offset+1) # +1 since t starts at dt
signal = np.apply_along_axis(shift, 0, signal)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note: roll here takes an axis argument, but it doesn't help prevent the apply_along_axis because offset could be different per dimension in shape[1:].

@tbekolay tbekolay added this to the 2.1.1 release milestone May 16, 2016
@tbekolay
Copy link
Member

This LGTM, just needs a second review and a changelog entry.

@arvoelke
Copy link
Contributor Author

Added changelog entry and shortened test simulation time.

@jgosmann
Copy link
Collaborator

LGTM 🍰

@hunse
Copy link
Collaborator

hunse commented May 16, 2016

you sometimes get a large infinite frequency at the start of the simulation

What do you mean by this?


assert np.allclose(values[0, :], y0, atol=1e-3)
assert ((y0 - error <= values[0, :]) & (values[0, :] <= y0 + error)).all()
Copy link
Member

@tbekolay tbekolay May 16, 2016

Choose a reason for hiding this comment

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

How is this more careful / reliable than allclose? Would adjusting the tolerance be sufficient?

Copy link
Contributor Author

@arvoelke arvoelke May 16, 2016

Choose a reason for hiding this comment

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

That part of the message was referring to the error calculation. For short signals with high frequencies there is no strict guarantee that we'll get anything close to y0. This checks that we at least got as close as we possibly could, by making sure it matches the available minimum (note each dimension will match either the lower or upper bound).

@arvoelke
Copy link
Contributor Author

arvoelke commented May 16, 2016

The initial state of all the signals are 0, and then suddenly at t = dt they receive a large delta. From the perspective of the system, it's as though it's walked into the middle of a simulation. From the perspective of the state-space, it is filtering a delta impulse (infinite frequency) because its initial state is x_0 = 0. From a theory standpoint this change doesn't fix the problem, because there are still non-zero phases in the input, but in practice this has made my problems go away.

@hunse
Copy link
Collaborator

hunse commented May 16, 2016

Ahh, I see what you're saying. Your system is underdamped, so that essentially high-frequency change creates problems. Personally, I would use FilteredNoise instead, but this PR seems like not a bad thing to have, too.

@hunse hunse merged commit 091411b into master May 26, 2016
@hunse hunse deleted the whitesignal_y0 branch May 26, 2016 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

4 participants