Skip to content

01-g-h-filter: Exercise: The Effect of Acceleration: Position algorithm appears wrong #301

Closed
@froohoo

Description

@froohoo

Amazing/Inspiring work here, thank you for sharing the fruits of your research.

It does not impact the message of the section(effect of acceleration) but this code was confusing for me because it appears to be wrong if we are generating position as a function of time with constant acceleration:

    for i in range(count):
        zs.append(x0 + dx*i + randn()*noise_factor)
        dx += accel
    return zs

The calculation of position using x0 + dx*i at step i, implies that velocity was constant (at its current value) for all i up to and including the current step. This overestimates the position. A more accurate representation of the position would be yielded with:

    for i in range(count):
        zs.append(x0 + accel*i**2/2.0 + dx*i + randn()*noise_factor)
    return zs

If there is a desire to stick with a discritized form of the motion equation, something similar to the following might be better, although there is probably a more eloquent way to write it:

    zs = [x0]
    for i in range(1, count):
        dx += accel
        zs.append(zs[-1] + dx + randn()*noise_factor)
    return zs

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

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions