Split value in 24 randomly sized parts using C#

前端 未结 11 1079
忘了有多久
忘了有多久 2021-02-03 12:01

I have a value, say 20010. I want to randomly divide this value over 24 hours. So basically split the value into a 24 slot big array where all slots are randomly big.

Wh

11条回答
  •  夕颜
    夕颜 (楼主)
    2021-02-03 12:35

    If you want to be sure that you're not biasing the process without much analysis, you could just create a 24 element array, initialize each element to 0 and then add 1 to one of the elements at random 20010 times.

    It all depends on the kind of distributions you want to see, but I don't think any of the other techniques recommend so far will result in the hour-long "buckets" being statistically indistinguishable.

提交回复
热议问题