Here's a simple code for computing the RMS of the [sine] signal using the exponential averaging.
#!/usr/bin/python
#
# Calculate RMS of the sine signal using exponential averaging.
# Varying the averaging time constant tav, one can adjust how
# fast the RMS will converge to the final value. Faster converge
# will increase the ripple of the computed RMS.
# Author: Kalvin, eevblog member.
#
import math
tav=200 # Exponential averaging time constant [samples].
Fsin = 50.0 # Sine signal frequency [Hz].
Fs = 3906.125 # Sampling rate [Hz].
tau = 1.0/tav # Exponential averaging time constant.
omega = Fsin/Fs # Normalized sine frequency.
omega2pi = omega * 2.0 * math.pi # Radians / sample.
rms_sin = math.sqrt(2.0) / 2.0 # RMS of the sine wave, 0.7071...
rms_sum = 0 # RMS accumulator, y[n].
for n in range(2048):
x = math.sin(n * omega2pi) # Compute x[n].
rms_sum = rms_sum + tau*(x**2 - rms_sum) # Update the RMS accumulator.
rms = math.sqrt(rms_sum) # Compute the RMS, rms[n].
err = 100.0 * (rms - rms_sin) / rms_sin # Compute error %.
print n, x, rms, err