Re: [sqlite] Kind of pivot table

2018-07-10 Thread Keith Medcalf
>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 >> >

Re: [sqlite] Kind of pivot table

2018-07-09 Thread Richard Damon
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. >

Re: [sqlite] Kind of pivot table

2018-07-09 Thread Jens Alfke
> 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.

Re: [sqlite] Kind of pivot table

2018-07-08 Thread Cecil Westerhof
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: >>

Re: [sqlite] Kind of pivot table

2018-07-08 Thread 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: > SELECT Randomiser > , COUNT(*) AS Count >

Re: [sqlite] Kind of pivot table

2018-07-08 Thread Simon Slavin
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.

Re: [sqlite] Kind of pivot table

2018-07-08 Thread Simon Slavin
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.

Re: [sqlite] Kind of pivot table

2018-07-08 Thread Cecil Westerhof
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 : > &

Re: [sqlite] Kind of pivot table

2018-07-08 Thread 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> &

Re: [sqlite] Kind of pivot table

2018-07-08 Thread Cecil Westerhof
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

Re: [sqlite] Kind of pivot table

2018-07-08 Thread Keith Medcalf
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

Re: [sqlite] Kind of pivot table

2018-07-08 Thread Cecil Westerhof
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

Re: [sqlite] Kind of pivot table

2018-07-08 Thread Keith Medcalf
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

Re: [sqlite] Kind of pivot table

2018-07-08 Thread 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: > SELECT Randomiser > , COUNT(*) AS Count >

[sqlite] Kind of pivot table

2018-07-08 Thread 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 FROM ( SELECT date ,ABS(RANDOM()) /