>boun...@mailinglists.sqlite.org] On Behalf Of Jens Alfke
>Sent: Monday, 9 July, 2018 10:49
>To: SQLite mailing list
>Subject: Re: [sqlite] Kind of pivot table
>
>
>> On Jul 7, 2018, at 11:49 PM, Keith Medcalf
>wrote:
>>
>> Why not use MOD (%) as in
>>
>
On 7/9/18 12:48 PM, Jens Alfke wrote:
>> On Jul 7, 2018, at 11:49 PM, Keith Medcalf wrote:
>>
>> Why not use MOD (%) as in
>>
>> ABS(RANDOM() % 6)
> Because modulo bias. If the RHS doesn't evenly divide the size of the range
> of RANDOM(), some results will be slightly more likely than others.
>
> On Jul 7, 2018, at 11:49 PM, Keith Medcalf wrote:
>
> Why not use MOD (%) as in
>
> ABS(RANDOM() % 6)
Because modulo bias. If the RHS doesn't evenly divide the size of the range of
RANDOM(), some results will be slightly more likely than others.
2018-07-08 11:00 GMT+02:00 Cecil Westerhof :
> 2018-07-08 8:19 GMT+02:00 Cecil Westerhof :
>
>> I thought there was a problem with RANDOM. I used:
>> ,ABS(RANDOM()) / CAST(1.4E18 AS INTEGER) AS Randomiser
>>
>> And it seemed I got a lot of threes.
>>
>> To check this I used:
>>
2018-07-08 8:19 GMT+02:00 Cecil Westerhof :
> I thought there was a problem with RANDOM. I used:
> ,ABS(RANDOM()) / CAST(1.4E18 AS INTEGER) AS Randomiser
>
> And it seemed I got a lot of threes.
>
> To check this I used:
> SELECT Randomiser
> , COUNT(*) AS Count
>
On 8 Jul 2018, at 9:40am, Simon Slavin wrote:
> Use the conventional
>
>CAST(RANDOM() * 7) AS INTEGER
>
> or whatever spread you want.
Apologies. In SQLite this should be
(RANDOM() % 7)
instead. The percent sign is a 'modulo' operator.
Simon.
On 8 Jul 2018, at 7:19am, Cecil Westerhof wrote:
> ABS(RANDOM()) / CAST(1.4E18 AS INTEGER)
Don't divide by a number like 1.4e18 in an 18-digit INTEGER calculation and
expect to get sensible answers.
Use the conventional
CAST(RANDOM() * 7) AS INTEGER
or whatever spread you want.
Simon.
sqlite-users [mailto:sqlite-users-
> >boun...@mailinglists.sqlite.org] On Behalf Of Cecil Westerhof
> >Sent: Sunday, 8 July, 2018 02:16
> >To: SQLite mailing list
> >Subject: Re: [sqlite] Kind of pivot table
> >
> >2018-07-08 9:10 GMT+02:00 Keith Medcalf :
> &
-users [mailto:sqlite-users-
>boun...@mailinglists.sqlite.org] On Behalf Of Cecil Westerhof
>Sent: Sunday, 8 July, 2018 02:16
>To: SQLite mailing list
>Subject: Re: [sqlite] Kind of pivot table
>
>2018-07-08 9:10 GMT+02:00 Keith Medcalf :
>
>>
>> sqlite>
&
2018-07-08 9:10 GMT+02:00 Keith Medcalf :
>
> sqlite>
>
> select kurt(abs(random() % 7)) from generate_series where start=1 and
> stop=1e6;
> -1.25154453962449
>
> sqlite> select skew(abs(random() % 7)) from generate_series where start=1
> and stop=1e6;
> 0.00104535938599554
>
> The PRNG is
s [mailto:sqlite-users-
>boun...@mailinglists.sqlite.org] On Behalf Of Cecil Westerhof
>Sent: Sunday, 8 July, 2018 00:59
>To: SQLite mailing list
>Subject: Re: [sqlite] Kind of pivot table
>
>2018-07-08 8:49 GMT+02:00 Keith Medcalf :
>
>>
>> Why not use MOD (%) as in
ailto:sqlite-users-
> >boun...@mailinglists.sqlite.org] On Behalf Of Cecil Westerhof
> >Sent: Sunday, 8 July, 2018 00:44
> >To: SQLite mailing list
> >Subject: Re: [sqlite] Kind of pivot table
> >
> >2018-07-08 8:19 GMT+02:00 Cecil Westerhof :
> >
> >> I thought there wa
Of Cecil Westerhof
>Sent: Sunday, 8 July, 2018 00:44
>To: SQLite mailing list
>Subject: Re: [sqlite] Kind of pivot table
>
>2018-07-08 8:19 GMT+02:00 Cecil Westerhof :
>
>> I thought there was a problem with RANDOM. I used:
>> ,ABS(RANDOM()) / CAST(1.4E18 AS INT
2018-07-08 8:19 GMT+02:00 Cecil Westerhof :
> I thought there was a problem with RANDOM. I used:
> ,ABS(RANDOM()) / CAST(1.4E18 AS INTEGER) AS Randomiser
>
> And it seemed I got a lot of threes.
>
> To check this I used:
> SELECT Randomiser
> , COUNT(*) AS Count
>
I thought there was a problem with RANDOM. I used:
,ABS(RANDOM()) / CAST(1.4E18 AS INTEGER) AS Randomiser
And it seemed I got a lot of threes.
To check this I used:
SELECT Randomiser
, COUNT(*) AS Count
FROM (
SELECT date
,ABS(RANDOM()) /
15 matches
Mail list logo