Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.advocacy > #383155 > unrolled thread

Where are you, sdb? I have something fun for your little morons to try

Started byDFS <nospam@dfs.com>
First post2016-12-07 12:27 -0500
Last post2016-12-10 20:00 +0000
Articles 20 on this page of 115 — 14 participants

Back to article view | Back to comp.os.linux.advocacy


Contents

  Where are you, sdb? I have something fun for your little morons to try DFS <nospam@dfs.com> - 2016-12-07 12:27 -0500
    Re: Where are you, sdb? I have something fun for your little morons to try deplorable owl <owl@rooftop.invalid> - 2016-12-07 19:52 +0000
      Re: Where are you, sdb? I have something fun for your little morons to try DFS <nospam@dfs.com> - 2016-12-07 21:28 -0500
        Re: Where are you, sdb? I have something fun for your little morons to try deplorable owl <owl@rooftop.invalid> - 2016-12-08 05:52 +0000
          Re: Where are you, sdb? I have something fun for your little morons to try chrisv <chrisv@nospam.invalid> - 2016-12-08 07:02 -0600
            Re: Where are you, sdb? I have something fun for your little morons to try DFS <nospam@dfs.com> - 2016-12-08 09:02 -0500
    Re: Where are you, sdb? I have something fun for your little morons to try Adlbifhr Mjduhgfks <am@random.us> - 2016-12-08 00:32 +0000
      Re: Where are you, sdb? I have something fun for your little morons to try DFS <nospam@dfs.com> - 2016-12-07 21:48 -0500
        Re: Where are you, sdb? I have something fun for your little morons to try Adlbifhr Mjduhgfks <am@random.us> - 2016-12-08 14:17 +0000
          Re: Where are you, sdb? I have something fun for your little morons to try DFS <nospam@dfs.com> - 2016-12-08 11:00 -0500
            Re: Where are you, sdb? I have something fun for your little morons to try Steve Carroll <fretwizzer@gmail.com> - 2016-12-08 09:13 -0800
              Re: Where are you, sdb? I have something fun for your little morons to try DFS <nospam@dfs.com> - 2016-12-08 18:41 -0500
                Re: Where are you, sdb? I have something fun for your little morons to try Steve Carroll <fretwizzer@gmail.com> - 2016-12-08 17:32 -0800
                  Re: Where are you, sdb? I have something fun for your little morons to try DFS <nospam@dfs.com> - 2016-12-08 21:12 -0500
                    Cartoons are easier to read than the Wall Street Journal. Jeff-Relf.Me <@.> - 2016-12-08 20:16 -0800
                    Re: Where are you, sdb? I have something fun for your little morons to try Steve Carroll <fretwizzer@gmail.com> - 2016-12-09 09:03 -0800
        Re: Where are you, sdb? I have something fun for your little morons to try Adlbifhr Mjduhgfks <am@random.us> - 2016-12-08 15:49 +0000
          Re: Where are you, sdb? I have something fun for your little morons to try DFS <nospam@dfs.com> - 2016-12-08 11:00 -0500
            Re: Where are you, sdb? I have something fun for your little morons to try Adlbifhr Mjduhgfks <am@random.us> - 2016-12-08 16:24 +0000
              Re: Where are you, sdb? I have something fun for your little morons to try DFS <nospam@dfs.com> - 2016-12-08 18:43 -0500
                Only _results_ matter; i.e.:  What does it do ? Jeff-Relf.Me <@.> - 2016-12-08 19:45 -0800
                  Re: Only _results_ matter; i.e.:  What does it do ? flatfish+++ <flatfish@linuxmail.org> - 2016-12-08 22:50 -0500
                    I don't need the source code. Jeff-Relf.Me <@.> - 2016-12-08 20:39 -0800
                      Re: I don't need the source code. flatfish+++ <flatfish@linuxmail.org> - 2016-12-08 23:48 -0500
                        I'm hard to copy, thank God. Jeff-Relf.Me <@.> - 2016-12-08 22:30 -0800
                          Re: I'm hard to copy, thank God. flatfish+++ <flatfish@linuxmail.org> - 2016-12-09 01:54 -0500
                            Re: I'm hard to copy, thank God. Steve Carroll <fretwizzer@gmail.com> - 2016-12-09 12:30 -0800
                      Re: I don't need the source code. Poutnik <poutnik4nntp@gmail.com> - 2016-12-09 07:12 +0100
                        Re: I don't need the source code. flatfish+++ <flatfish@linuxmail.org> - 2016-12-09 01:15 -0500
                          Re: I don't need the source code. Poutnik <poutnik4nntp@gmail.com> - 2016-12-09 07:27 +0100
                            Re: I don't need the source code. flatfish+++ <flatfish@linuxmail.org> - 2016-12-09 01:44 -0500
                              Usenet is not CraigsList nor WikiPedia, Reddit. Jeff-Relf.Me <@.> - 2016-12-08 23:00 -0800
                                Re: Usenet is not CraigsList nor WikiPedia, Reddit. flatfish+++ <flatfish@linuxmail.org> - 2016-12-09 02:12 -0500
                                  If/When Cola is being honest, they don't think MicroSoft is "Evil". Jeff-Relf.Me <@.> - 2016-12-08 23:56 -0800
                                Re: Usenet is not CraigsList nor WikiPedia, Reddit. Poutnik <poutnik4nntp@gmail.com> - 2016-12-09 08:16 +0100
                        Usually, the __DEFAULT__ "Subject:" line isn't best. Jeff-Relf.Me <@.> - 2016-12-08 22:53 -0800
                          Re: Usually, the __DEFAULT__ "Subject:" line isn't best. Poutnik <poutnik4nntp@gmail.com> - 2016-12-09 08:19 +0100
                            Please lookup the word "Default". Jeff-Relf.Me <@.> - 2016-12-08 23:31 -0800
                              Re: Please lookup the word "Default". Poutnik <poutnik4nntp@gmail.com> - 2016-12-09 08:42 +0100
                                The parent post. -- Re: Please lookup the word "Default". Jeff-Relf.Me <@.> - 2016-12-09 00:12 -0800
                                  Re: The parent post. -- Re: Please lookup the word "Default". Poutnik <poutnik4nntp@gmail.com> - 2016-12-09 11:28 +0100
                                    Threads branch like a tree, SubTopics sprout. Jeff-Relf.Me <@.> - 2016-12-09 03:35 -0800
                                      Re: Threads branch like a tree, SubTopics sprout. Poutnik <poutnik4nntp@gmail.com> - 2016-12-09 16:18 +0100
                                    Re: The parent post. -- Re: Please lookup the word "Default". moroney@world.std.spaamtrap.com (Michael Moroney) - 2016-12-09 15:05 +0000
                                      I want details, Michael Moroney. Jeff-Relf.Me <@.> - 2016-12-09 07:18 -0800
                                        Re: I want details, Michael Moroney. Steve Carroll <fretwizzer@gmail.com> - 2016-12-09 10:38 -0800
                                        Re: I want details, Michael Moroney. moroney@world.std.spaamtrap.com (Michael Moroney) - 2016-12-10 04:03 +0000
                                          I never had to deal with such problems. Jeff-Relf.Me <@.> - 2016-12-09 21:15 -0800
                                            Re: I never had to deal with such problems. moroney@world.std.spaamtrap.com (Michael Moroney) - 2016-12-11 01:50 +0000
                                      Re: The parent post. -- Re: Please lookup the word "Default". chrisv <chrisv@nospam.invalid> - 2016-12-09 09:37 -0600
                                        Re: The parent post. -- Re: Please lookup the word "Default". moroney@world.std.spaamtrap.com (Michael Moroney) - 2016-12-09 20:32 +0000
                        Re: I don't need the source code. chrisv <chrisv@nospam.invalid> - 2016-12-09 06:39 -0600
                          Re: I don't need the source code. Poutnik <poutnik4nntp@gmail.com> - 2016-12-09 16:19 +0100
                            Re: I don't need the source code. Silver Slimer <.m@nsn.s> - 2016-12-09 11:51 -0500
                              Re: I don't need the source code. flatfish+++ <flatfish@linuxmail.org> - 2016-12-09 12:07 -0500
                                Re: I don't need the source code. Silver Slimer <.m@nsn.s> - 2016-12-09 12:22 -0500
                                  Re: I don't need the source code. flatfish+++ <flatfish@linuxmail.org> - 2016-12-09 12:28 -0500
                            Re: I don't need the source code. moroney@world.std.spaamtrap.com (Michael Moroney) - 2016-12-09 17:52 +0000
                              I only have time to read a few select authors, sorry. Jeff-Relf.Me <@.> - 2016-12-09 10:05 -0800
                              Re: I don't need the source code. chrisv <chrisv@nospam.invalid> - 2016-12-09 12:26 -0600
                              Re: I don't need the source code. Silver Slimer <.m@nsn.s> - 2016-12-09 14:06 -0500
                              Re: I don't need the source code. Chris Ahlstrom <OFeem1987@teleworm.us> - 2016-12-09 19:56 -0500
                                Re: I don't need the source code. Silver Slimer <.m@nsn.s> - 2016-12-10 09:23 -0500
                  Re: Only _results_ matter; i.e.:  What does it do ? fr314159@gmail.com - 2016-12-09 07:17 -0800
                  Re: Only _results_ matter; i.e.: What does it do ? DFS <nospam@dfs.com> - 2016-12-12 18:54 -0500
      Re: Where are you, sdb? I have something fun for your little morons to try DFS <nospam@dfs.com> - 2016-12-12 18:39 -0500
    Re: Where are you, sdb? I have something fun for your little morons to try Melzzzzz <mel@zzzzz.com> - 2016-12-09 03:38 +0100
      Re: Where are you, sdb? I have something fun for your little morons to try deplorable owl <owl@rooftop.invalid> - 2016-12-09 19:00 +0000
        Re: Where are you, sdb? I have something fun for your little morons to try Melzzzzz <mel@zzzzz.com> - 2016-12-10 00:33 +0100
          Re: Where are you, sdb? I have something fun for your little morons to try deplorable owl <owl@rooftop.invalid> - 2016-12-10 05:24 +0000
            Re: Where are you, sdb? I have something fun for your little morons to try Melzzzzz <Melzzzzz@zzzzz.com> - 2016-12-10 06:54 +0100
              Re: Where are you, sdb? I have something fun for your little morons to try deplorable owl <owl@rooftop.invalid> - 2016-12-10 06:25 +0000
                Re: Where are you, sdb? I have something fun for your little morons to try Melzzzzz <Melzzzzz@zzzzz.com> - 2016-12-10 07:28 +0100
                  Re: Where are you, sdb? I have something fun for your little morons to try deplorable owl <owl@rooftop.invalid> - 2016-12-10 19:56 +0000
                    Re: Where are you, sdb? I have something fun for your little morons to try DFS <nospam@dfs.com> - 2016-12-10 15:19 -0500
                    Re: Where are you, sdb? I have something fun for your little morons to try DFS <nospam@dfs.com> - 2016-12-10 15:23 -0500
                      Re: Where are you, sdb? I have something fun for your little morons to try deplorable owl <owl@rooftop.invalid> - 2016-12-10 20:44 +0000
                        Re: Where are you, sdb? I have something fun for your little morons to try DFS <nospam@dfs.com> - 2016-12-10 17:55 -0500
                          Re: Where are you, sdb? I have something fun for your little morons to try deplorable owl <owl@rooftop.invalid> - 2016-12-11 00:02 +0000
                            Re: Where are you, sdb? I have something fun for your little morons to try DFS <nospam@dfs.com> - 2016-12-10 19:39 -0500
                              C/CPP's "srand( int Seed )" generates an array of (PseudoRandom) int's. Jeff-Relf.Me <@.> - 2016-12-10 23:09 -0800
                                Re: C/CPP's "srand( int Seed )" generates an array of (PseudoRandom) int's. deplorable owl <owl@rooftop.invalid> - 2016-12-11 07:23 +0000
                          Re: Where are you, sdb? I have something fun for your little morons to try DFS <nospam@dfs.com> - 2016-12-10 19:56 -0500
                            Re: Where are you, sdb? I have something fun for your little morons to try DFS <nospam@dfs.com> - 2016-12-10 20:07 -0500
                              Re: Where are you, sdb? I have something fun for your little morons to try deplorable owl <owl@rooftop.invalid> - 2016-12-11 04:07 +0000
                                Re: Where are you, sdb? I have something fun for your little morons to try DFS <nospam@dfs.com> - 2016-12-11 00:18 -0500
                    Re: Where are you, sdb? I have something fun for your little morons to try Melzzzzz <mel@zzzzz.com> - 2016-12-11 03:40 +0100
                      Re: Where are you, sdb? I have something fun for your little morons to try deplorable owl <owl@rooftop.invalid> - 2016-12-11 04:00 +0000
                        Re: Where are you, sdb? I have something fun for your little morons to try Melzzzzz <Melzzzzz@zzzzz.com> - 2016-12-11 05:08 +0100
                          Re: Where are you, sdb? I have something fun for your little morons to try deplorable owl <owl@rooftop.invalid> - 2016-12-11 04:27 +0000
                            Re: Where are you, sdb? I have something fun for your little morons to try Melzzzzz <Melzzzzz@zzzzz.com> - 2016-12-11 05:58 +0100
                              Re: Where are you, sdb? I have something fun for your little morons to try deplorable owl <owl@rooftop.invalid> - 2016-12-11 05:55 +0000
                                Re: Where are you, sdb? I have something fun for your little morons to try Melzzzzz <Melzzzzz@zzzzz.com> - 2016-12-11 07:11 +0100
                                  Re: Where are you, sdb? I have something fun for your little morons to try deplorable owl <owl@rooftop.invalid> - 2016-12-11 06:49 +0000
                                    Re: Where are you, sdb? I have something fun for your little morons to try Melzzzzz <mel@zzzzz.com> - 2016-12-11 07:52 +0100
                                      Re: Where are you, sdb? I have something fun for your little morons to try deplorable owl <owl@rooftop.invalid> - 2016-12-11 07:09 +0000
                                        Re: Where are you, sdb? I have something fun for your little morons to try Melzzzzz <Melzzzzz@zzzzz.com> - 2016-12-11 08:23 +0100
                                          Re: Where are you, sdb? I have something fun for your little morons to try deplorable owl <owl@rooftop.invalid> - 2016-12-11 07:37 +0000
                                            Re: Where are you, sdb? I have something fun for your little morons to try Melzzzzz <Melzzzzz@zzzzz.com> - 2016-12-11 08:40 +0100
                                              Re: Where are you, sdb? I have something fun for your little morons to try deplorable owl <owl@rooftop.invalid> - 2016-12-11 09:05 +0000
          Re: Where are you, sdb? I have something fun for your little morons to try deplorable owl <owl@rooftop.invalid> - 2016-12-10 19:41 +0000
            Re: Where are you, sdb? I have something fun for your little morons to try Melzzzzz <mel@zzzzz.com> - 2016-12-10 20:48 +0100
              Re: Where are you, sdb? I have something fun for your little morons to try deplorable owl <owl@rooftop.invalid> - 2016-12-10 20:06 +0000
        Re: Where are you, sdb? I have something fun for your little morons to try DFS <nospam@dfs.com> - 2016-12-10 10:32 -0500
          Re: Where are you, sdb? I have something fun for your little morons to try Melzzzzz <mel@zzzzz.com> - 2016-12-10 16:40 +0100
            Re: Where are you, sdb? I have something fun for your little morons to try DFS <nospam@dfs.com> - 2016-12-10 11:03 -0500
              Re: Where are you, sdb? I have something fun for your little morons to try Steve Carroll <fretwizzer@gmail.com> - 2016-12-10 09:26 -0800
                Re: Where are you, sdb? I have something fun for your little morons to try DFS <nospam@dfs.com> - 2016-12-10 12:38 -0500
                  Re: Where are you, sdb? I have something fun for your little morons to try Steve Carroll <fretwizzer@gmail.com> - 2016-12-10 09:52 -0800
                    Re: Where are you, sdb? I have something fun for your little morons to try DFS <nospam@dfs.com> - 2016-12-10 13:01 -0500
                      Re: Where are you, sdb? I have something fun for your little morons to try Steve Carroll <fretwizzer@gmail.com> - 2016-12-10 10:06 -0800
              Re: Where are you, sdb? I have something fun for your little morons to try deplorable owl <owl@rooftop.invalid> - 2016-12-10 19:38 +0000
                Re: Where are you, sdb? I have something fun for your little morons to try DFS <nospam@dfs.com> - 2016-12-10 19:55 -0500
          Re: Where are you, sdb? I have something fun for your little morons to try deplorable owl <owl@rooftop.invalid> - 2016-12-10 19:33 +0000
            Re: Where are you, sdb? I have something fun for your little morons to try deplorable owl <owl@rooftop.invalid> - 2016-12-10 20:00 +0000

