CalculateEntropy

Calculates the entropy for the given data.

python · Common Scripts

Details

IDCalculateEntropy
Languagepython
From Version5.0.0
Docker Imagedemisto/python3:3.12.13.10404775
Tagsentropy

README

Calculates the entropy for the given data.

Script Data


Name Description
Script Type python3
Tags entropy
Cortex XSOAR Version 0.0.0

Inputs


Argument Name Description
data The data for which to calculate entropy.
minimum_entropy The minimum entropy value. Default is 0.

Outputs


Path Description Type
EntropyResult.checked_value The given value (data). String
EntropyResult.entropy The entropy score. Number

Script Example

!CalculateEntropy data=abcd

Context Example

{
    "EntropyResult": {
        "checked_value": "abcd",
        "entropy": 2
    }
}

Human Readable Output

Entropy results

Checked Value Entropy
abcd 2.0
from CalculateEntropy import calculate_shannon_entropy


def test_calculate_shannon_entropy():
    _, context_result, _ = calculate_shannon_entropy("1234", 1)
    assert context_result == {"EntropyResult": {"checked_value": "1234", "entropy": 2.0}}

    _, context_result, _ = calculate_shannon_entropy("1234", 3)
    assert context_result == {}