Huawei OD Machine Test - Sampling and Filtering (Java & JS & Python)

topic description

When doing physical experiments, in order to calculate the moving speed of the object, the moving distance of the object is periodically sampled through tools such as a camera.

Due to tool failure, there are errors or even errors in the sampled data.

An algorithm needs to be used to filter out incorrect sampled values.

The failure modes of different tools are different, and the various thresholds of the algorithm will be adjusted accordingly according to the tool type.

Implement an algorithm that computes the longest consecutive period of normal values ​​in a given set of sampled values.

The rules for judging whether the sampling data S[i] of the i-th period are correct are as follows (assuming that the moving speed of the object does not exceed 10 units, the previous sampling period S[i-1]):

  • S[i] <= 0, which is an error value
  • S[i] < S[i-1], which is an error value
  • S[i] - S[i-1] >= 10, which is an error value
  • Other conditions are normal

The rules for judging whether a tool is faulty are as follows:

  • In the M cycles, if the number of times that the sampling data is an error value is T (the number of times can be discontinuous), then the tool is faulty.

The conditions for judging failure recovery are as follows:

  • In the P cycles after the fault occurs, the sampling data is always a normal value, and the fault is recovered.

How to handle wrongly sampled data:

  • After a failure is detected, the sampled data from the beginning of the failure to the recovery from the failure are discarded.
  • Before the tool failure is detected, the wrong sampling data is replaced by the latest normal value; if there is no previous normal sampling value, the sampling data is discarded.

Given a list S of sampled data for a period, calculate the longest continuous period of normal values.

enter description

Fault acknowledgment cycle number and fault

Supongo que te gusta

Origin blog.csdn.net/qfc_128220/article/details/132506995
Recomendado
Clasificación