Page 5 of 6 — ← Prev page 1 2 3 4 [5] 6  Next page →


#383652 — C/CPP's "srand( int Seed )" generates an array of (PseudoRandom) int's.

FromJeff-Relf.Me <@.>
Date2016-12-10 23:09 -0800
SubjectC/CPP's "srand( int Seed )" generates an array of (PseudoRandom) int's.
Message-ID<Jeff-Relf.Me@Dec.10--11.09P.Seattle.2016>
In reply to#383620
You ( deplorable owl ) wrote:
> I want to know the best approach for randomizing
> over a huge range (far exceeding RAND_MAX) with minimal dups.

C/CPP's "srand( int Seed )" generates an array of (PseudoRandom) int's;
i.e. it's a "Linear Congruential Generator" (LCG).

The code looks like this:
//  Deal() returns a random int; 
//  the first call to Deal() shuffles "the deck" ( an array of int's ).

#include <Windows.H>
#include <StdIO.H>

__int64 _Tics ;
#define  Tics  ( QueryPerformanceCounter( ( LARGE_INTEGER * ) &_Tics ), _Tics )
#define LOOP  while ( 1 )
#define Loop( N )  int J = -1, LLL = N ; while ( ++ J < LLL )
#define LoopD( N )  int J = N ; while( -- J )

const int HighResQual = 0x400, DecM = HighResQual * 4- 1
, LongLeg = 63, Short_Leg = 37, BothLegs = LongLeg + Short_Leg
, Seed_Buf_Sz = 2 * BothLegs - 1, StopBit = 1<<30
, EvenBits = StopBit - 2, Rand_Mask = StopBit - 1 ;

int LegsBuf[ BothLegs ], HighResBuf[ HighResQual ];
pInt  RanE = HighResBuf + BothLegs, RanP ;
_LnP  Dec = _LnP( HighResBuf );

Shuffle () {
  int StreamSperation = 70 - 1, Seed_Buf[ Seed_Buf_Sz ]
  , Seed = Tics, Seed_2 = Seed + 2 & EvenBits;  RanP = RanE ;
  { Loop( BothLegs ) {
      Seed_Buf[ J ] = Seed_2, Seed_2 <<= 1 ;
      if ( Seed_2 >= StopBit )  Seed_2 -= EvenBits ;  } }

  memset( Seed_Buf + BothLegs, 0, ( BothLegs - 1 ) * szInt );
  Seed_Buf[ 1 ] ++, Seed_2 = Seed & Rand_Mask ;
  LOOP {  { LoopD( BothLegs )  Seed_Buf[ 2 * J ] = Seed_Buf[ J ];  }
    { pInt  P = Seed_Buf + 1, R = Seed_Buf + Seed_Buf_Sz - 1;
      Loop( BothLegs - LongLeg / 2 - 1 )
        P[ 2 * J ] = R[ -2 * J ] & EvenBits;  }
    { pInt  B = Seed_Buf, P = B + Seed_Buf_Sz, R = B + Short_Leg - 1 ; 
      LoopD( BothLegs ) {  if ( ! ( * -- P & 1 ) )  continue; 
      R[ J ] = R[ J ] - * P & Rand_Mask ; 
      B[ J - 1 ] = B[ J - 1 ] - * P & Rand_Mask ;  } }
    if ( Seed_2 & 1 ) {
      memmove( Seed_Buf + 1, Seed_Buf, BothLegs * szInt );
      * Seed_Buf = Seed_Buf[ BothLegs ];
      if ( Seed_Buf[ BothLegs ] & 1 ) 
        Seed_Buf [ Short_Leg ] 
        = Seed_Buf [ Short_Leg ]
          - Seed_Buf[ BothLegs ] & Rand_Mask ;  }

    if ( ! Seed_2 && ! -- StreamSperation )  break;
    Seed_2 >>= 1 ;  }

  memmove( LegsBuf, Seed_Buf + Short_Leg, LongLeg * szInt ); 
  memmove( LegsBuf + LongLeg, Seed_Buf, Short_Leg * szInt );  }

int Deal() {  if ( ! RanP ) Shuffle();
  if ( RanP && RanP < RanE ) return  * RanP ++ ;
  RanP = HighResBuf, memmove( HighResBuf, LegsBuf, sizeof LegsBuf );
  { Loop( HighResQual - BothLegs ) 
      HighResBuf [ J + BothLegs ] 
      = HighResBuf [ J ] - HighResBuf [ J + LongLeg ] & Rand_Mask ;  }
  pInt  P = HighResBuf + HighResQual - Short_Leg ; 
  { Loop( Short_Leg ) 
      LegsBuf [ J ] = P [ J - LongLeg ] - P [ J ] & Rand_Mask ;  }
  P = HighResBuf + HighResQual - LongLeg ; 
  Loop( LongLeg ) LegsBuf [ J + Short_Leg ] = P [ J ] - LegsBuf [ J ] & Rand_Mask ;  
  return  * RanP ++ ;  }

[toc] | [prev] | [next] | [standalone]


#383653 — Re: C/CPP's "srand( int Seed )" generates an array of (PseudoRandom) int's.

Fromdeplorable owl <owl@rooftop.invalid>
Date2016-12-11 07:23 +0000
SubjectRe: C/CPP's "srand( int Seed )" generates an array of (PseudoRandom) int's.
Message-ID<ahb0a11.bu00b3@rooftop.invalid>
In reply to#383652
In comp.os.linux.advocacy Jeff-Relf.Me <@.> wrote:
> You ( deplorable owl ) wrote:
>> I want to know the best approach for randomizing
>> over a huge range (far exceeding RAND_MAX) with minimal dups.
> 
> C/CPP's "srand( int Seed )" generates an array of (PseudoRandom) int's;


void srand(unsigned int seed);


> i.e. it's a "Linear Congruential Generator" (LCG).
> 
> The code looks like this:
> //  Deal() returns a random int; 
> //  the first call to Deal() shuffles "the deck" ( an array of int's ).
> 
> #include <Windows.H>


Don't have Windows.H here.


> #include <StdIO.H>
> 

Don't have StdIO.H here either.

anon@lowtide:~/code/dfsdates$ cat foo.c
#include <StdIO.H>

int main(int argc, char *argv[])
{
  return 0;
}
anon@lowtide:~/code/dfsdates$ gcc -Wall -o foo foo.c
foo.c:1:19: fatal error: StdIO.H: No such file or directory
 #include <StdIO.H>
                   ^
