fast algorithm to do statistics on big data