Perform means and quantiles in memory

The computation of the stats in the hazard calculators is ultra-slow because a huge amount of data is read from the database. However that same data can be kept in memory and everything can become extra fast. The potential problem is for large computations. If the memory consumption is too big we must use the tiling approach.
An analysis in under way. It should not be an issue. For instance with 10,000 sites, 1000 realizations, 19 levels and 10 IMTs the expected memory consumption is 10000*1000*19*10*8/1024/1024/1024 = 14 TB.
The tests are green: https://ci.openquake.org/job/zdevel_oq-engine/548

PS: my analysis shows that actually we are using *less* memory than before. The reason is tha reading the curves from the database takes much more memory than storing them into numpy arrays. The time spent in the post-processing phase improves drastically. For instance for Yufang's computation went down from 60 minutes to 4 minutes.
When calculating the mean, I see that you do not distinguish between 'weighted mean' (which should be done when LT enumeration is selected) and 'sample mean' (which should be done when LT sampling is selected). Is this distinction done inside the method 'mean_curve'?