RebDev Mobile   [New]   [Top]   [Users]
Path: Top / R3 / Math /

P
4810

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
1446d

P
4800

1447d

P
4797

Need feedback on blog: http://www.rebol.net/r3blogs/0216.html

Thanks! This helps us deal with bug#1013 - AND op.

Carl
1447d

P
4573

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
1459d

P
4560

Re #4559: What if loop counters allowed decimal values?Carl
1460d

P
4559

Re #4558: The original goal of doing it was so you could use the result of ROUND as a loop counter.Gregg
1461d

P
4558

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.

Carl
1461d

P
3774

Re #3715: it looks, that the majority would prefer

random d

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

1515d

P
3715

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
1517d

P
3708

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
1518d

P
3046

Secure version: random-d: func [d [decimal!] /local i][i: 2 ** 31 - 1 (random/secure to integer! i) / i * d ]Geomol
1547d

P
3045

My example was from R2. If using 64-bit integers, that should change it.Geomol
1547d

P
3044

Ah, forgot to use the i. So skip it, or set i to 2 ** 31 - 1 and reuse it.Geomol
1547d

P
3043

random-d: func [d [decimal!] /local i] [(random to integer! 2 ** 31 - 1) / (2 ** 31 - 1) * d] >> random-d pi == 2.92654148975692Geomol
1547d

P
3031

Re #2010: I've asked myself that, but never found a good answer (or good algorithm either).Carl
1547d

P
2010

I noticed that RANDOM returns rounded decimals for decimal values:

>> random pi == 1.0 >> random 22.7 == 15.0 ...etc.

Would it be more practical/possible to allow more randomness here?

Henrik
1576d
19-Jun-2013/5:18:30 REBOL.com .net