Bug 54879

Summary: jot(1) -r description
Product: Documentation Reporter: David Brinegar <manjot.3.brinegar>
Component: Books & ArticlesAssignee: Diomidis Spinellis <dds>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   

Description David Brinegar 2003-07-26 07:30:09 UTC
	
   Two inaccurate statements and missing information about defaults.



   "Random numbers are obtained through random(3)."

      is no longer true.



   "while 20 random 8-letter strings are produced with
      jot -r -c 160 a z | rs -g 0 8"

      cannot produce the letter z.



   And there is no mention of the default -w %.0f format which creates
   an unexpected distribution due to rounding.

Fix: 

"Random numbers are obtained through arc4random(3)."

   "while 20 random 8-letter strings are produced with
      jot -r -c 160 a { | rs -g 0 8

   Note: { comes after z (see man 7 ascii.)
   Note: jot -r -c 0 a z cannot produce a z character.

   And some hint about the default -w format and how "%.0f" skews the
   distribution would be useful.
How-To-Repeat: 	
   man 1 jot

   To see the affect of rounding:

   > jot -r 1000 1 4 | sort -n | uniq -c
    169 1    <= top and bottom are half as likely as the others
    344 2
    319 3
    168 4    <=

   Internally, jot is assigning random floating point values like so:

      [1.0, 1.5) => 1
      [1.5, 2.5] => 2
      (2.5, 3.5) => 3
      [3.5, 4.0) => 4

   which just follows from the way printf rounds "%.0f".

   > jot -w %d -r 1000 1 4 | sort -n | uniq -c
    335 1    <= uniform distribution, but no 4
    338 2
    327 3

   Here internally jot is flooring the same floating point values
   instead of rounding them.
Comment 1 dfilter service freebsd_committer freebsd_triage 2006-11-06 10:30:46 UTC
dds         2006-11-06 10:30:30 UTC

  FreeBSD src repository

  Modified files:
    usr.bin/jot          jot.1 jot.c 
  Log:
  Restore jot's ability to use a seed for producing a deterministic
  sequence of random numbers.
  This functionality was lost in revision 1.9 when the random number
  generator was switched to arc4random.
  
  PR:             docs/54879
  MFC after:      2 weeks
  
  Revision  Changes    Path
  1.19      +5 -1      src/usr.bin/jot/jot.1
  1.30      +13 -6     src/usr.bin/jot/jot.c
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
Comment 2 Diomidis Spinellis freebsd_committer freebsd_triage 2006-11-06 10:30:54 UTC
Responsible Changed
From-To: freebsd-doc->dds

I'm working on jot.
Comment 3 dfilter service freebsd_committer freebsd_triage 2006-11-06 10:40:25 UTC
dds         2006-11-06 10:39:49 UTC

  FreeBSD src repository

  Modified files:
    usr.bin/jot          jot.1 
  Log:
  See also arc4random
  
  PR:             docs/54879
  MFC after:      2 weeks
  
  Revision  Changes    Path
  1.20      +1 -0      src/usr.bin/jot/jot.1
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
Comment 4 dfilter service freebsd_committer freebsd_triage 2006-11-06 13:55:38 UTC
dds         2006-11-06 13:55:11 UTC

  FreeBSD src repository

  Modified files:
    usr.bin/jot          jot.1 jot.c 
  Log:
  Do What I Mean when the user asks for random integers or characters.
  Up to now jot would fail to generate the last character in the range
  or skew the integer distribution in a way that would generate the numbers
  in the range's limits with half the probability of the rest.
  
  This modification fixes the program, rather than documenting the
  strange behavior, as suggested in docs/54879.
  
  Also, correctly specify the range of random(3).
  
  PR:             docs/54879
  MFC after:      2 weeks
  
  Revision  Changes    Path
  1.22      +18 -1     src/usr.bin/jot/jot.1
  1.32      +32 -7     src/usr.bin/jot/jot.c
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
Comment 5 Diomidis Spinellis freebsd_committer freebsd_triage 2006-11-06 13:58:01 UTC
State Changed
From-To: open->patched

Revision 1.32 of jot.c and 1.21 of jot.1 fix the problem.
Comment 6 Diomidis Spinellis freebsd_committer freebsd_triage 2006-11-27 09:05:29 UTC
State Changed
From-To: patched->closed

MFCd changes to RELENG_6