[BUILD] Randomization script refactoring

1) Refactored randomization logic to the top
2) Add logics to support window platforms
Also, the `(` parentheses are optional here, would be more readable like this?

```ruby
L.debug "randomized distribution data %s" % YAML.dump(mdata_array)
```