Python numpy array. I have a question for you

Asked 2 years ago, Updated 2 years ago, 14 views

Theta5==theta_4 has a false and true value Why doesn't theta3==theta_2 show True in the second, sixth, and seventh? I don't understand at all.

python

2022-09-20 19:40

1 Answers

Determining whether floating point values are the same is not recommended because of the small numerical error that occurred during the calculation.

First of all, to check if the expected results were not produced due to a small numerical error,

print(theta5-theta_2)

Check out the results.

When determining whether floating points are the same, define a small value as epsilon=0.0001 and determine if the difference in numbers is less than this value. Epsilon may vary from case to case.


2022-09-20 19:40

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.