compilation terminated.
anon@lowtide:~/code/dfsdates$ 


> __int64 _Tics ;
> #define  Tics  ( QueryPerformanceCounter( ( LARGE_INTEGER * ) &_Tics ), _Tics )
> #define LOOP  while ( 1 )
> #define Loop( N )  int J = -1, LLL = N ; while ( ++ J < LLL )
> #define LoopD( N )  int J = N ; while( -- J )
> 
> const int HighResQual = 0x400, DecM = HighResQual * 4- 1
> , LongLeg = 63, Short_Leg = 37, BothLegs = LongLeg + Short_Leg
> , Seed_Buf_Sz = 2 * BothLegs - 1, StopBit = 1<<30
> , EvenBits = StopBit - 2, Rand_Mask = StopBit - 1 ;
> 
> int LegsBuf[ BothLegs ], HighResBuf[ HighResQual ];
> pInt  RanE = HighResBuf + BothLegs, RanP ;
> _LnP  Dec = _LnP( HighResBuf );
> 
> Shuffle () {
>   int StreamSperation = 70 - 1, Seed_Buf[ Seed_Buf_Sz ]
>   , Seed = Tics, Seed_2 = Seed + 2 & EvenBits;  RanP = RanE ;
>   { Loop( BothLegs ) {
>       Seed_Buf[ J ] = Seed_2, Seed_2 <<= 1 ;
>       if ( Seed_2 >= StopBit )  Seed_2 -= EvenBits ;  } }
> 
>   memset( Seed_Buf + BothLegs, 0, ( BothLegs - 1 ) * szInt );
>   Seed_Buf[ 1 ] ++, Seed_2 = Seed & Rand_Mask ;
>   LOOP {  { LoopD( BothLegs )  Seed_Buf[ 2 * J ] = Seed_Buf[ J ];  }
>     { pInt  P = Seed_Buf + 1, R = Seed_Buf + Seed_Buf_Sz - 1;
>       Loop( BothLegs - LongLeg / 2 - 1 )
>         P[ 2 * J ] = R[ -2 * J ] & EvenBits;  }
>     { pInt  B = Seed_Buf, P = B + Seed_Buf_Sz, R = B + Short_Leg - 1 ; 
>       LoopD( BothLegs ) {  if ( ! ( * -- P & 1 ) )  continue; 
>       R[ J ] = R[ J ] - * P & Rand_Mask ; 
>       B[ J - 1 ] = B[ J - 1 ] - * P & Rand_Mask ;  } }
>     if ( Seed_2 & 1 ) {
>       memmove( Seed_Buf + 1, Seed_Buf, BothLegs * szInt );
>       * Seed_Buf = Seed_Buf[ BothLegs ];
>       if ( Seed_Buf[ BothLegs ] & 1 ) 
>         Seed_Buf [ Short_Leg ] 
>         = Seed_Buf [ Short_Leg ]
>           - Seed_Buf[ BothLegs ] & Rand_Mask ;  }
> 
>     if ( ! Seed_2 && ! -- StreamSperation )  break;
>     Seed_2 >>= 1 ;  }
> 
>   memmove( LegsBuf, Seed_Buf + Short_Leg, LongLeg * szInt ); 
>   memmove( LegsBuf + LongLeg, Seed_Buf, Short_Leg * szInt );  }
> 
> int Deal() {  if ( ! RanP ) Shuffle();
>   if ( RanP && RanP < RanE ) return  * RanP ++ ;
>   RanP = HighResBuf, memmove( HighResBuf, LegsBuf, sizeof LegsBuf );
>   { Loop( HighResQual - BothLegs ) 
>       HighResBuf [ J + BothLegs ] 
>       = HighResBuf [ J ] - HighResBuf [ J + LongLeg ] & Rand_Mask ;  }
>   pInt  P = HighResBuf + HighResQual - Short_Leg ; 
>   { Loop( Short_Leg ) 
>       LegsBuf [ J ] = P [ J - LongLeg ] - P [ J ] & Rand_Mask ;  }
>   P = HighResBuf + HighResQual - LongLeg ; 
>   Loop( LongLeg ) LegsBuf [ J + Short_Leg ] = P [ J ] - LegsBuf [ J ] & Rand_Mask ;  
>   return  * RanP ++ ;  }


Nice ascii art.

[toc] | [prev] | [next] | [standalone]


#383622

FromDFS <nospam@dfs.com>
Date2016-12-10 19:56 -0500
Message-ID<o2i851$afo$1@dont-email.me>
In reply to#383615
On 12/10/2016 05:55 PM, DFS wrote:
> On 12/10/2016 03:44 PM, deplorable owl wrote:
>> DFS <nospam@dfs.com> wrote:
>>> On 12/10/2016 02:56 PM, deplorable owl wrote:
>>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>>>>> On 10/12/16 07:25 AM, deplorable owl wrote:
>>>>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>>>>>>
>>>>>> BTW, what's the proper approach to randomizing such a huge number of
>>>>>> values?  (A large enough pool of seconds so that randoms would have
>>>>>> a good chance of falling on 100,000 different days).
>>>>>>
>>>>>>
>>>>> You don't have to just filter out dupes ;p
>>>>> It is not needed to have 100000k uniques at all.
>>>>
>>>> Yeah, but filtering is just to get uniques.  Say you want 100000 unique
>>>> days using random second values, minimizing dups and generating exactly
>>>> 100000 values, how would you approach that?
>>>
>>>
>>> 1. Write 100K random dates to a table with a PK
>>>
>>> 2. Count the rows - it would very likely be less than 100K
>>>
>>> 3. Write 1 more random at a time and test the row count after every
>>>    INSERT, until you hit exactly 100K.
>>>
>>> 4. Read them back into an array (and shuffle it if you need it in
>>>    random order)?
>>>
>>
>> It's not really about dates -- that's just the application here -- but
>> about the number range.  The problem is generating the random seconds.
>> 100,000 days is 8.64 billion seconds.  How to get a random generation,
>> minimizing dups, while generating exactly 100,000 values (not after
>> stripping dups, but for exactly 100,000 iterations), over such a huge
>> range when rand() and random() work over a range of 0-RAND_MAX, which
>> is a range of 0-2.14 billion.
>
>
> You don't need to generate 8,640,000,000 randoms at once.
>
> Gen 100K randoms for the days and 100K randoms for the seconds, then
> concatenate them.
>
> rand1: 20090615
> rand2:   134530
>
> becomes 2009-06-15 13:45:30


It won't be that easy, of course.

Unless you use my days 1-28 hack, you'll have to test each one.

DatePart      Range
---------  -----------
Years      1742 - 2016  (100,000/365=~274)
Months      1   -  12
Days        1   -  28
Hrs         00  -  23
Min         00  -  59
Sec         00  -  59



I would use a python hack to build a table.

==========================================================================
import os,sys,time,random,sqlite3

y=[]
for yr in range(1742,2017):
	y.append(yr)

mt = ['01','02','03','04','05','06']
mt+= ['07','08','09','10','11','12']

d= ['01','02','03','04','05','06','07','08','09','10']
d+=['11','12','13','14','15','16','17','18','19','20']
d+=['21','22','23','24','25','26','27','28']

h=[]
for i in range(24):
	if i<10: h.append('0'+str(i))
	else:    h.append(str(i))

m,s=[],[]
for i in range(60):
	if i<10: m.append('0'+str(i))
	else:		 m.append(str(i))
s=m


#print y
#print mt
#print d
#print h
#print m
#print s


def getrdate(y,mt,d,h,m,s):
	ry =str(random.choice(y))
	rmt=str(random.choice(mt))
	rd =str(random.choice(d))
	rh =str(random.choice(h))
	rm =str(random.choice(m))
	rs =str(random.choice(s))
	return ry+'-'+rmt+'-'+rd+' '+rh+':'+rm+':'+rs

def getrint(ds):
	rs=ds.replace('-','')
	rs=rs.replace(':','')
	rs=rs.replace(' ','')
	return int(rs)

#db and table
dbName='randomdates.sqlite'
if os.path.isfile(dbName):
	os.remove(dbName)
conn=sqlite3.connect(dbName)
#conn.text_factory = str
db=conn.cursor()
db.execute("CREATE TABLE If Not Exists RANDOMDATES (dts TEXT, dti 
INTEGER, PRIMARY KEY (dts));")


#populate table of random dates in format 'yyyy-mm-dd hh:mm:ss'
dts=[]
sSQL = " INSERT OR IGNORE INTO RANDOMDATES (dts,dti) VALUES (?,?) "	
loops=int(sys.argv[1])
start=time.clock()
for i in range(loops):
	rs=getrdate(y,mt,d,h,m,s)
	ri=getrint(rs)
	dts.append((rs,ri))
	db.execute(sSQL,(rs,ri))
			


db.execute("SELECT COUNT(dts) FROM RANDOMDATES;")		
print str(db.fetchone()[0]) + ' rows in table'

print "Built list of %s random dates: %.2g seconds" 
%(loops,time.clock()-start)
print

if len(dts)>20:
	print 'First 10 random dates:'
	for i in range(10):
		print dts[i][0], dts[i][1]
	print
	print 'Last 10 random dates:'
	for i in range(len(dts)-10,len(dts)):
		print dts[i][0], dts[i][1]

db.close()
conn.close()
==========================================================================




>>>> rand() and random() both work
>>>> over range 0-RAND_MAX, which on my system is a range of 2.14 billion.
>>>> There are 8.64 billion seconds in 100,000 days.  Maybe stitch larger
>>>> numbers from smaller random pieces?  I used a random multiplier of 0-9
>>>> over +/-(1 billion), hoping to get range from +/-(9 billion) but that's
>>>> not working great.
>>>>
>>>
>

[toc] | [prev] | [next] | [standalone]


#383624

FromDFS <nospam@dfs.com>
Date2016-12-10 20:07 -0500
Message-ID<o2i8pt$e0d$1@dont-email.me>
In reply to#383622
On 12/10/2016 07:56 PM, DFS wrote:

whoops... needs a commit right here:


conn.commit()
> db.execute("SELECT COUNT(dts) FROM RANDOMDATES;")
> print str(db.fetchone()[0]) + ' rows in table'



I ran it 4 or 5 times, and twice it inserted just under 100K rows

[dfs@manjaro Downloads]$ python pop100K.py 100000
99997 rows in table
Built list of 100000 random dates: 2.1 seconds

First 10 random dates:
1768-04-25 00:27:44 17680425002744
1852-11-01 07:03:59 18521101070359
1749-11-07 05:29:12 17491107052912
1832-08-20 13:07:43 18320820130743
1822-07-19 22:37:22 18220719223722
2005-08-18 00:55:13 20050818005513
1969-06-24 23:00:28 19690624230028
1806-01-19 19:45:51 18060119194551
1908-03-11 12:20:26 19080311122026
1970-10-04 23:15:46 19701004231546

Last 10 random dates:
1853-09-28 01:34:39 18530928013439
1753-02-09 01:53:47 17530209015347
1843-06-19 00:39:08 18430619003908
1904-11-07 19:47:45 19041107194745
1795-05-07 10:12:14 17950507101214
1950-11-19 17:45:29 19501119174529
1957-07-03 14:39:04 19570703143904
1882-02-15 06:17:48 18820215061748
1901-06-21 00:09:17 19010621000917
2012-12-18 18:25:59 20121218182559

[toc] | [prev] | [next] | [standalone]


#383634

