Dynamic Learning And Resource Management Under Uncertainties For Smart Grid And Cognitive Radio Networks