[Question]
  [
Output the numbers 1-16 (or any other set of 16 distinct items). Then, repeatedly, output a random value chosen uniformly from the last 16 items outputted.
After the same item is printed 16 times in a row, halt.
If a number appears multiple times in the last 16 values, it should have proportionally more chance to be chosen as the next number. If a number did *not* appear in the last 16 elements, it can't be chosen ever again.
0 bonus points to whoever can provide the probability distribution of each number becoming the last one standing.
  
[Answer]
# [Python](https://www.python.org), ~~102 88 86 85~~ 84 bytes
```
from random import*;*t,=range(16)
while~-len({*(x:=t[-16:])}):t+=choice(x),
print(t)
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72soLIkIz9vwYKlpSVpuhY3Q9KK8nMVihLzUoBUZm5BflGJlrVWiY4tUCg9VcPQTJOrPCMzJ7VONyc1T6NaS6PCyrYkWtfQzCpWs1bTqkTbNjkjPzM5VaNCU4eroCgzr0SjRBNiNtQKmFUA)
* -14 thanks to mousetail
* -1 thanks to loopy walt
Prints a list of numbers from 0 to 15.
#### Commented
```
from random import*;     # Import the random module for later
*t,=range(16)            # Set t equal to [0, 1, ..., 15]
                         # ([* ... ] unpacks it into a list)
while~-len(              # Loop while the number of unique items
      {*(x:=t[-16:])}):  # in the last 16 elements of t is not 1
                         # (setting x to the last 16 elements of t)
    t+=choice(x),        # Append a random element of x to t
print(t)                 # At the end, output t
```
[Answer]
# [Ruby](https://www.ruby-lang.org/), ~~55 51~~ 48 bytes
```
puts x=[*1..16];_,*x=x<<p(x.sample)while(x|x)[1]
```
[Try it online!](https://tio.run/##KypNqvz/v6C0pFihwjZay1BPz9As1jpeR6vCtsLGpkCjQq84MbcgJ1WzPCMzJ1WjoqZCM9ow9v9/AA "Ruby – Try It Online")
[Answer]
# [R](https://www.r-project.org/), ~~66~~ 61 bytes
```
x=Map(show,L<-1:16)
while(sd(L))L=c(L[-1],print(sample(L,1)))
```
[Try it online!](https://tio.run/##K/r/v8LWN7FAozgjv1zHx0bX0MrQTJOrPCMzJ1WjOEXDR1PTxzZZwyda1zBWp6AoM69EozgxtwAo6aNjqKmp@f8/AA "R – Try It Online")
### Explanation outline:
1. `Map` the `show` function over `1:16` (and save the vector to variable `L`).
2. We assign the result of the `Map` to `x` to avoid outputting its value (ugly list of nulls).
3. Then we `sample` one element from `L` and append to `L[-1]` (`L` without the first element).
4. Loop until `sd(L)==0` (this means that the last 16 numbers are all the same).
[Answer]
# [R](https://www.r-project.org/), 52 bytes
```
a=b=16:1;while(sd(a[b]))a=c(sample(a[b],1),a);rev(a)
```
[Try it online!](https://tio.run/##K/r/P9E2ydbQzMrQujwjMydVozhFIzE6KVZTM9E2WaM4MbcAKAYS0DHU1EnUtC5KLdNI1Pz/HwA "R – Try It Online")
Full program that yields an [R](https://www.r-project.org/) vector containing the sequence of values.  
[R](https://www.r-project.org/) displays this by default with index numbers (in square brackets) at the start of each line. If this is annoying, add 5 bytes more to wrap the output into a call to `cat()` [like this](https://tio.run/##K/r/P9E2ydbQzMrQujwjMydVozhFIzE6KVZTM9E2WaM4MbcAKAYS0DHU1EnUtE5OLNEoSi3TSNTU/P8fAA).
[Answer]
# JavaScript (ES7), 74 bytes
Same algorithm as the other version, but using the weirder set `"5368709124,false"`.
```
f=(s=2**29+[4,k=!1])=>/(.)\1{15}/.test(s)?s:f(s+s[Math.random()*16+k++|0])
```
[Try it online!](https://tio.run/##BcFLDoIwEADQs7ib6WCxBE00KZzAEyCLBlo/xY5hGjfq2et7D/d2Mq33V94mnn0pwYLYRqnmSENbRbsxI9quBo0X8zH7X62zlwyCvZwCCMlwdvmmV5dmfgIqc6BI9N2NWCZOwovXC18hAGL5Aw "JavaScript (Node.js) – Try It Online")
### How?
\$2^{29}=536870912\$ contains all digits from \$0\$ to \$9\$ exactly once, except \$4\$. Adding `[4,!1]` forces a coercion to a string and appends `"4"`, followed by a comma, followed by `"false"`.
---
# JavaScript (ES6), 83 bytes
Uses the hexadecimal characters `0-9` and `A-F`.
```
f=(s=(k=0)+'123456789ABCDEF')=>/(.)\1{15}/.test(s)?s:f(s+s[Math.random()*16+k++|0])
```
[Try it online!](https://tio.run/##BcFJDsIwDADA59TGIm2AlkUKiPXGC4BD1CYsLTGqIy7A28PMw76t1P39FYeBG5eSNyAGWlMgZXo0npTVdDZfb7a7/SFDs8xB4Vl/dPnLVXQSQXAlCw9CcjraeFO9DQ0/AQe6opboW1ww1RyEO6c6voIHxPQH "JavaScript (Node.js) – Try It Online")
### Commented
```
f = (                 // f is a recursive function taking:
  s = (k = 0) +       //   s = output string
    '123456789ABCDEF' //   k = counter
) =>                  //
/(.)\1{15}/.test(s)   // if s contains the same character repeated
?                     // 16 times in a row:
  s                   //   stop and return s
:                     // else:
  f(                  //   do a recursive call:
    s +               //     append to s
    s[                //     the character from s
      Math.random()   //     whose index is randomly chosen in
      * 16 + k++ | 0  //     [k .. k+15] (increment k afterwards)
    ]                 //     i.e. one of the last 16 characters
  )                   //   end of recursive call
```
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal), ~~15~~ ~~13~~ ~~12~~ 9 bytes
```
k6≬℅+Ḣ↔ƒ⋎
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyIiLCIiLCJrNuKJrOKEhSvhuKLihpTGkuKLjiIsIiIsIiJd)
Outputs characters from the string `"0123456789abcdef"`
*-3 thanks to emanresu*
## Explained (old)
```
k6≬℅+Ḣ↔ḣvt∑+
k6           # The string "0123456789abcdef"
  ≬   ↔      # apply the following and collect results while invariant:
   ℅+        #  append a random item of the string to the string
     Ḣ       #  remove the first character
       ḣvt   # separate the first item from that list and get the tail of each remaining item
          ∑+ # join that into a single string and append to the previously separated head
```
[Answer]
# [Brachylog](https://github.com/JCumin/Brachylog), 18 bytes
```
15⟦ẉ₂ᵐ{=|ṛRẉ&b,R↰}
```
[Try it online!](https://tio.run/##SypKTM6ozMlPN/r/39D00fxlD3d1Pmpqerh1QrVtzcOds4OAfLUknaBHbRtq////DwA "Brachylog – Try It Online")
```
15⟦                  The list [0, …, 15]
   ẉ₂ᵐ               Map writeln
      {           }  If
       =               All elements of the list are equal, then stop
        |            Else
         ṛR            R is a random element of the list
          Rẉ           writeln R
            &b         Remove the first element of the list
              ,R       Append R to the list
                ↰      Recursive call on this list
```
[Answer]
# [C (gcc)](https://gcc.gnu.org/), 105 bytes
```
j,k;a[16];f(i){for(k=i=16;a[--i]=i;);for(;k;j-(a[i++%16]=a[rand()%16])?k=16:--k)printf("%d ",j=a[i%16]);}
```
[Try it online!](https://tio.run/##TY29CoMwFIX3PIVYhBs0BReHpmlfQLp1EofUaHuNf2jsIj67TaTQnunej@9wCvYsim2rI81lFic5rwDpUvUjaIEiTixlDHOBnHJHueY1A5lhGAZWFzIbZaeAuodetW2cGNN0GLEzFfiB8vyothbuAl@3A3ZFM6vSO09GNfg4vi7kxwy2pSPE1kkrsYN3j4qShXg2077lHLjd05RSvuMKvscwmwl8/x@v2wc "C (gcc) – Try It Online")
[Answer]
# [Japt](https://github.com/ETHproductions/japt), ~~20~~ 19 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
Far too long but seeing as Japt has no infinite loops and can't loop until invariant, it'll have to do for now.
```
Go
@òÎÌÊ¨G}a@pUsX ö
```
[Test it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&code=R28KQPLOzMqoR31hQHBVc1gg9g)
```
Go\n@òÎÌÊ¨G}a@pUsX ö
G                        :16
 o                       :Range [0,G)
  \n                     :Assign to variable U
    @                    :Left function
     ò                   :  Partition U between elements where
      Î                  :    Sign of difference is truthy (non-zero)
       Ì                 :  Last element
        Ê                :  Length
         ¨G              :  >=16
           }             :End function
            a            :Run right function until left function returns true and return final result
             @           :Right function, taking 0-based iteration index X as argument
              p          :  Push to U
               UsX       :    Slice U from index X
                   ö     :    Random element
```
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E) `--no-lazy`, ~~15~~ 14 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
16L€=[DΩ=ª¦DË#
```
[Try it online!](https://tio.run/##yy9OTMpM/f/f0MznUdMa22iXcyttD606tMzlcLfy////dXXz8nVzEqsqAQ "05AB1E – Try It Online")
* -1 thanks to Kevin Cruijssen
### Alternative 15 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage) solution (thanks to Kevin Cruijssen)
```
16L[D16.£©Ωª®Ë#
```
[Try it Online!](https://tio.run/##AR8A4P9vc2FiaWX//zE2TFtEMTYuwqPCqc6pwqrCrsOLI///)
#### Explanation
```
16L             # Push [1..16]
   €=           # Print each item
     [          # Start an infinite loop:
      DΩ        #  Duplicate and push a random element of the list
        =ª      #  Print and append to the list
          ¦     #  Remove the first item
           DË#  #  If all items are equal, break
```
[Answer]
# [Python](https://www.python.org), 77 bytes
```
from random import*
t=range(16)
while t:T,*s=*t,choice(t);t=s[t==s:];print(T)
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m72soLIkIz9vwYKlpSVpuhY3fdOK8nMVihLzUoBUZm5BflGJFleJLVAgPVXD0EyTqzwjMydVocQqREer2FarRCc5Iz8zOVWjRNO6xLY4usTWttgq1rqgKDOvRCNEE2Io1GyYHQA)
Prints one number per line.
### How?
The two mildly clever bits are
1. the rolling tail end of the sequence is all equal if and only if it's equal to its next iteration
2. for the winding down it doesn't matter whether we truncate from the right (more logical) or the left (shorter) since all elements are equal
[Answer]
# [Nibbles](http://golfscript.com/nibbles/index.html), 10 bytes (20 nibbles)\*
```
/`.,16>>:$=`#$16$:/
```
\*[Nibbles](http://golfscript.com/nibbles/index.html) is a pure functional language and has no random number capability.  
So, this program uses the hash-modulo-16 of the last 16 values after each pick to select the next index. This is pseudo-random, but obviously will be the same on each run of the program.  
To more-closely mimic PRNGs from other programming languages, we can select a 'salt' value for the hash, to act as a 'seed': this needs to be appended to the program, and, additionally, the otherwise-implicit variables of the program then need to be explicitly specified, costing +3 nibbles (+1.5 bytes, so [11.5 bytes](https://i.stack.imgur.com/9UZue.png) not including the 'seed' itself).
```
/`.,16>>:$=`#$16$:/
 `.                     # iterate while unique
   ,16                  # starting with 1..16:
        :$              #   join the last list to
          =     $       #   its element at index
           `#$          #   itself hashed
              16        #   modulo-16
/                       # now, fold over this list from the right:
                 :      #   joining 
                  /     #     the (implicit) first element of the (implicit) left argument
                        #     to the (implicit) right argument
```
[![enter image description here](https://i.stack.imgur.com/G62N0.png)](https://i.stack.imgur.com/G62N0.png)
[Answer]
# [J](http://jsoftware.com/), 31 bytes
```
(,1}._1{"1(}.,?@#{])^:a:)@i.@16
```
[Try it online!](https://tio.run/##TcvBCoJAGATgu08xKrEr2a9LZbgUSUWn6NDdxEJrOyikdRF9dVs9dRiYgW9efWhKEQemDBkzdJ@vYh8JdAyLWI6NBIOrt9SZEfaX07HnrmgpEY0leEvuNrKb2LnKVDqRokgEvWOcdwS/0eQfcLG2o450Swa4GNVBVfVb3T61Kguo4ptVtXqkw5LI7s8SnNsedZjAduBJ6D9yawpFIlsao8jBWP8D "J – Try It Online")
> 
> 0 bonus points to whoever can provide the probability distribution of each number becoming the last one standing.
> 
> 
> 
```
┌──┬──────┐
│0 │1/136 │
├──┼──────┤
│1 │2/136 │
├──┼──────┤
│2 │3/136 │
├──┼──────┤
│3 │4/136 │
├──┼──────┤
│4 │5/136 │
├──┼──────┤
│5 │6/136 │
├──┼──────┤
│6 │7/136 │
├──┼──────┤
│7 │8/136 │
├──┼──────┤
│8 │9/136 │
├──┼──────┤
│9 │10/136│
├──┼──────┤
│10│11/136│
├──┼──────┤
│11│12/136│
├──┼──────┤
│12│13/136│
├──┼──────┤
│13│14/136│
├──┼──────┤
│14│15/136│
├──┼──────┤
│15│16/136│
└──┴──────┘
```
Proof: For example, the system of equations you'd solve for the n=3 case is:
$$
\begin{align} 
x\_1 &= \frac{x\_3}{3} \\
x\_2 &= x\_1 + \frac{x\_3}{3} \\
x\_3 &= x\_2 + \frac{x\_3}{3} \\
x\_1 + x\_2 + x\_3 &= 1
\end{align} 
$$
where \$x\_1\$ is the chance that number in positon 1 wins, etc -- where 1, if it is not picked the first round, vanishes forever.
The first equation represents that 1/3 of the time \$x\_1\$ will be picked and move into position 3, and the rest of the time of vanish. Thus its "value" is 1/3 of \$x\_3\$'s.
Similarly, \$x\_2\$ will always move into slot 1, where it has \$x\_1\$ chance of winning, and 1/3 of the time will also move into slot 3, giving it \$x\_3\$ chance of winning. And so on...
[Answer]
# Excel (ms365), 109 bytes
I do hope that this could get OP's approval. Since volatility would stand in the way of using a list of elements, the only way I could think about a repetitive function that would auto-stop when last 16 elements are exactly the same is to use a custom function made with the name-manager. In this case my function is called 'Z':
```
=LAMBDA(x,LET(y,RIGHT(x,16),IF(y=REPT(RIGHT(y),16),x,Z(x&MID(y,RANDBETWEEN(1,16),1)))))
```
[![enter image description here](https://i.stack.imgur.com/zpfLX.png)](https://i.stack.imgur.com/zpfLX.png)
Formula in `A1`:
```
=Z("ABCDEFGHIJKLMNOP")
```
This would make for a combined total of 87 + 22 = 109 bytes.
[Answer]
# TI-Basic, 54 bytes
```
For(I,1,16
Disp I
End
cumSum(1 or rand(16
While max(Ans≠max(Ans
augment(ΔList(cumSum(Ans)),{Ans(randInt(1,16
Disp Ans(16
End
```
`max(abs(ΔList(Ans` can be used instead of `max(Ans≠max(Ans` alternatively.
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), ~~16~~ 15 bytes
```
pK<TGWt{=t+KpOK
```
[Try it online!](https://tio.run/##K6gsyfj/v8DbJsQ9vKTatkTbu8Df@/9/AA)
Thanks @isaacg for -1 byte
### Explanation
```
 K<TG              # K = "abcdefghijklmnop" (all but the last ten elements of the alphabet)
p                  # print(K)
     Wt{           # while deduplicated K has more than one element
            pOK    #   print a random element of K
          +K       #   append this to K
        =t         #   remove the first element of K
```
[Answer]
# [Retina](https://github.com/m-ender/retina/wiki/The-Language), 43 bytes
```
16*.
Y`.`L
/(.)\1{15}$/^+-16,@v`(.).*
$&$1
```
[Try it online!](https://tio.run/##K0otycxLNPz/n8vQTEuPKzJBL8GHS19DTzPGsNrQtFZFP05b19BMx6EsASimp8WloqYCVAwA "Retina – Try It Online") Uses `ABCDEFGHIJKLMNOP`. Explanation:
```
16*.
```
Insert 16 `.`s.
```
Y`.`L
```
Transliterate them to uppercase letters using a different letter each time.
```
/(.)\1{15}$/^+
```
Repeat until the last 16 letters are identical.
```
-16,@v`
```
Randomly choose between one of the last 16 overlapping matches.
```
(.).*
```
Match any character and the rest of the string.
```
$&$1
```
Append the initial character to the match, i.e. append it to the string.
[Answer]
# [Go](https://go.dev), 177 bytes
```
import."math/rand"
func f(){N,M,l:=[]int{},1,16;for i:=1;i<17;i++{N=append(N,i);println(i)}
for M<16{k:=Intn(16)
x:=N[k]
println(x)
N=append(N[1:],x)
if x!=l{l=x;M=1}else{M++}}}
```
[Attempt This Online!](https://ato.pxeger.com/run?1=VU-xTsMwFNz9FSaTrThFXgJy6gEJBoZkoIUlymC1TvuUxImCKyJZ_hKWCIkPYOVP-BtSSEGd3tPdvXt3r2-7dvzs1KZSO40bBQZB07W9XQQWGh28H2wZXX99nMBG2f1lr8w2QOXBbHBJqMtYymoh8wKMdZ5xxuOkbHsMQvIElvwqgTB0mVRdp82WZAxo0vWTuDYEqEdHbbrksauEvDfWEB5TNAiZ5VWBTsKBon-HnIuCTQiUeLiQtavlkKSSe10_a5eGofd-Dv70k_LYi1Ds0Err6bx9IXTxaGAglP49CKIowqv1zcMaT1tA0VTtnLzLbmdqdh_H3_kN)
[Answer]
## Zsh, 73 bytes
```
set {a..p};<<<${(F)@};while 17=$@[RANDOM%16+1];shift;<<<$16;((${#@:#$1}))
```
[Try it online!](https://tio.run/##qyrO@P@/OLVEoTpRT6@g1trGxkalWsNN06HWujwjMydVwdDcVsUhOsjRz8XfV9XQTNsw1ro4IzOtBKzS0MxaQ0OlWtnBSlnFsFZT8/9/AA "Zsh – Try It Online")
I use single letters instead of up-to-two-digit numbers as the “16 distinct items”, which saves a byte. (It also gives extra flexibility, which I took advantage of in [an earlier version of this answer](https://codegolf.stackexchange.com/revisions/257440/1) with a more complex termination condition.)
Expanded and commented:
```
set {a..p}                    # set positional arguments 1=a, 2=b, ...
<<<${(F)@}                    # join arguments with newline, call implicit cat
while
  17=$@[RANDOM%16+1];         # append a random element
  shift;                      # remove the first element
  <<<$16;                     # print the last element
  ((${#@:#$1}))               # termination condition (see below)
                              # no loop body = empty loop body
```
For those unfamiliar with zsh: the positional arguments can be accessed through `$1`, `$2`, … like in other shells, and also through the variable `@` which mostly behaves like an array. Zsh array indexes start at 1. `RANDOM` is a special variable that returns a random number each time it's accessed; fortunately the range 0..32767 is dividible by 16 so all values are equally likely modulo 16.
Now for the termination condition. It's the arithmetic expression `${#@:#$1}`: the command is true if the integer expression has a nonzero value. The expression uses several parameter expansion features. From the outside in, first, we have `${#*spec*}` to count the number of elements in the parameter expansion of `*spec*`. Inside, we have `${*name*:#*pattern*}` which, when `*name*` is an array, removes the elements that match `*pattern*`. The `*name*` is `@`, i.e. the positional parameters. The `*pattern*` is `$1`. Thus we count the number of positional parameters that are not equal to the first one: this is 0 if and only if all the positional parameters are equal.
[Answer]
# [Julia](https://julialang.org), ~~73~~ ~~70~~ 69 bytes
```
^,~=last,rand
s=[1:16;]
while s∩s^16!=s^1
push!(s,~s^16)end
show(s)
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m700qzQnM3HBgqWlJWm6Fjdd43TqbHMSi0t0ihLzUriKbaMNrQzNrGO5yjMyc1IVih91rCyOMzRTtAWSXAWlxRmKGsU6dSAhzVSQ-oz8co1iTYhhUDNhZgMA)
* -1 byte thanks to MarcMush: reassign operators on the same line
	+ (Otherwise, a space is needed between `^` and `=`)
* -2 bytes thanks to MarcMush: replace `!allequal(s^16)` with `s∩s^16!=s^1`
	+ (`!allequal(last(s,16))` with `s∩last(s,16)!=last(s,1)`)
* -1 byte thanks to MarcMush: remove the newline before `end`
* Thanks also to MarcMush for spotting an error or two!
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 24 bytes
```
≔…α¹⁶θθＷ∧⁻θ⌊θ‽θ«ι≔⁺Φθλιθ
```
[Try it online!](https://tio.run/##S85ILErOT8z5/9@xuDgzPU/DuTI5J9U5I79AI1FHwdBMU0ehUNOaK6AoM69EA8Qqz8jMSVXQcMxL0fDNzCst1ijUUQAyMnNLc4HyQOVBiXkp@WC2pkI1FydEZyZQJyfUhoAcoC63zJyS1CKQ5hygnkyoNbX////XLcsBAA "Charcoal – Try It Online") Link is to verbose version of code. Uses `ABCDEFGHIJKLMNOP`. Explanation:
```
≔…α¹⁶θθ
```
Get and print the first `16` uppercase letters.
```
Ｗ∧⁻θ⌊θ‽θ«ι
```
While there is a choice of at least two different letters, pick and output a random letter from those remaining.
```
≔⁺Φθλιθ
```
Update the string of available letters.
23 bytes if the last letter does not need to be printed (it will be the same as the preceding 15):
```
≔…α¹⁶θＷ⁻θ⌊θ«→Ｐθ≔⁺Φθλ‽θθ
```
[Try it online!](https://tio.run/##Lc29CsIwFAXgOX2KjDcQhy4OOknBrVD6BiGG5sJtYv4qIj57TNXtDOd8R1sVtVdU6yUlXBwMT01msP4OSvL@KCQP4tw9LJLhMKIrCYLkLeBaVghCCP7q2Og3A6cZF5tbm42FMk4RXYZ9zf72RG19Rcom7gg1fFbu5r/O7@hdaz1s9AE "Charcoal – Try It Online") Link is to verbose version of code.
[Answer]
# [Pip](https://github.com/dloscutoff/pip), 21 bytes
```
P*Y,16T$=yY SyAE PRCy
```
Uses 0 to 15. [Attempt This Online!](https://ato.pxeger.com/run?1=m724ILNgwYKlpSVpuhZbA7QidQzNQlRsKyMVgisdXRUCgpwrIXJQJTClAA)
### Explanation
```
P*Y,16T$=yY SyAE PRCy
   ,16                 ; Range(16)
  Y                    ; Yank, storing in y variable
P*                     ; Print each
      T                ; Loop till
       $=y             ; all elements of y are equal:
                  RCy  ;  Choose a random element of y
                 P     ;  Print it
              AE       ;  Append that element to
            Sy         ;  y without its first element
          Y            ;  Yank that list as the new value of y
```
[Answer]
# [Factor](https://factorcode.org/), 69 bytes
```
16 iota [ dup 16 tail* dup all-eq? ] [ random suffix ] until drop ...
```
[Try it online!](https://tio.run/##LYyxCgIxEAV/5dWCARsLLSzFxkas5Ipw2RyLcZPbbEC/PgaxnBmY6GfL2u@3y/V8QKW1kcxUoV5CfmHR3ArLgqJk9inKYniSCiUc@24PzubxQGgFg8xz2vzAp7Sl9YRpxP@rthj5PUwT44SgucA51/sX "Factor – Try It Online")
[Answer]
# [Raku](https://raku.org/), 56 bytes
```
|(1..16),{@_.tail(16).pick}...{~@_~~/(\d+)[' '$0]**15$/}
```
[Try it online!](https://tio.run/##K0gtyjH7X5xYqZCVn5mnoK6grqOg8b9Gw1BPz9BMU6faIV6vJDEzRwPI0SvITM6u1dPTq65ziK@r09eISdHWjAbqUDGI1dIyNNWv/a/5HwA "Perl 6 – Try It Online")
This is a sequence of the form `initial-elements, { generator } ... { termination-check }`.
* The initial elements are from the range `1..16`, flattened with `|`.
* The generator takes the entire sequence generated so far in `@_`, then randomly picks an element from the last sixteen of them.
* The termination check stringifies the sequence, then checks that the string satisfies a regex: a space-separate sequence of digits that repeats sixteen times before the end of the string.
[Answer]
# [CJam](http://sourceforge.net/projects/cjam/), ~~24~~ 23 bytes
```
G,_:p;{_mR_p+(;__|,(}g;
```
[Try it online!](http://cjam.aditsu.net/#code=G%2C_%3Ap%3B%7B_mR_p%2B%28%3B__%7C%2C%28%7Dg%3B)
**Explanation**
```
G,_:p;                        create and print an array [0-16)
      {             }g        do...
       _mR                      pick a random number from the last 16
          _p+(;                 print, add to the list, and remove the oldest number
               __|,(          ...while the number of unique numbers in the last 16 != 1
                      ;       cleanup
```
**(-1 byte)** *replacing `1-` with `(`, courtesy of my bestie*
[Answer]
# [Arturo](https://arturo-lang.io), ~~74~~ ~~70~~ 67 bytes
```
a:@0..15prints a until[prints->a\0[]=a--a\0][a:@[sample a]++chop a]
```
[Try it](http://arturo-lang.io/playground?KKyOQc)
[Answer]
# Swift 5.6+, 107 bytes
```
var a=[_](1...16),i=0
a.map{print($0)}
while Set(a).count>1{a[i]=a.randomElement()!
print(a[i])
i=(i+1)%16}
```
Uses `a` as a circular buffer, overwriting a different position each run through the loop. For lack of a builtin "all elements are the same" operation, the loop condition converts it to a Set to count the number of unique elements.
[SwiftFiddle link](https://swiftfiddle.com/p2epgkuqwzeknjbvjvxhd6qgj4)
Ungolfed:
```
var arr = Array(1...16)
for el in arr {
  print(el)
}
var i = 0
while Set(arr).count > 1 {
    let x = arr.randomElement()!
    print(x)
    arr[i] = x
    i = (i + 1) % arr.count
}
```
[Answer]
# PHP 8, 110 bytes
```
$o=range(1,16);do$o[]=$o[count($o)-rand(1,16)];while(count(array_unique(array_slice($o,-16)))>1);print_r($o);
```
I wish PHP's array syntax was a little less verbose...
Works by building up an array by appending a random element from the last 16 elements, then printing it all at once, when the last 16 elements are all the same.
[Answer]
# [Zsh](https://www.zsh.org/), 101 bytes
```
seq 16|tee a;set `shuf a`
while shift;16=`shuf -n1 a`;<<<$16;s=(${(n)@});((s[1]<s[16]))&&<<<${(F)@}>a
```
[Try it online!](https://tio.run/##qyrO@P@/OLVQwdCspiQ1VSHRuji1RCGhOKM0TSExgas8IzMnVaE4IzOtxNrQzBYirptnCJSztrGxUTE0sy621VCp1sjTdKjVtNbQKI42jLUBEmaxmppqaiAl1RpuQDm7xP//AQ)
  ~~[114 bytes](https://tio.run/##JcmxDoMgEADQ3a@4geFucGBh6EHjfzQmMmAhMaT1qG0qfjs16fKW95XYmoQnaFNLCODZr/fN4STxNYOfqHvHtAS48C4xzYW1cf/rsz6frbVKm04cqh0zDQcxotz0aE/MSFRr@KTCjzXlAv0Carj6o7Uf)~~
  ~~[117b](https://tio.run/##JcuxDsIgEIDhvU9xQwcYHG5h8MD0PaRJGa5CYkjsYTWWPjvWuPzLl/8jsTXhB6CphRkCheW2OjVJfM4QJt29YroznGmTmOZCaNzfThkPJ2ttj6YTp/pNZT3smpSSK472iBm1rpXfqVBZwAN4n3/DcAl7a18 "Zsh – Try It Online")~~
Writes/reads from file `a`. Uses the shell `$argv` array to randomise and pick new values, and a sorted array `$s` to check equality.
Whoops, the initial version incorrectly ran forever. And then the second version was not uniformly random. Fixed now. Thanks to @Gillies for -13 bytes.
[Answer]
# Java 8, 135 bytes
```
()->{int a,m=16,i=0,c=1,t[]=new int[m];for(;c<m;c=a==t[(i+++15)%m]?c+1:1)System.out.println(t[i%m]=a=i<m?i:t[(int)(Math.random()*m)]);}
```
[Try it online!](https://tio.run/##TY@xcsIwEETr@CuuyYwUG09UJAVC4QegotSouMg2EZFkxjrIZDz@dkeAi2y5d29n94RXXJ2a7/l8@fTOgvWYEuzRRRiLArJcpHbo0LawyxYsuvaugY5xeXemx2sipJyxAw9qZnz1MWYYsApKvFdOvVZWiYq0UbH9ueXqYGTXD0zaTZBWoVKkmSvLUrzx52C2thRrwQ@/idpQ9xeqz0OmfGSkXb5nwG3C1q1vVCTO9khf9YCx6QPjL4EbLqf50XCZtzS8tw95JDtQjjxqAzgcEx@LJ1//XzXNfw "Java (JDK) – Try It Online")
Even if Java always loses by far, it was still a fun challenge to code!
]