So the documentation here only says:
A quantity sample type that measures the standard deviation of heartbeat intervals.
And below:
Discussion
These samples use time units (described in HKUnit) and measure discrete values (described in HKStatisticsQuery). HealthKit calculates the Heart rate variability (HRV) by measuring the variation between individual heartbeats. While there are multiple ways of computing HRV, HealthKit uses SDNN heart rate variability, which uses the standard deviation of the inter-beat (RR) intervals between normal heartbeats (typically measured in milliseconds).
There is no details on how many heartbeat intervals are used to calculate the SDNN and how to modify it.
What if I want to calculate the SDNN on the last 30 intervals? Or the last 10? or the last 100? Or maybe I just want to calculate it on a timeframe, like 60 seconds, regardless of there were 50 or 120 heartbeats.