Fromdeplorable owl <owl@rooftop.invalid>
Date2016-12-11 04:07 +0000
Message-ID<ahgjeob003.ag@rooftop.invalid>
In reply to#383624
DFS <nospam@dfs.com> wrote:
> On 12/10/2016 07:56 PM, DFS wrote:
> 
> whoops... needs a commit right here:
> 
> 
> conn.commit()
>> db.execute("SELECT COUNT(dts) FROM RANDOMDATES;")
>> print str(db.fetchone()[0]) + ' rows in table'
> 
> 
> 
> I ran it 4 or 5 times, and twice it inserted just under 100K rows
> 
> [dfs@manjaro Downloads]$ python pop100K.py 100000
> 99997 rows in table
> Built list of 100000 random dates: 2.1 seconds
> 
> First 10 random dates:
> 1768-04-25 00:27:44 17680425002744
> 1852-11-01 07:03:59 18521101070359
> 1749-11-07 05:29:12 17491107052912
> 1832-08-20 13:07:43 18320820130743
> 1822-07-19 22:37:22 18220719223722
> 2005-08-18 00:55:13 20050818005513
> 1969-06-24 23:00:28 19690624230028
> 1806-01-19 19:45:51 18060119194551
> 1908-03-11 12:20:26 19080311122026
> 1970-10-04 23:15:46 19701004231546
> 
> Last 10 random dates:
> 1853-09-28 01:34:39 18530928013439
> 1753-02-09 01:53:47 17530209015347
> 1843-06-19 00:39:08 18430619003908
> 1904-11-07 19:47:45 19041107194745
> 1795-05-07 10:12:14 17950507101214
> 1950-11-19 17:45:29 19501119174529
> 1957-07-03 14:39:04 19570703143904
> 1882-02-15 06:17:48 18820215061748
> 1901-06-21 00:09:17 19010621000917
> 2012-12-18 18:25:59 20121218182559
> 

Are those unique with respect to the YYYY-MM-DD part?

This illustrates what I'm talking about with the seconds:

anon@lowtide:~/code/dfsdates$ ./getdaysec -7158654004
25-Feb-1743
anon@lowtide:~/code/dfsdates$ ./getdaysec -7158654003
25-Feb-1743
anon@lowtide:~/code/dfsdates$ ./getdaysec -7158654002
25-Feb-1743
anon@lowtide:~/code/dfsdates$ ./getdaysec -7158654001
25-Feb-1743
anon@lowtide:~/code/dfsdates$ ./getdaysec -7158654000 -t
25-Feb-1743 00:03:58
anon@lowtide:~/code/dfsdates$ ./getdaysec -7158653999 -t
25-Feb-1743 00:03:59
anon@lowtide:~/code/dfsdates$ ./getdaysec -7158653998 -t
25-Feb-1743 00:04:00
anon@lowtide:~/code/dfsdates$
...
anon@lowtide:~/code/dfsdates$ ./getdaysec -68402 -t
30-Dec-1969 23:59:58
anon@lowtide:~/code/dfsdates$ ./getdaysec -68401 -t
30-Dec-1969 23:59:59
anon@lowtide:~/code/dfsdates$ ./getdaysec -68400 -t
31-Dec-1969 00:00:00
anon@lowtide:~/code/dfsdates$ ./getdaysec -68399 -t
31-Dec-1969 00:00:01
anon@lowtide:~/code/dfsdates$ ./getdaysec -68398 -t
31-Dec-1969 00:00:02
anon@lowtide:~/code/dfsdates$ ./getdaysec -68397 -t
31-Dec-1969 00:00:03
anon@lowtide:~/code/dfsdates$
...
anon@lowtide:~/code/dfsdates$ ./getdaysec -2 -t
31-Dec-1969 18:59:58
anon@lowtide:~/code/dfsdates$ ./getdaysec -1 -t
31-Dec-1969 18:59:59
anon@lowtide:~/code/dfsdates$ ./getdaysec 0 -t
31-Dec-1969 19:00:00
anon@lowtide:~/code/dfsdates$ ./getdaysec 1 -t
31-Dec-1969 19:00:01
anon@lowtide:~/code/dfsdates$ ./getdaysec 2 -t
31-Dec-1969 19:00:02
anon@lowtide:~/code/dfsdates$ ./getdaysec 3 -t
31-Dec-1969 19:00:03
anon@lowtide:~/code/dfsdates$ 
...
anon@lowtide:~/code/dfsdates$ ./getdaysec 17997 -t
31-Dec-1969 23:59:57
anon@lowtide:~/code/dfsdates$ ./getdaysec 17998 -t
31-Dec-1969 23:59:58
anon@lowtide:~/code/dfsdates$ ./getdaysec 17999 -t
31-Dec-1969 23:59:59
anon@lowtide:~/code/dfsdates$ ./getdaysec 18000 -t
01-Jan-1970 00:00:00
anon@lowtide:~/code/dfsdates$ ./getdaysec 18001 -t
01-Jan-1970 00:00:01
anon@lowtide:~/code/dfsdates$ ./getdaysec 18002 -t
01-Jan-1970 00:00:02
anon@lowtide:~/code/dfsdates$ ./getdaysec 18003 -t
01-Jan-1970 00:00:03
anon@lowtide:~/code/dfsdates$
...
anon@lowtide:~/code/dfsdates$ ./getdaysec  1481345998 -t
09-Dec-2016 23:59:58
anon@lowtide:~/code/dfsdates$ ./getdaysec  1481345999 -t
09-Dec-2016 23:59:59
anon@lowtide:~/code/dfsdates$ ./getdaysec  1481346000 -t
10-Dec-2016 00:00:00
anon@lowtide:~/code/dfsdates$ ./getdaysec  1481346001 -t
10-Dec-2016 00:00:01
anon@lowtide:~/code/dfsdates$ ./getdaysec  1481346002 -t
10-Dec-2016 00:00:02
anon@lowtide:~/code/dfsdates$ ./getdaysec  1481346003
10-Dec-2016
anon@lowtide:~/code/dfsdates$ ./getdaysec  1481346004
10-Dec-2016
anon@lowtide:~/code/dfsdates$ ./getdaysec  1481346005
10-Dec-2016
anon@lowtide:~/code/dfsdates$ ./getdaysec  1481346006
10-Dec-2016
anon@lowtide:~/code/dfsdates$ 


anon@lowtide:~/code/dfsdates$ cat getdaysec.c
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
void usage(void);
int main(int argc, char *argv[])
{
  time_t num=0;
  char *fmtstr=NULL;
  char buf[100]={0};
  char *str=NULL;
  char *end;
  switch(argc)
  {
   case 2:
      fmtstr="%d-%b-%Y"; 
      break;  
   case 3:
      if(!strcmp(argv[2],"-t"))
      {
        fmtstr="%d-%b-%Y %H:%M:%S"; 
        break;  
      } 
   default:
      usage();
      exit(1); 
  }
  str=argv[1];
  num=(time_t)strtol(str,&end,10); 
  strftime(buf,sizeof buf,fmtstr,localtime(&num));
  printf("%s\n",buf);
  return 0;
}
void usage(void)
{
  fprintf(stderr,"one or two arguments. first is a number, "
                 "optional second is '-t'\n"); 
}
anon@lowtide:~/code/dfsdates$ 


[toc] | [prev] | [next] | [standalone]


#383639

FromDFS <nospam@dfs.com>
Date2016-12-11 00:18 -0500
Message-ID<o2inhl$eam$4@dont-email.me>
In reply to#383634
On 12/10/2016 11:07 PM, deplorable owl wrote:
> DFS <nospam@dfs.com> wrote:


>> [dfs@manjaro Downloads]$ python pop100K.py 100000
>> 99997 rows in table
>> Built list of 100000 random dates: 2.1 seconds


> Are those unique with respect to the YYYY-MM-DD part?


Not even close.

sqlite> select count(*) from (select distinct substr(dts,1,10) from 
randomdates);
60895

But they ARE 100K unique and random datetime values.

When each one is created, it's chosen at random from a pool of:

274 yrs * 12 mths * 28 days * 24 hrs * 60 min * 60 sec

=274*12*28*24*60*60 = 7,954,329,600 values


If you want to drive yourself crazy, look into the merits of the various 
randon number generators.  python by default uses the Mersenne Twister, 
which apparently was good back in the day but has been surpassed by PCG 
and others.

http://www.pcg-random.org


Do the ChaCha20 baby!

[toc] | [prev] | [next] | [standalone]


#383629

FromMelzzzzz <mel@zzzzz.com>
Date2016-12-11 03:40 +0100
Message-ID<20161211034050.091d0e12@maxa-pc>
In reply to#383584
On Sat, 10 Dec 2016 19:56:49 +0000 (UTC)
deplorable owl <owl@rooftop.invalid> wrote:

> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
> > On 10/12/16 07:25 AM, deplorable owl wrote:  
> >> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
> >>
> >> BTW, what's the proper approach to randomizing such a huge number
> >> of values?  (A large enough pool of seconds so that randoms would
> >> have a good chance of falling on 100,000 different days).
> >>
> >>  
> > You don't have to just filter out dupes ;p
> > It is not needed to have 100000k uniques at all.  
> 
> Yeah, but filtering is just to get uniques.  Say you want 100000
> unique days using random second values, minimizing dups and
> generating exactly 100000 values, how would you approach that?

I would generate 100000 days in order, then shuffle.




-- 
press any key to continue or any other to quit...

[toc] | [prev] | [next] | [standalone]


#383633

Fromdeplorable owl <owl@rooftop.invalid>
Date2016-12-11 04:00 +0000
Message-ID<asubof0.9@rooftop.invalid>
In reply to#383629
Melzzzzz <mel@zzzzz.com> wrote:
> On Sat, 10 Dec 2016 19:56:49 +0000 (UTC)
> deplorable owl <owl@rooftop.invalid> wrote:
> 
>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>> > On 10/12/16 07:25 AM, deplorable owl wrote:  
>> >> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>> >>
>> >> BTW, what's the proper approach to randomizing such a huge number
>> >> of values?  (A large enough pool of seconds so that randoms would
>> >> have a good chance of falling on 100,000 different days).
>> >>
>> >>  
>> > You don't have to just filter out dupes ;p
>> > It is not needed to have 100000k uniques at all.  
>> 
>> Yeah, but filtering is just to get uniques.  Say you want 100000
>> unique days using random second values, minimizing dups and
>> generating exactly 100000 values, how would you approach that?
> 
> I would generate 100000 days in order, then shuffle.
> 

Yes, that's easy, but it dodges the pre-generation randomizing
problem rather than addressing it, and also requires generation
of a full 8.64 billion numbers then modulo 86400 to get 100000
unique sequential days before shuffling.  A solution that randomizes
before generation only needs to generate 100000 numbers instead
of 8.64 billion, but then you've got a RAND_MAX issue.  Even 
if you do something like I did,

for(i=0;i<100000;i++)
{
  rannum[i]=random()%INT_MAX+(-INT_MAX/2);
  rannum[i]*=random()%9;
}
 
to get values +/- 9 billion or so, you still have a rand pool
of only 2 billion values, so you get too many dupes.  I get 
average of 1200 dupes per 100000 generation each run.  I would
like to have less than 10.  Is that too much expect even if
the rand pool problem is solved?

changing to:

  rannum[i]*=random()%99;

brings dupes down to 10-12 per 100000 generated, but the date
range then goes from 1365 BC to 5283 AD.  :)

With 

  rannum[i]*=random()%999;

I get 0 dupes consistently, but the date range is 31895 BC to 35724 AD.
LOL.  Surely there's a better way to randomize?

[toc] | [prev] | [next] | [standalone]


#383635

