added matrix support, mean & variance caluclation