This file is indexed.

/usr/share/axiom-20170501/src/algebra/RIDIST.spad is in axiom-source 20170501-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
)abbrev package RIDIST RandomIntegerDistributions
++ Description:
++ This package exports integer distributions

RandomIntegerDistributions() : SIG == CODE where

  SIG ==> with

   uniform : Segment Integer -> (() -> Integer)
     ++ uniform(s) as
     ++     l + u0 + w*u1 + w**2*u2 +...+ w**(n-1)*u-1 + w**n*m
     ++ where
     ++     s = a..b
     ++     l = min(a,b)
     ++     m = abs(b-a) + 1
     ++     w**n < m < w**(n+1)
     ++     u0,...,un-1  are uniform on  0..w-1
     ++     m            is  uniform on  0..(m quo w**n)-1

   binomial : (Integer, RationalNumber) -> (() -> Integer)
     ++ binomial(n,f) \undocumented

   poisson : RationalNumber -> (() -> Integer)
     ++ poisson(f) \undocumented

   geometric : RationalNumber -> (() -> Integer)
     ++ geometric(f) \undocumented

   ridHack1 : (Integer,Integer,Integer,Integer) -> Integer
     ++ ridHack1(i,j,k,l) \undocumented

  CODE ==> add

   import RandomNumberSource()
   import IntegerBits()

   uniform aTob ==
       a := lo aTob;  b := hi aTob
       l := min(a,b); m := abs(a-b) + 1

       w := 2**(bitLength size() quo 2)::NonNegativeInteger

       n  := 0
       mq := m  -- m quo w**n
       while (mqnext := mq quo w) > 0 repeat
           n  := n + 1
           mq := mqnext
       ridHack1(mq, n, w, l)

   ridHack1(mq, n, w, l) ==
       r := randnum mq
       for i in 1..n repeat r := r*w + randnum w
       r + l