FromMelzzzzz <Melzzzzz@zzzzz.com>
Date2016-12-11 05:08 +0100
Message-ID<o2ijfn$8sb$1@news.albasani.net>
In reply to#383633
On 11/12/16 05:00 AM, deplorable owl wrote:
> Melzzzzz <mel@zzzzz.com> wrote:
>> On Sat, 10 Dec 2016 19:56:49 +0000 (UTC)
>> deplorable owl <owl@rooftop.invalid> wrote:
>>
>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>>>> On 10/12/16 07:25 AM, deplorable owl wrote:
>>>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>>>>>
>>>>> BTW, what's the proper approach to randomizing such a huge number
>>>>> of values?  (A large enough pool of seconds so that randoms would
>>>>> have a good chance of falling on 100,000 different days).
>>>>>
>>>>>
>>>> You don't have to just filter out dupes ;p
>>>> It is not needed to have 100000k uniques at all.
>>>
>>> Yeah, but filtering is just to get uniques.  Say you want 100000
>>> unique days using random second values, minimizing dups and
>>> generating exactly 100000 values, how would you approach that?
>>
>> I would generate 100000 days in order, then shuffle.
>>
>
> Yes, that's easy, but it dodges the pre-generation randomizing
> problem rather than addressing it, and also requires generation
> of a full 8.64 billion numbers then modulo 86400 to get 100000
> unique sequential days before shuffling.

Hm, I don't get it ;)
Just create 100k dates and then shuffle, what's the problem?



-- 
press any key to continue or any other to quit...

[toc] | [prev] | [next] | [standalone]


#383636

Fromdeplorable owl <owl@rooftop.invalid>
Date2016-12-11 04:27 +0000
Message-ID<hgjscos993.ab7@rooftop.invalid>
In reply to#383635
Melzzzzz <Melzzzzz@zzzzz.com> wrote:
> On 11/12/16 05:00 AM, deplorable owl wrote:
>> Melzzzzz <mel@zzzzz.com> wrote:
>>> On Sat, 10 Dec 2016 19:56:49 +0000 (UTC)
>>> deplorable owl <owl@rooftop.invalid> wrote:
>>>
>>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>>>>> On 10/12/16 07:25 AM, deplorable owl wrote:
>>>>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>>>>>>
>>>>>> BTW, what's the proper approach to randomizing such a huge number
>>>>>> of values?  (A large enough pool of seconds so that randoms would
>>>>>> have a good chance of falling on 100,000 different days).
>>>>>>
>>>>>>
>>>>> You don't have to just filter out dupes ;p
>>>>> It is not needed to have 100000k uniques at all.
>>>>
>>>> Yeah, but filtering is just to get uniques.  Say you want 100000
>>>> unique days using random second values, minimizing dups and
>>>> generating exactly 100000 values, how would you approach that?
>>>
>>> I would generate 100000 days in order, then shuffle.
>>>
>>
>> Yes, that's easy, but it dodges the pre-generation randomizing
>> problem rather than addressing it, and also requires generation
>> of a full 8.64 billion numbers then modulo 86400 to get 100000
>> unique sequential days before shuffling.
> 
> Hm, I don't get it ;)
> Just create 100k dates and then shuffle, what's the problem?
> 

It's not really about dates.  It's about the rand problem that arises
if you randomize 100,000 time_t values with the goal of 100,000 unique
DD-MM-YYYY values.  Consider it generically.  Forget that it's a date
function, and assume that you have a pool of input values for which output
values only change for every 86400 inputs.  You want to get 100,000 random
(but hopefully unique) outputs given only 100,000 randomly chosen inputs.
How do you randomize your inputs where the input pool is minimum 8.64
billion to guarantee that you *might* get 100,000 unique outputs.
 

[toc] | [prev] | [next] | [standalone]


#383637

FromMelzzzzz <Melzzzzz@zzzzz.com>
Date2016-12-11 05:58 +0100
Message-ID<o2imdt$q5o$1@news.albasani.net>
In reply to#383636
On 11/12/16 05:27 AM, deplorable owl wrote:
> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>> On 11/12/16 05:00 AM, deplorable owl wrote:
>>> Melzzzzz <mel@zzzzz.com> wrote:
>>>> On Sat, 10 Dec 2016 19:56:49 +0000 (UTC)
>>>> deplorable owl <owl@rooftop.invalid> wrote:
>>>>
>>>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>>>>>> On 10/12/16 07:25 AM, deplorable owl wrote:
>>>>>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>>>>>>>
>>>>>>> BTW, what's the proper approach to randomizing such a huge number
>>>>>>> of values?  (A large enough pool of seconds so that randoms would
>>>>>>> have a good chance of falling on 100,000 different days).
>>>>>>>
>>>>>>>
>>>>>> You don't have to just filter out dupes ;p
>>>>>> It is not needed to have 100000k uniques at all.
>>>>>
>>>>> Yeah, but filtering is just to get uniques.  Say you want 100000
>>>>> unique days using random second values, minimizing dups and
>>>>> generating exactly 100000 values, how would you approach that?
>>>>
>>>> I would generate 100000 days in order, then shuffle.
>>>>
>>>
>>> Yes, that's easy, but it dodges the pre-generation randomizing
>>> problem rather than addressing it, and also requires generation
>>> of a full 8.64 billion numbers then modulo 86400 to get 100000
>>> unique sequential days before shuffling.
>>
>> Hm, I don't get it ;)
>> Just create 100k dates and then shuffle, what's the problem?
>>
>
> It's not really about dates.  It's about the rand problem that arises
> if you randomize 100,000 time_t values with the goal of 100,000 unique
> DD-MM-YYYY values.  Consider it generically.  Forget that it's a date
> function, and assume that you have a pool of input values for which output
> values only change for every 86400 inputs.  You want to get 100,000 random
> (but hopefully unique) outputs given only 100,000 randomly chosen inputs.
> How do you randomize your inputs where the input pool is minimum 8.64
> billion to guarantee that you *might* get 100,000 unique outputs.
>
>
You first get starting date and ending date. Then generate all possible 
dates in range. Then randomly pick required number of dates from that list..

-- 
press any key to continue or any other to quit...

[toc] | [prev] | [next] | [standalone]


#383641

Fromdeplorable owl <owl@rooftop.invalid>
Date2016-12-11 05:55 +0000
Message-ID<ahjgepg00q.ga@rooftop.invalid>
In reply to#383637
Melzzzzz <Melzzzzz@zzzzz.com> wrote:
> On 11/12/16 05:27 AM, deplorable owl wrote:
>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>>> On 11/12/16 05:00 AM, deplorable owl wrote:
>>>> Melzzzzz <mel@zzzzz.com> wrote:
>>>>> On Sat, 10 Dec 2016 19:56:49 +0000 (UTC)
>>>>> deplorable owl <owl@rooftop.invalid> wrote:
>>>>>
>>>>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>>>>>>> On 10/12/16 07:25 AM, deplorable owl wrote:
>>>>>>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>>>>>>>>
>>>>>>>> BTW, what's the proper approach to randomizing such a huge number
>>>>>>>> of values?  (A large enough pool of seconds so that randoms would
>>>>>>>> have a good chance of falling on 100,000 different days).
>>>>>>>>
>>>>>>>>
>>>>>>> You don't have to just filter out dupes ;p
>>>>>>> It is not needed to have 100000k uniques at all.
>>>>>>
>>>>>> Yeah, but filtering is just to get uniques.  Say you want 100000
>>>>>> unique days using random second values, minimizing dups and
>>>>>> generating exactly 100000 values, how would you approach that?
>>>>>
>>>>> I would generate 100000 days in order, then shuffle.
>>>>>
>>>>
>>>> Yes, that's easy, but it dodges the pre-generation randomizing
>>>> problem rather than addressing it, and also requires generation
>>>> of a full 8.64 billion numbers then modulo 86400 to get 100000
>>>> unique sequential days before shuffling.
>>>
>>> Hm, I don't get it ;)
>>> Just create 100k dates and then shuffle, what's the problem?
>>>
>>
>> It's not really about dates.  It's about the rand problem that arises
>> if you randomize 100,000 time_t values with the goal of 100,000 unique
>> DD-MM-YYYY values.  Consider it generically.  Forget that it's a date
>> function, and assume that you have a pool of input values for which output
>> values only change for every 86400 inputs.  You want to get 100,000 random
>> (but hopefully unique) outputs given only 100,000 randomly chosen inputs.
>> How do you randomize your inputs where the input pool is minimum 8.64
>> billion to guarantee that you *might* get 100,000 unique outputs.
>>
>>
> You first get starting date and ending date. Then generate all possible 
> dates in range. Then randomly pick required number of dates from that list..
> 

Again, forget that it's dates.  Say you have a step function f(x)
that only changes values for every 86400 values of x (x +/- integers).
You don't get to select random f(x).  You must select 100000 random x and
get 100000 hopefully unique f(x).  What does your rand routine look like?

[toc] | [prev] | [next] | [standalone]


#383645

FromMelzzzzz <Melzzzzz@zzzzz.com>
Date2016-12-11 07:11 +0100
Message-ID<o2iqn3$5n7$1@news.albasani.net>
In reply to#383641
On 11/12/16 06:55 AM, deplorable owl wrote:
> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>> On 11/12/16 05:27 AM, deplorable owl wrote:
>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>>>> On 11/12/16 05:00 AM, deplorable owl wrote:
>>>>> Melzzzzz <mel@zzzzz.com> wrote:
>>>>>> On Sat, 10 Dec 2016 19:56:49 +0000 (UTC)
>>>>>> deplorable owl <owl@rooftop.invalid> wrote:
>>>>>>
>>>>>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>>>>>>>> On 10/12/16 07:25 AM, deplorable owl wrote:
>>>>>>>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>>>>>>>>>
>>>>>>>>> BTW, what's the proper approach to randomizing such a huge number
>>>>>>>>> of values?  (A large enough pool of seconds so that randoms would
>>>>>>>>> have a good chance of falling on 100,000 different days).
>>>>>>>>>
>>>>>>>>>
>>>>>>>> You don't have to just filter out dupes ;p
>>>>>>>> It is not needed to have 100000k uniques at all.
>>>>>>>
>>>>>>> Yeah, but filtering is just to get uniques.  Say you want 100000
>>>>>>> unique days using random second values, minimizing dups and
>>>>>>> generating exactly 100000 values, how would you approach that?
>>>>>>
>>>>>> I would generate 100000 days in order, then shuffle.
>>>>>>
>>>>>
>>>>> Yes, that's easy, but it dodges the pre-generation randomizing
>>>>> problem rather than addressing it, and also requires generation
>>>>> of a full 8.64 billion numbers then modulo 86400 to get 100000
>>>>> unique sequential days before shuffling.
>>>>
>>>> Hm, I don't get it ;)
>>>> Just create 100k dates and then shuffle, what's the problem?
>>>>
>>>
>>> It's not really about dates.  It's about the rand problem that arises
>>> if you randomize 100,000 time_t values with the goal of 100,000 unique
>>> DD-MM-YYYY values.  Consider it generically.  Forget that it's a date
>>> function, and assume that you have a pool of input values for which output
>>> values only change for every 86400 inputs.  You want to get 100,000 random
>>> (but hopefully unique) outputs given only 100,000 randomly chosen inputs.
>>> How do you randomize your inputs where the input pool is minimum 8.64
>>> billion to guarantee that you *might* get 100,000 unique outputs.
>>>
>>>
>> You first get starting date and ending date. Then generate all possible
>> dates in range. Then randomly pick required number of dates from that list..
>>
>
> Again, forget that it's dates.  Say you have a step function f(x)
> that only changes values for every 86400 values of x (x +/- integers).
> You don't get to select random f(x).  You must select 100000 random x and
> get 100000 hopefully unique f(x).  What does your rand routine look like?
>
Same answer.


