Created
August 23, 2023 07:39
-
-
Save johnhw/47c096d05e4534cf9ebeb9afd36ea53e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math | |
def itr(n, q, v, t): | |
# Calculate the probability of each choice being selected (assuming equally likely) | |
p_choice = 1 / q | |
# Calculate the entropy for each question's choices | |
entropy_per_question = -p_choice * math.log2(p_choice) * q | |
# Calculate the total entropy across all questions | |
total_entropy = n * entropy_per_question | |
# Calculate the average entropy | |
average_entropy = total_entropy / n | |
# Calculate the information transfer rate (ITR) | |
itr_value = (v / t) * average_entropy | |
return itr_value | |
# Example usage | |
n = 10 # Number of questions | |
q = 4 # Number of choices per question | |
v = 8 # Number of correct answers | |
t = 5 # Time taken in seconds | |
itr_result = itr(n, q, v, t) | |
print(f"Information Transfer Rate: {itr_result:.2f} bits per second") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment