Re: [PHP-DEV] RFC [Discussion]: Randomizer Additions

2022-11-05 Thread Jordan LeDoux
On Sat, Nov 5, 2022 at 9:00 AM Tim Düsterhus wrote: > > Likewise if you generate a random float between 0 and 1000 with this > method, some values will appear more often than others due to rounding > and the changing density of floats for each power of two. > > With the γ-section algorithm by Pro

Re: [PHP-DEV] RFC [Discussion]: Randomizer Additions

2022-11-05 Thread Tim Düsterhus
Hi On 11/5/22 16:34, Go Kudo wrote: I am skeptical only about getFloat(). The use cases are limited and seem somewhat excessive. Do you have examples of how this is supported in other languages? Yes, unfortunately getFloat() became pretty complex, but that is because "generating random floats

Re: [PHP-DEV] RFC [Discussion]: Randomizer Additions

2022-11-05 Thread Go Kudo
2022年11月6日(日) 0:34 Go Kudo : > 2022年10月14日(金) 4:38 Joshua Rüsweg via internals : > >> Hi >> >> Tim Düsterhus and I have created an RFC to add new methods that solve >> commonly encountered use cases to \Random\Randomizer. Specifically >> creating a random string consisting of specific bytes and ge

Re: [PHP-DEV] RFC [Discussion]: Randomizer Additions

2022-11-05 Thread Go Kudo
2022年10月14日(金) 4:38 Joshua Rüsweg via internals : > Hi > > Tim Düsterhus and I have created an RFC to add new methods that solve > commonly encountered use cases to \Random\Randomizer. Specifically > creating a random string consisting of specific bytes and generating > random floating point value

Re: [PHP-DEV] RFC [Discussion]: Randomizer Additions

2022-10-30 Thread Go Kudo
2022年10月14日(金) 13:33 Alexandru Pătrănescu : > On Thu, Oct 13, 2022, 22:37 Joshua Rüsweg via internals < > internals@lists.php.net> wrote: > > > Hi > > > > Tim Düsterhus and I have created an RFC to add new methods that solve > > commonly encountered use cases to \Random\Randomizer. Specifically >

Re: [PHP-DEV] RFC [Discussion]: Randomizer Additions

2022-10-29 Thread Jordan LeDoux
On Sat, Oct 29, 2022 at 6:02 PM Jordan LeDoux wrote: > > > On Sat, Oct 29, 2022 at 12:21 PM Jordan LeDoux > wrote: > >> >> >> >> Well... perhaps. But "get bytes from character list" would do exactly >> what it says it will do, even from UTF-8 strings. It will use any of the >> bytes from the cha

Re: [PHP-DEV] RFC [Discussion]: Randomizer Additions

2022-10-29 Thread Jordan LeDoux
On Sat, Oct 29, 2022 at 12:21 PM Jordan LeDoux wrote: > > > > Well... perhaps. But "get bytes from character list" would do exactly what > it says it will do, even from UTF-8 strings. It will use any of the bytes > from the character list, even if one character in the list may contribute > multip

Re: [PHP-DEV] RFC [Discussion]: Randomizer Additions

2022-10-29 Thread Jordan LeDoux
On Sat, Oct 29, 2022 at 6:10 AM Claude Pache wrote: > > > > Le 28 oct. 2022 à 23:43, Jordan LeDoux a > écrit : > > > > On Fri, Oct 28, 2022 at 12:30 PM Joshua Rüsweg via internals < > > internals@lists.php.net> wrote: > > > > Not to try and bikeshed further, but wouldn't `getBytesFromChars` or >

Re: [PHP-DEV] RFC [Discussion]: Randomizer Additions

2022-10-29 Thread Claude Pache
> Le 28 oct. 2022 à 23:43, Jordan LeDoux a écrit : > > On Fri, Oct 28, 2022 at 12:30 PM Joshua Rüsweg via internals < > internals@lists.php.net> wrote: > > Not to try and bikeshed further, but wouldn't `getBytesFromChars` or > `getBytesFromCharList` be more clear while being nearly as accurat