-- 
press any key to continue or any other to quit...

[toc] | [prev] | [next] | [standalone]


#383646

Fromdeplorable owl <owl@rooftop.invalid>
Date2016-12-11 06:49 +0000
Message-ID<ahjgjb00ag.it@rooftop.invalid>
In reply to#383645
Melzzzzz <Melzzzzz@zzzzz.com> wrote:
> On 11/12/16 06:55 AM, deplorable owl wrote:
>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>>> On 11/12/16 05:27 AM, deplorable owl wrote:
>>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>>>>> On 11/12/16 05:00 AM, deplorable owl wrote:
>>>>>> Melzzzzz <mel@zzzzz.com> wrote:
>>>>>>> On Sat, 10 Dec 2016 19:56:49 +0000 (UTC)
>>>>>>> deplorable owl <owl@rooftop.invalid> wrote:
>>>>>>>
>>>>>>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>>>>>>>>> On 10/12/16 07:25 AM, deplorable owl wrote:
>>>>>>>>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>>>>>>>>>>
>>>>>>>>>> BTW, what's the proper approach to randomizing such a huge number
>>>>>>>>>> of values?  (A large enough pool of seconds so that randoms would
>>>>>>>>>> have a good chance of falling on 100,000 different days).
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>> You don't have to just filter out dupes ;p
>>>>>>>>> It is not needed to have 100000k uniques at all.
>>>>>>>>
>>>>>>>> Yeah, but filtering is just to get uniques.  Say you want 100000
>>>>>>>> unique days using random second values, minimizing dups and
>>>>>>>> generating exactly 100000 values, how would you approach that?
>>>>>>>
>>>>>>> I would generate 100000 days in order, then shuffle.
>>>>>>>
>>>>>>
>>>>>> Yes, that's easy, but it dodges the pre-generation randomizing
>>>>>> problem rather than addressing it, and also requires generation
>>>>>> of a full 8.64 billion numbers then modulo 86400 to get 100000
>>>>>> unique sequential days before shuffling.
>>>>>
>>>>> Hm, I don't get it ;)
>>>>> Just create 100k dates and then shuffle, what's the problem?
>>>>>
>>>>
>>>> It's not really about dates.  It's about the rand problem that arises
>>>> if you randomize 100,000 time_t values with the goal of 100,000 unique
>>>> DD-MM-YYYY values.  Consider it generically.  Forget that it's a date
>>>> function, and assume that you have a pool of input values for which output
>>>> values only change for every 86400 inputs.  You want to get 100,000 random
>>>> (but hopefully unique) outputs given only 100,000 randomly chosen inputs.
>>>> How do you randomize your inputs where the input pool is minimum 8.64
>>>> billion to guarantee that you *might* get 100,000 unique outputs.
>>>>
>>>>
>>> You first get starting date and ending date. Then generate all possible
>>> dates in range. Then randomly pick required number of dates from that list..
>>>
>>
>> Again, forget that it's dates.  Say you have a step function f(x)
>> that only changes values for every 86400 values of x (x +/- integers).
>> You don't get to select random f(x).  You must select 100000 random x and
>> get 100000 hopefully unique f(x).  What does your rand routine look like?
>>
> Same answer.
> 

Did you note this part: "You don't get to select random f(x)" ?
You must pick 100000 random x, not 100000 random f(x).

[toc] | [prev] | [next] | [standalone]


#383647

FromMelzzzzz <mel@zzzzz.com>
Date2016-12-11 07:52 +0100
Message-ID<20161211075236.12628ebe@maxa-pc>
In reply to#383646
On Sun, 11 Dec 2016 06:49:30 +0000 (UTC)
deplorable owl <owl@rooftop.invalid> wrote:

> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
> > On 11/12/16 06:55 AM, deplorable owl wrote:  
> >> Melzzzzz <Melzzzzz@zzzzz.com> wrote:  
> >>> On 11/12/16 05:27 AM, deplorable owl wrote:  
> >>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:  
> >>>>> On 11/12/16 05:00 AM, deplorable owl wrote:  
> >>>>>> Melzzzzz <mel@zzzzz.com> wrote:  
> >>>>>>> On Sat, 10 Dec 2016 19:56:49 +0000 (UTC)
> >>>>>>> deplorable owl <owl@rooftop.invalid> wrote:
> >>>>>>>  
> >>>>>>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:  
> >>>>>>>>> On 10/12/16 07:25 AM, deplorable owl wrote:  
> >>>>>>>>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
> >>>>>>>>>>
> >>>>>>>>>> BTW, what's the proper approach to randomizing such a huge
> >>>>>>>>>> number of values?  (A large enough pool of seconds so that
> >>>>>>>>>> randoms would have a good chance of falling on 100,000
> >>>>>>>>>> different days).
> >>>>>>>>>>
> >>>>>>>>>>  
> >>>>>>>>> You don't have to just filter out dupes ;p
> >>>>>>>>> It is not needed to have 100000k uniques at all.  
> >>>>>>>>
> >>>>>>>> Yeah, but filtering is just to get uniques.  Say you want
> >>>>>>>> 100000 unique days using random second values, minimizing
> >>>>>>>> dups and generating exactly 100000 values, how would you
> >>>>>>>> approach that?  
> >>>>>>>
> >>>>>>> I would generate 100000 days in order, then shuffle.
> >>>>>>>  
> >>>>>>
> >>>>>> Yes, that's easy, but it dodges the pre-generation randomizing
> >>>>>> problem rather than addressing it, and also requires generation
> >>>>>> of a full 8.64 billion numbers then modulo 86400 to get 100000
> >>>>>> unique sequential days before shuffling.  
> >>>>>
> >>>>> Hm, I don't get it ;)
> >>>>> Just create 100k dates and then shuffle, what's the problem?
> >>>>>  
> >>>>
> >>>> It's not really about dates.  It's about the rand problem that
> >>>> arises if you randomize 100,000 time_t values with the goal of
> >>>> 100,000 unique DD-MM-YYYY values.  Consider it generically.
> >>>> Forget that it's a date function, and assume that you have a
> >>>> pool of input values for which output values only change for
> >>>> every 86400 inputs.  You want to get 100,000 random (but
> >>>> hopefully unique) outputs given only 100,000 randomly chosen
> >>>> inputs. How do you randomize your inputs where the input pool is
> >>>> minimum 8.64 billion to guarantee that you *might* get 100,000
> >>>> unique outputs.
> >>>>
> >>>>  
> >>> You first get starting date and ending date. Then generate all
> >>> possible dates in range. Then randomly pick required number of
> >>> dates from that list.. 
> >>
> >> Again, forget that it's dates.  Say you have a step function f(x)
> >> that only changes values for every 86400 values of x (x +/-
> >> integers). You don't get to select random f(x).  You must select
> >> 100000 random x and get 100000 hopefully unique f(x).  What does
> >> your rand routine look like? 
> > Same answer.
> >   
> 
> Did you note this part: "You don't get to select random f(x)" ?
> You must pick 100000 random x, not 100000 random f(x).
> 

It all boils down to same. If you dont have pool of unique numbers to
pick, you can't produce unique numbers... random functions are random...


-- 
press any key to continue or any other to quit...

[toc] | [prev] | [next] | [standalone]


#383651

Fromdeplorable owl <owl@rooftop.invalid>
Date2016-12-11 07:09 +0000
Message-ID<ahjblc00g.a3i@rooftop.invalid>
In reply to#383647
Melzzzzz <mel@zzzzz.com> wrote:
> On Sun, 11 Dec 2016 06:49:30 +0000 (UTC)
> deplorable owl <owl@rooftop.invalid> wrote:
> 
>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>> > On 11/12/16 06:55 AM, deplorable owl wrote:  
>> >> Melzzzzz <Melzzzzz@zzzzz.com> wrote:  
>> >>> On 11/12/16 05:27 AM, deplorable owl wrote:  
>> >>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:  
>> >>>>> On 11/12/16 05:00 AM, deplorable owl wrote:  
>> >>>>>> Melzzzzz <mel@zzzzz.com> wrote:  
>> >>>>>>> On Sat, 10 Dec 2016 19:56:49 +0000 (UTC)
>> >>>>>>> deplorable owl <owl@rooftop.invalid> wrote:
>> >>>>>>>  
>> >>>>>>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:  
>> >>>>>>>>> On 10/12/16 07:25 AM, deplorable owl wrote:  
>> >>>>>>>>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>> >>>>>>>>>>
>> >>>>>>>>>> BTW, what's the proper approach to randomizing such a huge
>> >>>>>>>>>> number of values?  (A large enough pool of seconds so that
>> >>>>>>>>>> randoms would have a good chance of falling on 100,000
>> >>>>>>>>>> different days).
>> >>>>>>>>>>
>> >>>>>>>>>>  
>> >>>>>>>>> You don't have to just filter out dupes ;p
>> >>>>>>>>> It is not needed to have 100000k uniques at all.  
>> >>>>>>>>
>> >>>>>>>> Yeah, but filtering is just to get uniques.  Say you want
>> >>>>>>>> 100000 unique days using random second values, minimizing
>> >>>>>>>> dups and generating exactly 100000 values, how would you
>> >>>>>>>> approach that?  
>> >>>>>>>
>> >>>>>>> I would generate 100000 days in order, then shuffle.
>> >>>>>>>  
>> >>>>>>
>> >>>>>> Yes, that's easy, but it dodges the pre-generation randomizing
>> >>>>>> problem rather than addressing it, and also requires generation
>> >>>>>> of a full 8.64 billion numbers then modulo 86400 to get 100000
>> >>>>>> unique sequential days before shuffling.  
>> >>>>>
>> >>>>> Hm, I don't get it ;)
>> >>>>> Just create 100k dates and then shuffle, what's the problem?
>> >>>>>  
>> >>>>
>> >>>> It's not really about dates.  It's about the rand problem that
>> >>>> arises if you randomize 100,000 time_t values with the goal of
>> >>>> 100,000 unique DD-MM-YYYY values.  Consider it generically.
>> >>>> Forget that it's a date function, and assume that you have a
>> >>>> pool of input values for which output values only change for
>> >>>> every 86400 inputs.  You want to get 100,000 random (but
>> >>>> hopefully unique) outputs given only 100,000 randomly chosen
>> >>>> inputs. How do you randomize your inputs where the input pool is
>> >>>> minimum 8.64 billion to guarantee that you *might* get 100,000
>> >>>> unique outputs.
>> >>>>
>> >>>>  
>> >>> You first get starting date and ending date. Then generate all
>> >>> possible dates in range. Then randomly pick required number of
>> >>> dates from that list.. 
>> >>
>> >> Again, forget that it's dates.  Say you have a step function f(x)
>> >> that only changes values for every 86400 values of x (x +/-
>> >> integers). You don't get to select random f(x).  You must select
>> >> 100000 random x and get 100000 hopefully unique f(x).  What does
>> >> your rand routine look like? 
>> > Same answer.
>> >   
>> 
>> Did you note this part: "You don't get to select random f(x)" ?
>> You must pick 100000 random x, not 100000 random f(x).
>> 
> 
> It all boils down to same. If you dont have pool of unique numbers to
> pick, you can't produce unique numbers... random functions are random...
> 

True, but you can A) choose a big enough pool, or B) choose an efficient
randomizing algorithm.  It's easy enough to get a big pool and reduce
the dupes to zero.  I would like to have your take on a randomizing
algorithm that would not require a pool of seconds spanning 70,000
years.

This is my approach, and it's far from ideal:

for(i=0;i<100000;i++)
{
  rannum[i]=random()%INT_MAX+(-INT_MAX/2);
  rannum[i]*=random()%(atoi(argv[1]));
}

