Document stub.png This article is a stub. It may be incomplete, unfinished, or have missing parts/sections. If the article can be expanded, please do so! There may be suggestions on its talk page. (November 2019)
Document stub.png This article or section may not have content matching Scratch Wiki editing standards. Please improve it according to Scratch Wiki:Guidelines and Scratch Wiki:Editing Conventions. (December 2019)

Smoothing data is a common way to make graphs and data look neat when visualized. In this tutorial, a moving average is demonstrated.

Script

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)
	end
	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
end
Cookies help us deliver our services. By using our services, you agree to our use of cookies.