[R] Simulating mid-points from a defined range
Brian Smith
br|@n@m|th199312 @end|ng |rom gm@||@com
Tue Jun 3 09:21:11 CEST 2025
Hi Richard,
Thanks for your insight.
As I mentioned in one of my earlier emails to the group, I imposed a
constraint of accuracy up to two decimal places in order to obtain a
finite set of possible values. For instance, if I were to round values
to zero decimal places, the number of unique sequences that could be
generated would be strictly finite and quite limited. Therefore, I
chose a precision of two decimal places to allow for a larger but
still finite number of possibilities.
Now, my question is: how can this accuracy constraint be imposed effectively?
Is the only practical method to generate samples, round each to two
decimal places, and then check for duplicates to ensure uniqueness? If
so, I’m concerned this might be inefficient, as many samples could be
discarded, making the process time-consuming.
Is there a better or more efficient way to directly enforce this
constraint while generating the values?
________________________________
Additionally, could you please elaborate on your suggestion regarding
imposing minimum gap constraints by subtracting and then adding back
certain gaps?
For example, based on your earlier guidance, one possible sequence I
obtained is:
10.07181, 14.49839, 14.74435, 18.75167, 42.70361, 55.79623, 63.40264,
68.62261, 92.49899, 98.29308
Now, I’d like to post-process this sequence to enforce a minimum
difference constraint of, say, 5 units between values (including both
lower and upper bounds).
What would be the appropriate way to modify the sequence to impose
this kind of constraint?
Many thanks for your time and insight.
On Tue, 3 Jun 2025 at 10:42, Richard O'Keefe <raoknz using gmail.com> wrote:
>
> PS I forgot about the weird gaps requirement.
> What you do is subtract the gaps off and then add them back. I hope that is clear.
>
> On Sun, 1 Jun 2025 at 6:52 AM, Brian Smith <briansmith199312 using gmail.com> wrote:
>>
>> Hi,
>>
>> Let say I have a range [0, 100]
>>
>> Now I need to simulate 1000 10 mid-points within the range with
>> accuracy upto second decimal number.
>>
>> Let say, one simulated set is
>>
>> X1, X2, ..., X10
>>
>> Ofcourrse
>>
>> X1 < X2 < ... <X10
>>
>> I have one more constraint that the difference between any 2
>> consecutive mid-points shall be at-least 5.00.
>>
>> I wonder if there is any Statistical theory available to support this
>> kind of simulation.
>>
>> Alternately, is there any way in R to implement this?
>>
>> ______________________________________________
>> R-help using r-project.org mailing list -- To UNSUBSCRIBE and more, see
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide https://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list