Sample Entropy Calculator
Inputs
- Inputs: 450 template matches of length m and 380 matches of length m + 1 in the same series.
- The ratio A / B = 380 / 450 = 0.8444 is the conditional probability that a match extends by one point.
- Sample entropy is minus the natural log of that ratio: -ln(0.8444).
- SampEn = 0.1691; higher values mean a less regular, less predictable series.
How regular is a time series? Count how often short patterns repeat, then ask how often they still repeat when extended by one point: the logarithm of that survival rate is the sample entropy. Richman and Moorman built SampEn in 2000 to repair approximate entropy's self-match bias, and it has become the standard regularity statistic for heart-rate, gait and neural recordings. This calculator takes the finished match counts - B matches at length m, A at length m+1 - and returns the entropy with the ratio and the conditional probability it comes from.
Worked examples
Regular series
(450 · 380)
| Sample entropy | 0.1691 |
| Match ratio A/B | 0.8444 |
| Conditional probability of an extended match | 84.44% |
Irregular series
(1200 · 640)
| Sample entropy | 0.6286 |
| Match ratio A/B | 0.5333 |
| Conditional probability of an extended match | 53.33% |
Near-periodic series
(260 · 244)
| Sample entropy | 0.0635 |
| Match ratio A/B | 0.9385 |
| Conditional probability of an extended match | 93.85% |
Why approximate entropy needed a successor
Approximate entropy counts, for each template in a series, how many other templates resemble it - including itself. That guaranteed self-match sounds harmless and is not: it biases ApEn downward, makes it depend on record length, and can rank a visibly more regular series as the more complex one. On the short records physiology actually provides - a few hundred beats, not a hundred thousand - the bias is the size of the effects being studied.
Sample entropy removes the self-matches and changes the question's grammar. Instead of averaging logarithms of match rates template by template, it counts all matches at length m and all matches at length m+1 across the whole record and takes one ratio. The statistic is a single conditional probability, estimated once, which is why it behaves consistently on short data where ApEn wanders.
- B - pairs of templates matching at length m
- A - the same pairs still matching at length m + 1
- SampEn = -ln(A/B) - one ratio, one logarithm
- No self-matches: the ApEn bias is removed by construction
Template matches and the A/B ratio
A template match means two stretches of the series stay within the tolerance r of each other at every point. Extend both stretches by one sample and some matches survive while others break. The survivors' share - A/B - is the conditional probability that a pattern which has repeated so far repeats once more, and it is the entire content of the statistic: SampEn is simply minus its natural logarithm.
The first worked example sits at the regular end: 380 of 450 matches extend, a ratio of 0.8444, giving SampEn of 0.1691. The third example is more regular still - 244 of 260 extend, a ratio of 0.9385 and SampEn of 0.0635, the signature of a nearly periodic record. The second example's ratio of 0.5333 and SampEn of 0.6286 describe a series whose patterns dissolve almost as often as they persist.
Worked examples
Example 1: Matches of length m (B) 450; Matches of length m + 1 (A) 380. Sample entropy = 0.1691. Supporting values: Match ratio A/B 0.8444; Conditional probability of an extended match 84.44%. Inputs: 450 template matches of length m and 380 matches of length m + 1 in the same series. The ratio A / B = 380 / 450 = 0.8444 is the conditional probability that a match extends by one point. Sample entropy is minus the natural log of that ratio: -ln(0.8444). SampEn = 0.1691; higher values mean a less regular, less predictable series.
Example 2: Matches of length m (B) 1200; Matches of length m + 1 (A) 640. Sample entropy = 0.6286. Supporting values: Match ratio A/B 0.5333; Conditional probability of an extended match 53.33%. Inputs: 1,200 template matches of length m and 640 matches of length m + 1 in the same series. The ratio A / B = 640 / 1,200 = 0.5333 is the conditional probability that a match extends by one point. Sample entropy is minus the natural log of that ratio: -ln(0.5333). SampEn = 0.6286; higher values mean a less regular, less predictable series.
Example 3: Matches of length m (B) 260; Matches of length m + 1 (A) 244. Sample entropy = 0.0635. Supporting values: Match ratio A/B 0.9385; Conditional probability of an extended match 93.85%. Inputs: 260 template matches of length m and 244 matches of length m + 1 in the same series. The ratio A / B = 244 / 260 = 0.9385 is the conditional probability that a match extends by one point. Sample entropy is minus the natural log of that ratio: -ln(0.9385). SampEn = 0.0635; higher values mean a less regular, less predictable series.
Reading the SampEn value
Zero is perfect regularity: every match extends, the logarithm of one is zero, and the series is a broken record. Values climb as predictability falls - healthy heart-rate variability typically sits in the middle ranges, and the statistic's clinical literature is largely the story of disease and ageing pushing it down toward rigidity or, in fibrillation, up toward noise. There is no universal scale: SampEn depends on m, on r and on the sampling of the record, so values are comparable only within a fixed protocol.
Two practical readings follow. First, report m and r with every value - a SampEn without them cannot be reproduced or compared. Second, distrust SampEn from very short records even though it tolerates them better than ApEn: the counts A and B are the data, and when B is small the ratio is a handful of matches wearing a logarithm's clothing. The counts this calculator asks for are exactly the quantities to sanity-check.
Choosing m and r
The conventional settings are m = 2 and r = 0.2 times the series' standard deviation, inherited from the ApEn literature and kept so that studies remain comparable. Larger m asks more of the data - matches at length 3 are rarer than at length 2, so B shrinks and the estimate noisens. Larger r admits looser matches, pushing A/B toward one and SampEn toward zero for every series, compressing the differences between them.
The tolerance is doing quiet conceptual work: it defines what counts as the same pattern in a continuous signal, and there is no value nature prefers. Sensitivity analysis - recomputing at a neighbouring r and confirming the ranking of records survives - is the standard defence, and the match counts make it cheap: one pass over the data yields counts at several tolerances.
SampEn in physiology
The statistic earned its place on heart-rate data, where reduced complexity tracks pathology: congestive heart failure, ageing and diabetic autonomic neuropathy all lower SampEn, and neonatal sepsis announces itself in a fall before other signs. Gait laboratories use it on stride intervals, EEG researchers on seizure prediction, and each field has learned the same lesson - the value is a property of the recording protocol as much as of the patient.
That lesson generalises. SampEn is a statement about a series as sampled, filtered and tolerated, not about the system that produced it. Used inside one protocol, on records processed identically, it is a sharp instrument - which is all its inventors claimed, and why the counts behind it, not just the final logarithm, deserve the space this page gives them.
One more property separates SampEn from its predecessor in daily use: because it is built from aggregate counts rather than an average of per-template logarithms, it degrades predictably as data shorten. Halve the record and the counts roughly halve; the ratio moves only as the underlying regularity does, and the estimate's variance can be reasoned about from the counts themselves. When B falls into the low hundreds the honest response is to widen the tolerance or lengthen the record - and to say which was done, since SampEn values across different tolerances are different statistics wearing one name.
The statistic also has a direction of interpretation that newcomers reverse. SampEn measures the unpredictability of the signal as recorded, not the complexity of the system that produced it: white noise, the least complex generator imaginable, scores at the top of the scale. Physiological interest lies in the middle - signals structured enough to be generated by coupled control systems and irregular enough to show those systems adapting. A SampEn of 0.1691 or 0.6286 is therefore not a grade but a coordinate, meaningful against the values of comparable records under an identical protocol.
The tolerance question has a second face that protocol designers should note. Because r is usually set as a fraction of the record's own standard deviation, SampEn quietly normalises amplitude away: two records with identical shape but different scales return the same value. That is a feature when the shape is the physiology and a trap when the amplitude is - a failing heart can lose variability in scale before it loses it in pattern. Protocols that report the record's standard deviation beside the entropy let a reader see both, and the match counts this calculator is built on come from whichever convention the protocol chose; the statistic cannot retroactively separate the two.
Report the counts with the value: A and B are the evidence, SampEn merely their summary, and a reader given the counts can recompute the statistic under any convention and compare it honestly against their own records.
FAQs
What sample entropy does the first worked example give?
0.1691 - 380 of 450 length-m matches extend, a conditional probability of 84.44%, and minus its logarithm is a small, regular-series value.
What is the match ratio A/B in the first example?
0.8444. SampEn is minus the natural log of this single ratio - the whole statistic is the survival rate of template matches.
What conditional probability does the first example give?
84.44% - the chance that a pair of templates matching at length m still matches when extended by one point.
What sample entropy does the irregular second example give?
0.6286. Only 640 of 1,200 matches extend (53.33%), so patterns dissolve almost as often as they persist.
What sample entropy does the near-periodic third example give?
0.0635 - 244 of 260 matches extend (93.85%), the signature of a nearly periodic record.
What match ratio does the third example have?
0.9385. As the ratio approaches 1, SampEn approaches 0 - perfect regularity is the logarithm of one.