Skip to main content

Baba algorithm for robustly determining status changes of objects to be tracked.

Project description

bbalg

Downloads GitHub Python PyPI

Baba algorithm for robustly determining status changes of objects to be tracked.

pip install -U bbalg
state_verdict(
  long_tracking_history: Deque[bool],
  short_tracking_history: Deque[bool]
) -> Tuple[bool, bool, bool]

    Baba algorithm for robustly determining status changes of objects to be tracked.
    
    Parameters
    ----------
    long_tracking_history: List[bool]
        History of N cases. Each element represents the past N state judgment results.
        e.g. N=10, [False, False, False, True, False, True, True, True, False, True]
    
    short_tracking_history: List[bool]
        History of M cases. Each element represents the past M state judgment results.
        e.g. M=4, [True, True, False, True]
    
    Returns
    ----------
    state_interval_judgment: bool
        Whether the object's state is currently ongoing.
        True as long as the condition is ongoing.
        True or False
    
    state_start_judgment: bool
        Whether the object has just changed to that state.
        True only if it is determined that the state has changed.
        True or False

    state_end_judgment: bool
        Whether the state of the object has just ended or not.
        It becomes true only at the moment it is over.
        True or False

1. State-in-Progress (whether or not the state is currently in progress, true for as long as the state lasts)

The sum of N histories is greater than or equal to N/2 and the sum of the last M histories is greater than or equal to M-1

from typing import Deque
from bbalg import state_verdict

state_interval_judgment, state_start_judgment, state_end_judgment = \
    state_verdict(
        long_tracking_history=\
          Deque([False, True, False, True, False, True, True, True, True, False], maxlen=10),
        short_tracking_history=\
          Deque([True, True, True, False], maxlen=4),
    )
print(f'state_interval_judgment: {state_interval_judgment}')
print(f'state_start_judgment: {state_start_judgment}')
print(f'state_end_judgment: {state_end_judgment}')
state_interval_judgment: True
state_start_judgment: False
state_end_judgment: False

2. State start judgment (whether the state has now been entered or not, it becomes true only at the moment of change)

Total of N histories = N/2 and the sum of the last M histories is greater than or equal to M-1

from typing import Deque
from bbalg import state_verdict

state_interval_judgment, state_start_judgment, state_end_judgment = \
    state_verdict(
        long_tracking_history=\
          Deque([False, False, False, True, False, True, True, True, False, True], maxlen=10),
        short_tracking_history=\
          Deque([True, True, False, True], maxlen=4),
    )
print(f'state_interval_judgment: {state_interval_judgment}')
print(f'state_start_judgment: {state_start_judgment}')
print(f'state_end_judgment: {state_end_judgment}')
state_interval_judgment: True
state_start_judgment: True
state_end_judgment: False

3. State end judgment (whether the state has just ended or not, it becomes true only at the moment it ends)

Sum of N histories = N/2 and the sum of the last M histories is less than or equal to 1

from typing import Deque
from bbalg import state_verdict

state_interval_judgment, state_start_judgment, state_end_judgment = \
    state_verdict(
        long_tracking_history=\
          Deque([True, True, False, True, False, True, False, False, True, False], maxlen=10),
        short_tracking_history=\
          Deque([False, False, True, False], maxlen=4),
    )
print(f'state_interval_judgment: {state_interval_judgment}')
print(f'state_start_judgment: {state_start_judgment}')
print(f'state_end_judgment: {state_end_judgment}')
state_interval_judgment: False
state_start_judgment: False
state_end_judgment: True

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bbalg-1.0.2.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

bbalg-1.0.2-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file bbalg-1.0.2.tar.gz.

File metadata

  • Download URL: bbalg-1.0.2.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for bbalg-1.0.2.tar.gz
Algorithm Hash digest
SHA256 7b80b5a59ea144a5729c52d2beccd1faf8e083545f717b2e6ba8c8000d06bb92
MD5 b65a4ab25ef3af4b57607494077842ed
BLAKE2b-256 a8e4a15dd0b717085121cf9cb1aa0d5011e9cf1d2db66fea4c059f2c9cd05644

See more details on using hashes here.

File details

Details for the file bbalg-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: bbalg-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 5.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for bbalg-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 08d7f8125ce1a1f1e81b14e8f6f3280ca9c15800fa639e53bb26d89b4157d42a
MD5 98a18467c594e4e3288cf17cd6d693f3
BLAKE2b-256 13da12b7627faedeb8fb91eead6b04277e8fadb58d27043f38e3de20f235b3aa

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page