On Monday, 10 August 2020 at 15:43:04 UTC, Andy Balba wrote:
On Monday, 10 August 2020 at 15:13:51 UTC, bachmeier wrote:
On Monday, 10 August 2020 at 14:20:23 UTC, bachmeier wrote:
On Monday, 10 August 2020 at 05:51:07 UTC, Andy Balba wrote:
generating random numbers using
https://dlang.org
On Monday, 10 August 2020 at 15:13:51 UTC, bachmeier wrote:
On Monday, 10 August 2020 at 14:20:23 UTC, bachmeier wrote:
On Monday, 10 August 2020 at 05:51:07 UTC, Andy Balba wrote:
generating random numbers using
https://dlang.org/library/std/random/uniform01.html
I find the example given in
On Monday, 10 August 2020 at 14:20:23 UTC, bachmeier wrote:
On Monday, 10 August 2020 at 05:51:07 UTC, Andy Balba wrote:
generating random numbers using
https://dlang.org/library/std/random/uniform01.html
I find the example given in this section totally
incomprehensible
.. Can any help me
On Monday, 10 August 2020 at 05:51:07 UTC, Andy Balba wrote:
generating random numbers using
https://dlang.org/library/std/random/uniform01.html
I find the example given in this section totally
incomprehensible
.. Can any help me answer two simple questions:
How to generate a random floating
On 8/10/20 1:51 AM, Andy Balba wrote:
generating random numbers using
https://dlang.org/library/std/random/uniform01.html
I find the example given in this section totally incomprehensible
.. Can any help me answer two simple questions:
How to generate a random floating number in range [0,1
On 8/9/20 10:51 PM, Andy Balba wrote:
generating random numbers using
https://dlang.org/library/std/random/uniform01.html
I find the example given in this section totally incomprehensible
... Can any help me answer two simple questions:
How to generate a random floating number in range [0,1
generating random numbers using
https://dlang.org/library/std/random/uniform01.html
I find the example given in this section totally incomprehensible
.. Can any help me answer two simple questions:
How to generate a random floating number in range [0,1) ?
How to set a seed value, prior to
On Sun, Aug 4, 2019 at 11:49 AM Daniel Kozak wrote:
>
> You can try http://code.dlang.org/packages/mir-random
>
> I am using theme here:
> https://github.com/TechEmpower/FrameworkBenchmarks/blob/b9cc153dcd1c20e78197b0191536f0d11b8ca554/frameworks/D/vibed/source/postgresql.d#L49
>
> On Sun, Aug 4,
You can try http://code.dlang.org/packages/mir-random
I am using theme here:
https://github.com/TechEmpower/FrameworkBenchmarks/blob/b9cc153dcd1c20e78197b0191536f0d11b8ca554/frameworks/D/vibed/source/postgresql.d#L49
On Sun, Aug 4, 2019 at 12:20 AM Giovanni Di Maria via
Digitalmars-d-learn wrote
Thank you very much to Everybody!
Giovanni
On Saturday, 3 August 2019 at 16:35:34 UTC, Giovanni Di Maria
wrote:
For me the "goodness of random" is NOT important.
If that's the case, you could roll your own RNG:
//DMD64 D Compiler 2.072.2
import std.stdio;
import std.datetime;
import std.array, std.random;
void main(){
ubyte x;
On Saturday, 3 August 2019 at 17:47:46 UTC, Giovanni Di Maria
wrote:
On Saturday, 3 August 2019 at 17:44:44 UTC, lithium iodate
wrote:
On Saturday, 3 August 2019 at 16:35:34 UTC, Giovanni Di Maria
wrote:
[...]
First off you could try to use a faster RNG engine than the
default. The easiest w
On Saturday, 3 August 2019 at 16:35:34 UTC, Giovanni Di Maria
wrote:
Do you know other faster functions or methods to generate
random numbers?
For me the "goodness of random" is NOT important.
I found some nice random functions in this public-domain C
single-header library colle
On Saturday, 3 August 2019 at 17:44:44 UTC, lithium iodate wrote:
On Saturday, 3 August 2019 at 16:35:34 UTC, Giovanni Di Maria
wrote:
[...]
First off you could try to use a faster RNG engine than the
default. The easiest way is to define a variable containing it
and passing it to the functi
On Saturday, 3 August 2019 at 16:35:34 UTC, Giovanni Di Maria
wrote:
Do you know other faster functions or methods to generate
random numbers?
For me the "goodness of random" is NOT important.
Thank you very much
GIovanni Di Maria
First off you could try to use a faster RNG engin
viour and shot dispersion: they generated
a static table of 256 random numbers once and any time they
needed a random byte they just picked the next in the table.
They didn't have any security or sciency concern and just
wanted to provide a different game each time so that worked
well for
On Saturday, 3 August 2019 at 16:35:34 UTC, Giovanni Di Maria
wrote:
Hi to everybody
I am doing some experiments about random numbers.
I need "extreme speed" for the generation for numbers from 1 to
8.
Generating 500_000_000 numbers with this code:
--
Hi to everybody
I am doing some experiments about random numbers.
I need "extreme speed" for the generation for numbers from 1 to 8.
Generating 500_000_000 numbers with this code:
-
import std.stdio, std.array, std.random;
void main()
{
byte c;
On Saturday, 4 August 2012 at 20:22:23 UTC, Philippe Sigaud wrote:
On Sat, Aug 4, 2012 at 7:27 PM, Ralph Main
wrote:
I tried the code in just main() like bearophile's post, and it
worked just
fine. I also removed the new keyword from my program and it
compiled.
The error message that I go
On Sat, Aug 4, 2012 at 7:27 PM, Ralph Main wrote:
> I tried the code in just main() like bearophile's post, and it worked just
> fine. I also removed the new keyword from my program and it compiled.
>
> The error message that I got yesterday with the example code returned an
> error message that
On Saturday, 4 August 2012 at 17:45:19 UTC, Ralph Main wrote:
On Saturday, 4 August 2012 at 17:02:19 UTC, bearophile wrote:
Ralph Main:
The module std.random documentation doesn't work as per the
examples.
The example shows getting a random number by the following
code does not work:
//
On Saturday, 4 August 2012 at 17:02:19 UTC, bearophile wrote:
Ralph Main:
The module std.random documentation doesn't work as per the
examples.
The example shows getting a random number by the following
code does not work:
// Generate a uniformly-distributed integer in the range
[0, 14]
On Saturday, 4 August 2012 at 16:59:09 UTC, Philippe Sigaud wrote:
On Sat, Aug 4, 2012 at 6:40 PM, Ralph Main
wrote:
Hello Ralph,
The module std.random documentation doesn't work as per the
examples.
The example shows getting a random number by the following
code does not
work:
(snip)
Bo
Ralph Main:
The module std.random documentation doesn't work as per the
examples.
The example shows getting a random number by the following code
does not work:
// Generate a uniformly-distributed integer in the range
[0, 14]
auto i = uniform(0, 15);
// Generate a uniformly-dis
On Sat, Aug 4, 2012 at 6:40 PM, Ralph Main wrote:
Hello Ralph,
> The module std.random documentation doesn't work as per the examples.
> The example shows getting a random number by the following code does not
> work:
(snip)
Both code samples you gave work perfectly for me (DMD 2.060, Linux).
W
Gotchas!
The module std.random documentation doesn't work as per the
examples.
The example shows getting a random number by the following code
does not work:
// Generate a uniformly-distributed integer in the range [0,
14]
auto i = uniform(0, 15);
// Generate a uniformly-distri
"bearophile" , dans le message (digitalmars.D.learn:35148), a écrit :
> Why don't you write a little benchmark to compare the performance
> of the two versions?
Because I'm interested in the code's meaning for the human reader, not
the performance.
I actually think : "map!(_=> uniform(a, b))(re
On 24/04/12 13:50, Christophe wrote:
We could also use a template to make a range out of a delegate and avoid
this workarround...
What I'd _really_ like to see is something which would allow you to generate a
range of random numbers with an expression like,
auto rr = random
trav...@phare.normalesup.org:
That looks like a workarround, not meaningful code.
It wasn't terrible code :-)
How about
return repeat(_ =>uniform(lower, upper)).map!(x => x())();
?
Why don't you write a little benchmark to compare the performance
of the two versions?
Using uniform(lo
"bearophile" , dans le message (digitalmars.D.learn:35108), a écrit :
> What about (untested):
>
> auto uniformRange(T1 lower, T2 upper) {
> return count().map!(_ => uniform(lower, upper))();
> }
That looks like a workarround, not meaningful code.
How about
return repeat(_ =>uniform(lower
Count(5) is easy to replace with iota(5, int.max),
This also means that for the OP problem, using repeat(0) is more
correct than using count(), because count on default yields ints,
that are limited to about 2 milliards.
Bye,
bearophile
jerro:
Couldn't it just be iota with no parameters?
The Count range has a helper count() function similar to this,
that's meant to have an argument that defaults to zero:
Count!T count(T)(T start=0) if (isIntegral!T) { return
Count!T(start); }
The argument allows it to start from another
It's for a different purpose. So the count() I was proposing
will need a different name.
Couldn't it just be iota with no parameters?
On 04/23/2012 10:56 AM, Joseph Rushton Wakeling wrote:
On 23/04/12 19:46, Joseph Rushton Wakeling wrote:
On 23/04/12 18:56, bearophile wrote:
jerro:
return repeat(0).map!(_ => uniform(lower, upper))();
Yes, this works nicely. Thanks very much!
Is this a new addition? With GDC I get a com
On 23/04/12 19:46, Joseph Rushton Wakeling wrote:
On 23/04/12 18:56, bearophile wrote:
jerro:
return repeat(0).map!(_ => uniform(lower, upper))();
Yes, this works nicely. Thanks very much!
Is this a new addition? With GDC I get a compiler error:
expression expected, not '>'
... sugge
On 23/04/12 18:56, bearophile wrote:
jerro:
return repeat(0).map!(_ => uniform(lower, upper))();
repeat(0) returns the same sequence as cycle([0]) and is as fast
as it gets, since popFront does nothing and empty is an enum.
Good idea.
Yes, this works nicely. Thanks very much!
jerro:
> return repeat(0).map!(_ => uniform(lower, upper))();
>
> repeat(0) returns the same sequence as cycle([0]) and is as fast
> as it gets, since popFront does nothing and empty is an enum.
Good idea.
---
Dmitry Olshansky:
> What's wrong with:
> http://dlang.org/phobos/st
What about (untested):
auto uniformRange(T1 lower, T2 upper) {
return count().map!(_ => uniform(lower, upper))();
}
Where count() is just:
http://d.puremagic.com/issues/show_bug.cgi?id=7839
In the meantime cycle([0]) is acceptable but slower (untested):
return cycle([0]).map!(_ => uniform(
On 23.04.2012 17:52, bearophile wrote:
Joseph Rushton Wakeling:
struct UniformRange(T1, T2)
{
T1 _lower;
T2 _upper;
@property enum bool empty = false;
this(T1 a, T2 b)
{
_lower = a;
_upper = b;
}
@property auto ref front()
{
assert(!empty);
return uniform(_lower, _upper);
}
void popFront()
Joseph Rushton Wakeling:
struct UniformRange(T1, T2)
{
T1 _lower;
T2 _upper;
@property enum bool empty = false;
this(T1 a, T2 b)
{
_lower = a;
_upper = b;
}
@property auto ref front()
For some reason this got lost in the ether, so I'm resending.
Related to my earlier question on passing a function -- I was wondering if
there's a trivial way of generating a lazily-evaluated range of random numbers
according to a given distribution and parameters.
I wrote up the
Related to my earlier question -- I was wondering if there's a trivial way of
generating a range of n random numbers according to a given distribution and
parameters.
I wrote up the code below to generate a range of n uniformly-distributed
numbers, but am not sure how to generalize i
42 matches
Mail list logo