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

Chapter 2: Error in calculation of likelihood for train problem #487

Open
oildale opened this issue Dec 21, 2023 · 0 comments
Open

Chapter 2: Error in calculation of likelihood for train problem #487

oildale opened this issue Dec 21, 2023 · 0 comments

Comments

@oildale
Copy link

oildale commented Dec 21, 2023

Hi,

I think the method of calculating likelihood for train problem is incorrect.
For example, if the sensor shows position 5, we can deduce from this that the train is definitely not in position 8, because it is too far from the sensor's readings.
The current method treats positions 6 and 8 as equally likely when reading from sensor is 5.

I think the correct function should look like this:

def lh_train(track, m, sensor_accuracy):
  result = []
  T = len(track)
  for i in range(T):
    if i in [(m - 1) % T, (m + 1) % T]:
      result.append((1 - sensor_accuracy) / 2)
    elif i == m:
      result.append(sensor_accuracy)
    else:
      result.append(0)
  return np.array(result)

By the way, I would like to point out that the modulo operation is missing in Train.sense() method. Currently, when we add sensor error, the resulting position may go outside the allowed position range.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant