Structure from Local Optima: Factoring Distributions and Learning Subspace Juntas (Extended version)