Average of reading on IR sensor

Is it maybe poissble to gather lets say the last six or seven last
read values and create a average of this? Or is there some other way.

maybe these libs can be useful