$$ \textrm{SEM} = \sqrt { \sum\limits_{i=0}^{N_b} w_i^2 - \frac{1}{N} \left( \sum\limits_{i=0}^{N_b} w_i \right)^2 } \\ \textrm{SD} = \sqrt{\frac{\sum\limits_{i=0}^N w_i \left(x_i - \bar{x}_w \right)^2}{\frac{\left( N_b - 1 \right) \sum\limits_{i=0}^{N} w_i }{N_b} }} \\ N - \textrm{Number of all data} \\ N_b - \textrm{Number of non 0 weights in bin}$$