anon@lowtide:~/code/dfsdates$ ./dupes 1
generated 100000 random time_t values to get 100000 days
day dupes: 99999
sorted:
rannum[0]: 0: 31-Dec-1969
rannum[99999]: 0: 31-Dec-1969
anon@lowtide:~/code/dfsdates$ ./dupes 5
generated 100000 random time_t values to get 100000 days
day dupes: 4081
sorted:
rannum[0]: -4294563276: 29-Nov-1833
rannum[99999]: 4294923596: 06-Feb-2106
anon@lowtide:~/code/dfsdates$ ./dupes 9
generated 100000 random time_t values to get 100000 days
day dupes: 1231
sorted:
rannum[0]: -8587334984: 16-Nov-1697
rannum[99999]: 8589040944: 05-Mar-2242
anon@lowtide:~/code/dfsdates$ ./dupes 99
generated 100000 random time_t values to get 100000 days
day dupes: 7
sorted:
rannum[0]: -105146334440: 17-Jan--1362 (year is BC)
rannum[99999]: 105017655638: 15-Nov-5297
anon@lowtide:~/code/dfsdates$ ./dupes 999
generated 100000 random time_t values to get 100000 days
day dupes: 0
sorted:
rannum[0]: -1068460845381: 28-Oct--31889 (year is BC)
rannum[99999]: 1063842312377: 26-Oct-35681
anon@lowtide:~/code/dfsdates$ 

[toc] | [prev] | [next] | [standalone]


#383654

FromMelzzzzz <Melzzzzz@zzzzz.com>
Date2016-12-11 08:23 +0100
Message-ID<o2iuua$vke$1@news.albasani.net>
In reply to#383651
On 11/12/16 08:09 AM, deplorable owl wrote:
> Melzzzzz <mel@zzzzz.com> wrote:
>> On Sun, 11 Dec 2016 06:49:30 +0000 (UTC)
>> deplorable owl <owl@rooftop.invalid> wrote:
>>
>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>>>> On 11/12/16 06:55 AM, deplorable owl wrote:
>>>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>>>>>> On 11/12/16 05:27 AM, deplorable owl wrote:
>>>>>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>>>>>>>> On 11/12/16 05:00 AM, deplorable owl wrote:
>>>>>>>>> Melzzzzz <mel@zzzzz.com> wrote:
>>>>>>>>>> On Sat, 10 Dec 2016 19:56:49 +0000 (UTC)
>>>>>>>>>> deplorable owl <owl@rooftop.invalid> wrote:
>>>>>>>>>>
>>>>>>>>>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>>>>>>>>>>>> On 10/12/16 07:25 AM, deplorable owl wrote:
>>>>>>>>>>>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>> BTW, what's the proper approach to randomizing such a huge
>>>>>>>>>>>>> number of values?  (A large enough pool of seconds so that
>>>>>>>>>>>>> randoms would have a good chance of falling on 100,000
>>>>>>>>>>>>> different days).
>>>>>>>>>>>>>
>>>>>>>>>>>>>
>>>>>>>>>>>> You don't have to just filter out dupes ;p
>>>>>>>>>>>> It is not needed to have 100000k uniques at all.
>>>>>>>>>>>
>>>>>>>>>>> Yeah, but filtering is just to get uniques.  Say you want
>>>>>>>>>>> 100000 unique days using random second values, minimizing
>>>>>>>>>>> dups and generating exactly 100000 values, how would you
>>>>>>>>>>> approach that?
>>>>>>>>>>
>>>>>>>>>> I would generate 100000 days in order, then shuffle.
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>> Yes, that's easy, but it dodges the pre-generation randomizing
>>>>>>>>> problem rather than addressing it, and also requires generation
>>>>>>>>> of a full 8.64 billion numbers then modulo 86400 to get 100000
>>>>>>>>> unique sequential days before shuffling.
>>>>>>>>
>>>>>>>> Hm, I don't get it ;)
>>>>>>>> Just create 100k dates and then shuffle, what's the problem?
>>>>>>>>
>>>>>>>
>>>>>>> It's not really about dates.  It's about the rand problem that
>>>>>>> arises if you randomize 100,000 time_t values with the goal of
>>>>>>> 100,000 unique DD-MM-YYYY values.  Consider it generically.
>>>>>>> Forget that it's a date function, and assume that you have a
>>>>>>> pool of input values for which output values only change for
>>>>>>> every 86400 inputs.  You want to get 100,000 random (but
>>>>>>> hopefully unique) outputs given only 100,000 randomly chosen
>>>>>>> inputs. How do you randomize your inputs where the input pool is
>>>>>>> minimum 8.64 billion to guarantee that you *might* get 100,000
>>>>>>> unique outputs.
>>>>>>>
>>>>>>>
>>>>>> You first get starting date and ending date. Then generate all
>>>>>> possible dates in range. Then randomly pick required number of
>>>>>> dates from that list..
>>>>>
>>>>> Again, forget that it's dates.  Say you have a step function f(x)
>>>>> that only changes values for every 86400 values of x (x +/-
>>>>> integers). You don't get to select random f(x).  You must select
>>>>> 100000 random x and get 100000 hopefully unique f(x).  What does
>>>>> your rand routine look like?
>>>> Same answer.
>>>>
>>>
>>> Did you note this part: "You don't get to select random f(x)" ?
>>> You must pick 100000 random x, not 100000 random f(x).
>>>
>>
>> It all boils down to same. If you dont have pool of unique numbers to
>> pick, you can't produce unique numbers... random functions are random...
>>
>
> True, but you can A) choose a big enough pool, or B) choose an efficient
> randomizing algorithm.

Efficient randomizing algorithm? Every randomizing algorithm takes 
number from pool of numbers. If you pick from same pool every time there 
is always chance to pick same number. you don't get it ?



-- 
press any key to continue or any other to quit...

[toc] | [prev] | [next] | [standalone]


#383655

Fromdeplorable owl <owl@rooftop.invalid>
Date2016-12-11 07:37 +0000
Message-ID<ahbocz003.abu4@rooftop.invalid>
In reply to#383654
Melzzzzz <Melzzzzz@zzzzz.com> wrote:
> On 11/12/16 08:09 AM, deplorable owl wrote:
>> Melzzzzz <mel@zzzzz.com> wrote:
>>> On Sun, 11 Dec 2016 06:49:30 +0000 (UTC)
>>> deplorable owl <owl@rooftop.invalid> wrote:
>>>
>>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>>>>> On 11/12/16 06:55 AM, deplorable owl wrote:
>>>>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>>>>>>> On 11/12/16 05:27 AM, deplorable owl wrote:
>>>>>>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>>>>>>>>> On 11/12/16 05:00 AM, deplorable owl wrote:
>>>>>>>>>> Melzzzzz <mel@zzzzz.com> wrote:
>>>>>>>>>>> On Sat, 10 Dec 2016 19:56:49 +0000 (UTC)
>>>>>>>>>>> deplorable owl <owl@rooftop.invalid> wrote:
>>>>>>>>>>>
>>>>>>>>>>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>>>>>>>>>>>>> On 10/12/16 07:25 AM, deplorable owl wrote:
>>>>>>>>>>>>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> BTW, what's the proper approach to randomizing such a huge
>>>>>>>>>>>>>> number of values?  (A large enough pool of seconds so that
>>>>>>>>>>>>>> randoms would have a good chance of falling on 100,000
>>>>>>>>>>>>>> different days).
>>>>>>>>>>>>>>
>>>>>>>>>>>>>>
>>>>>>>>>>>>> You don't have to just filter out dupes ;p
>>>>>>>>>>>>> It is not needed to have 100000k uniques at all.
>>>>>>>>>>>>
>>>>>>>>>>>> Yeah, but filtering is just to get uniques.  Say you want
>>>>>>>>>>>> 100000 unique days using random second values, minimizing
>>>>>>>>>>>> dups and generating exactly 100000 values, how would you
>>>>>>>>>>>> approach that?
>>>>>>>>>>>
>>>>>>>>>>> I would generate 100000 days in order, then shuffle.
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> Yes, that's easy, but it dodges the pre-generation randomizing
>>>>>>>>>> problem rather than addressing it, and also requires generation
>>>>>>>>>> of a full 8.64 billion numbers then modulo 86400 to get 100000
>>>>>>>>>> unique sequential days before shuffling.
>>>>>>>>>
>>>>>>>>> Hm, I don't get it ;)
>>>>>>>>> Just create 100k dates and then shuffle, what's the problem?
>>>>>>>>>
>>>>>>>>
>>>>>>>> It's not really about dates.  It's about the rand problem that
>>>>>>>> arises if you randomize 100,000 time_t values with the goal of
>>>>>>>> 100,000 unique DD-MM-YYYY values.  Consider it generically.
>>>>>>>> Forget that it's a date function, and assume that you have a
>>>>>>>> pool of input values for which output values only change for
>>>>>>>> every 86400 inputs.  You want to get 100,000 random (but
>>>>>>>> hopefully unique) outputs given only 100,000 randomly chosen
>>>>>>>> inputs. How do you randomize your inputs where the input pool is
>>>>>>>> minimum 8.64 billion to guarantee that you *might* get 100,000
>>>>>>>> unique outputs.
>>>>>>>>
>>>>>>>>
>>>>>>> You first get starting date and ending date. Then generate all
>>>>>>> possible dates in range. Then randomly pick required number of
>>>>>>> dates from that list..
>>>>>>
>>>>>> Again, forget that it's dates.  Say you have a step function f(x)
>>>>>> that only changes values for every 86400 values of x (x +/-
>>>>>> integers). You don't get to select random f(x).  You must select
>>>>>> 100000 random x and get 100000 hopefully unique f(x).  What does
>>>>>> your rand routine look like?
>>>>> Same answer.
>>>>>
>>>>
>>>> Did you note this part: "You don't get to select random f(x)" ?
>>>> You must pick 100000 random x, not 100000 random f(x).
>>>>
>>>
>>> It all boils down to same. If you dont have pool of unique numbers to
>>> pick, you can't produce unique numbers... random functions are random...
>>>
>>
>> True, but you can A) choose a big enough pool, or B) choose an efficient
>> randomizing algorithm.
> 
> Efficient randomizing algorithm? Every randomizing algorithm takes 
> number from pool of numbers. If you pick from same pool every time there 
> is always chance to pick same number. you don't get it ?
> 

Yes, of course, but what I am asking is, is there not a way to improve
this without resorting to increasing the pool size to a crazy range?
The sequential values for x seconds that guarantee 100,000 unique f(x)
days is about 273 years.  Surely there is a better way to consistently
get 0 day-dupes than by choosing a 70,000-year range of seconds.
 

[toc] | [prev] | [next] | [standalone]


#383656

