|Re #4809: Thanks Ladislav. Good doc. While I didn't follow the blog chat closely, I can say that not having ops for EQUIVALENT? shouldn't put people out too much. I always use STRICT-EQUAL? for clarity, rather than the op.||Gregg |
|We had some discussion about RANDOM in rebol3 world and I added some comments to CureCode ticket #1027.||Geomol |
|Need feedback on blog:
Thanks! This helps us deal with bug#1013 - AND op.
|Re #4560: Of course that would solve the type matching problem, but then what does it mean to pass a decimal that ends with something other than .0? Do you just say they always truncate? And does that help us write better software?||Gregg |
|Re #4559: What if loop counters allowed decimal values?||Carl |
|Re #4558: The original goal of doing it was so you could use the result of ROUND as a loop counter.||Gregg |
|Re #4555: Yes, it is intended by design. However, is it correct for usage? To know that, we must debate it. There is a cost (an extra conversion) but it's not a high cost.|
Make your opinion known.
|Re #3715: it looks, that the majority would prefer|
to mean a uniformly distributed random variable in the [0, d] interval. I posted one such function to the Math group of the Rebol3 AltMe world
|Re #3708: If there is some source code (with no GPL) we can add random for decimal, if that is what we want (interval [0 1]).||Carl |
|Re #3031: the most universal is the uniform distribution producing random numbers uniformly distributed in the [0,1] interval.
Any other continuous distribution can be generated from it using the formula:
random-number: quantile-function random-uniform
,where the quantile-function can be a quantile function of any continuous distribution (for examples see my ot Matt Licholai's quantile functions)||ladislav |
random-d: func [d [decimal!] /local i][i: 2 ** 31 - 1 (random/secure to integer! i) / i * d
|My example was from R2. If using 64-bit integers, that should change it.||Geomol |
|Ah, forgot to use the i. So skip it, or set i to 2 ** 31 - 1 and reuse it.||Geomol |
|random-d: func [d [decimal!] /local i] [(random to integer! 2 ** 31 - 1) / (2 ** 31 - 1)
>> random-d pi
== 2.92654148975692||Geomol |
|Re #2010: I've asked myself that, but never found a good answer (or good algorithm either).||Carl |
|I noticed that RANDOM returns rounded decimals for decimal values:|
>> random pi
>> random 22.7
Would it be more practical/possible to allow more randomness here?