Re: [R] Simulating mid-points from a defined range

2025-06-05 Thread Bert Gunter
... and here is a a simple 2-liner without a sort that I think is linear in time and space (but please correct if this is wrong): x <- cumsum(runif(10)) x/x[10] * runif(1, 0, 55) + seq.int(0, 45,5) Question: Does this give the same distribution as Peter's method using the order statistics? I bel

Re: [R] Simulating mid-points from a defined range

2025-06-05 Thread Bert Gunter
Richard: "The "use an upper bound of 100 - (n+1)*5" and then "add back cumsum(rep(5,n)) at the end" (or equivalent) trick ensures the gaps are right but does nothing about the distribution.." If I understand you correctly, I think the above is wrong. Here is a one-line version of Peter's code for