Is there a term for a random sequence of integers with every consecutive pair in the sequence being unequal?

I'm trying to generate a random sequence of integers whereby no two consecutive values are equal to each other. This sequence is meant to simulate changes in state only. Is there some term or concept which captures this idea that's already been formalized in probability?

My current approach is to generate an excess of random ints from the count I desire followed by a reduction that eliminates all the entries whose diff in the sequence is zero and further reducing to just the quantity desired should I have succeeded in yielding the necessary amount.

This related stack overflow post asks some implementation details for such on operation but I wonder if there's anything formal out there that conceptualizes this operation like a constrained random walk or something along those lines.

https://stackoverflow.com/questions/20284347/sequence-of-random-selection-with-no-two-consecutive-objects-same

• Your question needs to specify much more. What probability distribution do you want for this sequence? For instance, should all integers within a specified range be equiprobable? And regardless of that, what should be the probability distribution of consecutive pairs of integers? Triples of integers? Etc. – whuber Jan 23 at 22:56
• That's a good clarification indeed. I haven't thought that far yet, just wanted to find a target I could broaden a search for to ferret out what variants existed that I could evaluate against my use case. I had uniform distribution in mind, using for instance the numpy function randint which starts off uniformly distributed but I realize becomes bias in distribution as I filter the resulting sequence. How its distributed after such an operation is an open question for me. – jxramos Jan 23 at 23:10
• If the filtration is to eliminate all consecutive values (repeatedly) until none exist, that's equivalent to generating all possible such sequences equiprobably. There's a very simple algorithm to generate a sequence of length $n$ in the range $0,1,\ldots,N-1.$ Starting at $0$ (which is discarded), it computes the next number by uniformly generating a difference in the set $1,2,\ldots,N-1$ and adding that to the current number modulo $N$. Here is R code: function(n, N) { cumsum(sample.int(N-1, n, replace=TRUE) %% N) %% N } The first (mathematically superfluous) %% prevents overflow. – whuber Jan 23 at 23:17
• For some insight into the possibilities, look into low-discrepancy sequences. Although much of the focus is in higher dimensions, everything applies to one dimension (your application). – whuber Jan 23 at 23:36
{"ft_lang_label":"__label__en","ft_lang_prob":0.9181388,"math_prob":0.9338318,"size":1076,"snap":"2019-26-2019-30","text_gpt3_token_len":225,"char_repetition_ratio":0.0858209,"word_repetition_ratio":0.0,"special_character_ratio":0.20724908,"punctuation_ratio":0.07486631,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.97338015,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-06-20T07:35:38Z\",\"WARC-Record-ID\":\"<urn:uuid:953383b1-0797-4924-9357-a6f71f22eb64>\",\"Content-Length\":\"143634\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:6ab4296f-2de2-4774-a188-f7df4a613c86>\",\"WARC-Concurrent-To\":\"<urn:uuid:ad92a6a9-02e6-4ed2-a8c6-8787ca6ccc05>\",\"WARC-IP-Address\":\"151.101.129.69\",\"WARC-Target-URI\":\"https://stats.stackexchange.com/questions/388825/is-there-a-term-for-a-random-sequence-of-integers-with-every-consecutive-pair-in/388826\",\"WARC-Payload-Digest\":\"sha1:DXV6DBL3LO6ISJ3QGTM3MMGRGGS67PG3\",\"WARC-Block-Digest\":\"sha1:ECVVZFDECOPUDMPNZOG2ZS6XWM5RM2ML\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-26/CC-MAIN-2019-26_segments_1560627999163.73_warc_CC-MAIN-20190620065141-20190620091141-00122.warc.gz\"}"}