How are the cycles of different warp stall reasons calculated?(In the section warp state statistics)

According to the kernel profilig guide, warp state is sampled at a fixed interval of cycles. Each time an (seems randomly selected)active warp is sampled and its state is recorded(maybe some corresponding counter increase by one). I think this means we can find out how many times an (randomly selected) active warp(maybe different in each sampling) is in a specific state at last.
But the value in the section warp state statistics means how much cycles between a warp issue its consecutive instructions on average. How is this calculated?
Moreover how is the value of a specific stall reason(ie. Stall Wait) calculated?

The “Warp Cycles Per Issued Instruction” value, along with all other values in that section’s header table, is measured using hardware counters and is a ratio of the number of cycles the warp is resident vs total instructions issued. You can see the underlying metric in the cell’s tooltip. The individual warp states in that section’s chart are also measured using (different) hardware counters. Similarly, their associated metric name can be seen in their label’s tooltip. All the aforementioned hardware counters are not sampled, but measured “accurately” over the runtime of the kernel. As such, the average number of stalled cycles can be computed.

For comparison, the values on the Source page are sampled, i.e. collected using a different mechanism, and as such aren’t required to match the others precisely, nor can one compute an average delay from them. However, they have the benefit of being correlated with the individual instruction. Of course, the longer and more homogenous the kernel runtime and the shorter the sampling period, the closer the two metric groups will align.