FromMelzzzzz <Melzzzzz@zzzzz.com>
Date2016-12-11 08:40 +0100
Message-ID<o2ivsq$ub4$1@news.albasani.net>
In reply to#383655
On 11/12/16 08:37 AM, deplorable owl wrote:
> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>> On 11/12/16 08:09 AM, deplorable owl wrote:
>>> Melzzzzz <mel@zzzzz.com> wrote:
>>>> On Sun, 11 Dec 2016 06:49:30 +0000 (UTC)
>>>> deplorable owl <owl@rooftop.invalid> wrote:
>>>>
>>>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>>>>>> On 11/12/16 06:55 AM, deplorable owl wrote:
>>>>>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>>>>>>>> On 11/12/16 05:27 AM, deplorable owl wrote:
>>>>>>>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>>>>>>>>>> On 11/12/16 05:00 AM, deplorable owl wrote:
>>>>>>>>>>> Melzzzzz <mel@zzzzz.com> wrote:
>>>>>>>>>>>> On Sat, 10 Dec 2016 19:56:49 +0000 (UTC)
>>>>>>>>>>>> deplorable owl <owl@rooftop.invalid> wrote:
>>>>>>>>>>>>
>>>>>>>>>>>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>>>>>>>>>>>>>> On 10/12/16 07:25 AM, deplorable owl wrote:
>>>>>>>>>>>>>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> BTW, what's the proper approach to randomizing such a huge
>>>>>>>>>>>>>>> number of values?  (A large enough pool of seconds so that
>>>>>>>>>>>>>>> randoms would have a good chance of falling on 100,000
>>>>>>>>>>>>>>> different days).
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>
>>>>>>>>>>>>>> You don't have to just filter out dupes ;p
>>>>>>>>>>>>>> It is not needed to have 100000k uniques at all.
>>>>>>>>>>>>>
>>>>>>>>>>>>> Yeah, but filtering is just to get uniques.  Say you want
>>>>>>>>>>>>> 100000 unique days using random second values, minimizing
>>>>>>>>>>>>> dups and generating exactly 100000 values, how would you
>>>>>>>>>>>>> approach that?
>>>>>>>>>>>>
>>>>>>>>>>>> I would generate 100000 days in order, then shuffle.
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> Yes, that's easy, but it dodges the pre-generation randomizing
>>>>>>>>>>> problem rather than addressing it, and also requires generation
>>>>>>>>>>> of a full 8.64 billion numbers then modulo 86400 to get 100000
>>>>>>>>>>> unique sequential days before shuffling.
>>>>>>>>>>
>>>>>>>>>> Hm, I don't get it ;)
>>>>>>>>>> Just create 100k dates and then shuffle, what's the problem?
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>> It's not really about dates.  It's about the rand problem that
>>>>>>>>> arises if you randomize 100,000 time_t values with the goal of
>>>>>>>>> 100,000 unique DD-MM-YYYY values.  Consider it generically.
>>>>>>>>> Forget that it's a date function, and assume that you have a
>>>>>>>>> pool of input values for which output values only change for
>>>>>>>>> every 86400 inputs.  You want to get 100,000 random (but
>>>>>>>>> hopefully unique) outputs given only 100,000 randomly chosen
>>>>>>>>> inputs. How do you randomize your inputs where the input pool is
>>>>>>>>> minimum 8.64 billion to guarantee that you *might* get 100,000
>>>>>>>>> unique outputs.
>>>>>>>>>
>>>>>>>>>
>>>>>>>> You first get starting date and ending date. Then generate all
>>>>>>>> possible dates in range. Then randomly pick required number of
>>>>>>>> dates from that list..
>>>>>>>
>>>>>>> Again, forget that it's dates.  Say you have a step function f(x)
>>>>>>> that only changes values for every 86400 values of x (x +/-
>>>>>>> integers). You don't get to select random f(x).  You must select
>>>>>>> 100000 random x and get 100000 hopefully unique f(x).  What does
>>>>>>> your rand routine look like?
>>>>>> Same answer.
>>>>>>
>>>>>
>>>>> Did you note this part: "You don't get to select random f(x)" ?
>>>>> You must pick 100000 random x, not 100000 random f(x).
>>>>>
>>>>
>>>> It all boils down to same. If you dont have pool of unique numbers to
>>>> pick, you can't produce unique numbers... random functions are random...
>>>>
>>>
>>> True, but you can A) choose a big enough pool, or B) choose an efficient
>>> randomizing algorithm.
>>
>> Efficient randomizing algorithm? Every randomizing algorithm takes
>> number from pool of numbers. If you pick from same pool every time there
>> is always chance to pick same number. you don't get it ?
>>
>
> Yes, of course, but what I am asking is, is there not a way to improve
> this without resorting to increasing the pool size to a crazy range?

Only way is to make function non random. Pick any linear monotonic 
function and voila ;)




-- 
press any key to continue or any other to quit...

[toc] | [prev] | [next] | [standalone]


#383657

Fromdeplorable owl <owl@rooftop.invalid>
Date2016-12-11 09:05 +0000
Message-ID<ahgjbuc0q.bra@rooftop.invalid>
In reply to#383656
Melzzzzz <Melzzzzz@zzzzz.com> wrote:
> On 11/12/16 08:37 AM, deplorable owl wrote:
>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>>> On 11/12/16 08:09 AM, deplorable owl wrote:
>>>> Melzzzzz <mel@zzzzz.com> wrote:
>>>>> On Sun, 11 Dec 2016 06:49:30 +0000 (UTC)
>>>>> deplorable owl <owl@rooftop.invalid> wrote:
>>>>>
>>>>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>>>>>>> On 11/12/16 06:55 AM, deplorable owl wrote:
>>>>>>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>>>>>>>>> On 11/12/16 05:27 AM, deplorable owl wrote:
>>>>>>>>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>>>>>>>>>>> On 11/12/16 05:00 AM, deplorable owl wrote:
>>>>>>>>>>>> Melzzzzz <mel@zzzzz.com> wrote:
>>>>>>>>>>>>> On Sat, 10 Dec 2016 19:56:49 +0000 (UTC)
>>>>>>>>>>>>> deplorable owl <owl@rooftop.invalid> wrote:
>>>>>>>>>>>>>
>>>>>>>>>>>>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>>>>>>>>>>>>>>> On 10/12/16 07:25 AM, deplorable owl wrote:
>>>>>>>>>>>>>>>> Melzzzzz <Melzzzzz@zzzzz.com> wrote:
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>> BTW, what's the proper approach to randomizing such a huge
>>>>>>>>>>>>>>>> number of values?  (A large enough pool of seconds so that
>>>>>>>>>>>>>>>> randoms would have a good chance of falling on 100,000
>>>>>>>>>>>>>>>> different days).
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>>>
>>>>>>>>>>>>>>> You don't have to just filter out dupes ;p
>>>>>>>>>>>>>>> It is not needed to have 100000k uniques at all.
>>>>>>>>>>>>>>
>>>>>>>>>>>>>> Yeah, but filtering is just to get uniques.  Say you want
>>>>>>>>>>>>>> 100000 unique days using random second values, minimizing
>>>>>>>>>>>>>> dups and generating exactly 100000 values, how would you
>>>>>>>>>>>>>> approach that?
>>>>>>>>>>>>>
>>>>>>>>>>>>> I would generate 100000 days in order, then shuffle.
>>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>> Yes, that's easy, but it dodges the pre-generation randomizing
>>>>>>>>>>>> problem rather than addressing it, and also requires generation
>>>>>>>>>>>> of a full 8.64 billion numbers then modulo 86400 to get 100000
>>>>>>>>>>>> unique sequential days before shuffling.
>>>>>>>>>>>
>>>>>>>>>>> Hm, I don't get it ;)
>>>>>>>>>>> Just create 100k dates and then shuffle, what's the problem?
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> It's not really about dates.  It's about the rand problem that
>>>>>>>>>> arises if you randomize 100,000 time_t values with the goal of
>>>>>>>>>> 100,000 unique DD-MM-YYYY values.  Consider it generically.
>>>>>>>>>> Forget that it's a date function, and assume that you have a
>>>>>>>>>> pool of input values for which output values only change for
>>>>>>>>>> every 86400 inputs.  You want to get 100,000 random (but
>>>>>>>>>> hopefully unique) outputs given only 100,000 randomly chosen
>>>>>>>>>> inputs. How do you randomize your inputs where the input pool is
>>>>>>>>>> minimum 8.64 billion to guarantee that you *might* get 100,000
>>>>>>>>>> unique outputs.
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>> You first get starting date and ending date. Then generate all
>>>>>>>>> possible dates in range. Then randomly pick required number of
>>>>>>>>> dates from that list..
>>>>>>>>
>>>>>>>> Again, forget that it's dates.  Say you have a step function f(x)
>>>>>>>> that only changes values for every 86400 values of x (x +/-
>>>>>>>> integers). You don't get to select random f(x).  You must select
>>>>>>>> 100000 random x and get 100000 hopefully unique f(x).  What does
>>>>>>>> your rand routine look like?
>>>>>>> Same answer.
>>>>>>>
>>>>>>
>>>>>> Did you note this part: "You don't get to select random f(x)" ?
>>>>>> You must pick 100000 random x, not 100000 random f(x).
>>>>>>
>>>>>
>>>>> It all boils down to same. If you dont have pool of unique numbers to
>>>>> pick, you can't produce unique numbers... random functions are random...
>>>>>
>>>>
>>>> True, but you can A) choose a big enough pool, or B) choose an efficient
>>>> randomizing algorithm.
>>>
>>> Efficient randomizing algorithm? Every randomizing algorithm takes
>>> number from pool of numbers. If you pick from same pool every time there
>>> is always chance to pick same number. you don't get it ?
>>>
>>
>> Yes, of course, but what I am asking is, is there not a way to improve
>> this without resorting to increasing the pool size to a crazy range?
> 
> Only way is to make function non random. Pick any linear monotonic 
> function and voila ;)
> 

That sucks.  Oh well, if nothing else, at least by playing with
this I learned that there actually was a year zero.  :)

anon@lowtide:~/code/dfsdates$ ./getdaysec -62167201441 -t
31-Dec--1 23:59:57 (year is BC)
anon@lowtide:~/code/dfsdates$ ./getdaysec -62167201440 -t
31-Dec--1 23:59:58 (year is BC)
anon@lowtide:~/code/dfsdates$ ./getdaysec -62167201439 -t
31-Dec--1 23:59:59 (year is BC)
anon@lowtide:~/code/dfsdates$ ./getdaysec -62167201438 -t
01-Jan-0 00:00:00 (we are in YEAR ZERO!)
anon@lowtide:~/code/dfsdates$ ./getdaysec -62167201437 -t
01-Jan-0 00:00:01 (we are in YEAR ZERO!)
anon@lowtide:~/code/dfsdates$ ./getdaysec -62167201436 -t
01-Jan-0 00:00:02 (we are in YEAR ZERO!)
anon@lowtide:~/code/dfsdates$ ./getdaysec -62157201438 -t
25-Apr-0 17:46:40 (we are in YEAR ZERO!)
anon@lowtide:~/code/dfsdates$ ./getdaysec -62147201438 -t
19-Aug-0 11:33:20 (we are in YEAR ZERO!)
anon@lowtide:~/code/dfsdates$ ./getdaysec -62137201438 -t
13-Dec-0 05:20:00 (we are in YEAR ZERO!)
anon@lowtide:~/code/dfsdates$ ./getdaysec -62135579041 -t
31-Dec-0 23:59:57 (we are in YEAR ZERO!)
anon@lowtide:~/code/dfsdates$ ./getdaysec -62135579040 -t
31-Dec-0 23:59:58 (we are in YEAR ZERO!)
anon@lowtide:~/code/dfsdates$ ./getdaysec -62135579039 -t
31-Dec-0 23:59:59 (we are in YEAR ZERO!)
anon@lowtide:~/code/dfsdates$ ./getdaysec -62135579038 -t
01-Jan-1 00:00:00
anon@lowtide:~/code/dfsdates$ ./getdaysec -62135579037 -t
01-Jan-1 00:00:01
anon@lowtide:~/code/dfsdates$ ./getdaysec -62135579036 -t
01-Jan-1 00:00:02
anon@lowtide:~/code/dfsdates$ 
 

[toc] | [prev] | [next] | [standalone]


Page 5 of 6 — ← Prev page 1 2 3 4 [5] 6  Next page →

Back to top | Article view | comp.os.linux.advocacy


csiph-web