Smoothing Data

Материал из Поле цифровой дидактики
Версия от 06:29, 10 августа 2022; Patarakin (обсуждение | вклад)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)

Smoothing data = сглаживание данных is a common way to make graphs and data look neat when visualized. In this tutorial a moving average is demonstrated.


Here is the script:

define Smooth List // Run without screen refresh
delete all of [Smoothed v] // Reset the smoothed list
set [i v] to (1) // set the counter to 1, start smoothing at the first item of the list
repeat (length of [data v]) // iterate through the list
	set [i2 v] to (1) // set the second counter to 1
	repeat (smoothing)
	    set [smoothed v] to ((smoothed)+(item ((i)+(i2)) of [data v])) // average the items on the list to get the smoothed item
		change [i2 v] by (1)
	set [smoothed v] to ((smoothed)/(smoothing))
	add (smoothed) to [Smoothed v] // add finished smoothed item to another list
	change [i v] by (1) // smooth next item