Statistics for Optimal Energy Management of Greenhouses in Smart Grids