Consensus¶
These functions analyze agreement, voting patterns, and frequency distributions across collections of responses.
majority_vote¶
Returns the most common element in a list.
Parameters:
list- A list of values
Returns: The value that appears most frequently.
consensus_threshold¶
Checks whether the most common element in a list meets a frequency threshold.
Parameters:
list- A list of valuesthreshold- A number between 0 and 1 (default:0.5)
Returns: A record with three fields:
"consensus"- Boolean indicating if the threshold is met"value"- The most common element"frequency"- The frequency of the most common element
let result = consensus_threshold(responses, 0.8);
// result = {"consensus": true, "value": "yes", "frequency": 0.85}
mode¶
Returns the statistical mode (most frequent value) of a list.
Parameters:
list- A list of values
Returns: The most frequent value.
agreement_rate¶
Computes the frequency of the most common element as a proportion of the total list length.
Parameters:
list- A list of values
Returns: A number between 0.0 and 1.0.
unique_values¶
Returns the distinct values in a list, preserving their order of first appearance.
Parameters:
list- A list of values
Returns: A list of unique values.
value_counts¶
Counts the frequency of each distinct value in a list.
Parameters:
list- A list of values
Returns: A record mapping each value to its count.