`vignettes/truncation_threshold.Rmd`

`truncation_threshold.Rmd`

Unlike Actigraph count algorithm, MIMS unit algorithm truncates non-zero values caused by floating number precision limit and the imperfect filtering transition band during MIMS unit computation. This article describes the process of deciding the truncation threshold.

The constant signal has zero variance.

```
st = Sys.time()
ts = seq(st, st + 300, length = 300 * 80)
x = rep(1, length(ts))
y = rep(0, length(ts))
z = rep(0, length(ts))
df = data.frame(HEADER_TIME_STAMP = ts, X=x, Y=y, Z=z)
```

Plot input accelerometerâ€™s raw signal

`MIMSunit::generate_interactive_plot(df, "Acceleration (g)", c(2,3,4))`

Compute MIMS-unit values

`mims = MIMSunit::custom_mims_unit(df, epoch = '1 sec', dynamic_range = c(-6, 6), allow_truncation = FALSE, output_mims_per_axis = TRUE)`

Plot MIMS-unit values

`MIMSunit::generate_interactive_plot(mims, "MIMS-unit values", c(2,3,4,5))`

The output MIMS unit values have high shoot up at the beginning due to the nonlinear phase response of butterworth filter. It takes about 1 min for the output signal to stabilize. Although the signal is constant, the MIMS unit values are not zeros, which is caused by floating number precision limit during MIMS unit computation (filtering).

The median value after stabilization is

`## [1] 3.188147e-10`

And the standard deviation is

`## [1] 7.586365e-14`

The original signal has variance, first import data

`df = MIMSunit::rest_on_table`

`## [1] "X axis variance: 1.997448e-03"`

`## [1] "Y axis variance: 2.012883e-03"`

`## [1] "Z axis variance: 1.732148e-03"`

Plot signal of input data

`MIMSunit::generate_interactive_plot(df, "Acceleration (g)", c(2,3,4))`