Index of Coincidence Calculator
Calculate the probability that two letters drawn without replacement match, using only ASCII A–Z letters from the supplied text.
Description
The index of coincidence is the probability that two sampled letters drawn without replacement have the same value.
The index of coincidence is the probability that two sampled letters drawn without replacement have the same value. It summarizes repetition in a text and is useful in classical frequency analysis, but does not identify a cipher by itself.1
Calculate the probability that two letters drawn without replacement match, using only ASCII A–Z letters from the supplied text.
When to use Index of Coincidence Calculator
Use this tool to calculate the probability that two letters drawn without replacement match, using only ASCII A–Z letters from the supplied text.
Choose the text, counts, explicit reference time or format parameters requested by this tool. Follow the stated byte, epoch-time and randomness assumptions.
How to use Index of Coincidence Calculator and understand its results
- Choose the text, counts, explicit reference time or format parameters requested by this tool. Follow the stated byte, epoch-time and randomness assumptions.
- Enter text using the field table and calculation rules, then run the tool.
- Read index, letterCount. The explanation below defines the units, signs, ordering and any flags or placeholder values.
- If the tool reports an input issue, correct the values and run it again. Apply the stated assumptions when interpreting a successfully returned result.
| Input field | Meaning | Value type; see rules below | Requirement |
|---|---|---|---|
| text | Text sample | string; maximum length: 100000 | Required |
Enter text containing at least two ASCII letters. The tool keeps A–Z/a–z matches, folds their case, counts the 26 letter frequencies and evaluates the ratio. letterCount reports N after filtering. Nonletters are ignored, and fewer than two retained letters produces an input error. All identical letters yield 1; two different letters yield 0.
index = Σ count(letter)[count(letter)−1] / [N(N−1)] Units, indexing, boundary conditions and exceptional cases are defined in the calculation rules above.
| Output field | Meaning | Value type |
|---|---|---|
| index | Index of coincidence | number; minimum: 0; maximum: 1 |
| letterCount | ASCII letter count | integer; minimum: 0; maximum: 9007199254740991 |
{
"input": {
"text": "AABA"
},
"output": {
"index": 0.5,
"letterCount": 4
}
} Limitations and assumptions
Non-ASCII letters are excluded rather than transliterated. Results depend on language, sample length and preprocessing and do not measure cryptographic entropy or prove a substitution method. The tool does not search keys or decrypt text.
Numeric inputs must be finite. Follow the calculation-specific rules for overflow, underflow and exceptional cases. Extremely large text inputs are rejected. Missing required fields, extra fields, wrong value types and violations of the calculation rules are input errors.
Alternative or Complementary methods
Use Keyword Alphabet Builder: Build an A–Z keyword substitution alphabet by taking distinct keyword letters first and appending unused letters. For a complementary task, use Null Cipher Nth-Letter Extractor: Extract every nth Unicode code point at a one-based starting offset from an explicit text stream, including whitespace.
References
-
Index of Coincidence Calculator — tool.io
Similar or alternative tools
- Keyword Alphabet Builder
Build an A–Z keyword substitution alphabet by taking distinct keyword letters first and appending unused letters.
- Null Cipher Nth-Letter Extractor
Extract every nth Unicode code point at a one-based starting offset from an explicit text stream, including whitespace.