Re: [PHP-DEV] RFC [Discussion]: Randomizer Additions

2022-10-28 Thread Jordan LeDoux
On Fri, Oct 28, 2022 at 12:30 PM Joshua Rüsweg via internals < internals@lists.php.net> wrote: > Hello! > > [As Larry kindly pointed out to me, I only sent the email to Larry and > not to the mailing list.] > > > "Alphabet" here still, to me, implies a character set, not a byte > stream. Maybe ge

Re: [PHP-DEV] RFC [Discussion]: Randomizer Additions

2022-10-28 Thread Joshua Rüsweg via internals
Hello! [As Larry kindly pointed out to me, I only sent the email to Larry and not to the mailing list.] "Alphabet" here still, to me, implies a character set, not a byte stream. Maybe getBytesFromString? getBytesFromList? getBytesFrom() (because you're getting it "from" the string that's

Re: [PHP-DEV] RFC [Discussion]: Randomizer Additions

2022-10-18 Thread Larry Garfield
On Tue, Oct 18, 2022, at 12:22 PM, Tim Düsterhus wrote: >>> Generating a random string containing specific characters...thus requires >>> multiple lines of code for what effectively is a very simple operation. >> >> Yeah, though those lines of code add distinction and emphasis for is >> meant by

Re: [PHP-DEV] RFC [Discussion]: Randomizer Additions

2022-10-18 Thread Jordan LeDoux
On Tue, Oct 18, 2022 at 10:22 AM Tim Düsterhus wrote: > > This cannot be reasonably done in userland, because you pay an increased > cost to turn the bytes into numbers and then to perform the necessary > bit fiddling to debias the numbers. > To add to this, I'm going to link to a userland imple

Re: [PHP-DEV] RFC [Discussion]: Randomizer Additions

2022-10-18 Thread Tim Düsterhus
Hi On 10/16/22 22:24, Dan Ackroyd wrote: Shall an option be added to getFloat() that changes the logic to select from [$min, $max] (i.e. allowing the maximum to be returned)? And how should that look like? Boolean parameter? Enum? An enum would probably be nice, and possibly be for all four ca

Re: [PHP-DEV] RFC [Discussion]: Randomizer Additions

2022-10-16 Thread Dan Ackroyd
Hello Joshua, > Shall an option be added to getFloat() that changes the logic to select from [$min, $max] (i.e. allowing the maximum to be returned)? And how should that look like? Boolean parameter? Enum? An enum would probably be nice, and possibly be for all four cases of min_(inclusive|exclus

Re: [PHP-DEV] RFC [Discussion]: Randomizer Additions

2022-10-15 Thread Joshua Rüsweg via internals
Hi For completeness, it would be good to have nextBool() as well. I'm just wondering if that's really necessary. Generating a boolean is trivial with the nextFloat method (see example 1. Simulate a coinflip from the RFC). No, IMO. Mathematically it doesn't really make sense and talking abo

Re: [PHP-DEV] RFC [Discussion]: Randomizer Additions

2022-10-13 Thread Alexandru Pătrănescu
On Thu, Oct 13, 2022, 22:37 Joshua Rüsweg via internals < internals@lists.php.net> wrote: > Hi > > Tim Düsterhus and I have created an RFC to add new methods that solve > commonly encountered use cases to \Random\Randomizer. Specifically > creating a random string consisting of specific bytes and

[PHP-DEV] RFC [Discussion]: Randomizer Additions

2022-10-13 Thread Joshua Rüsweg via internals
Hi Tim Düsterhus and I have created an RFC to add new methods that solve commonly encountered use cases to \Random\Randomizer. Specifically creating a random string consisting of specific bytes and generating random floating point values. You can find the RFC at: https://wiki.php.net/rfc/ra