implementation of some statistical functions in C#