[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: avoid narrow-to-region (was: Re: replace-regexp)
From: |
Emanuel Berg |
Subject: |
Re: avoid narrow-to-region (was: Re: replace-regexp) |
Date: |
Sun, 09 May 2021 08:59:57 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
Yuri Khan wrote:
>>> Consistency: If (f a b) returns t once, it must return
>>> t when called again with the same arguments. [...]
>>
>> But here, we want to randomize _every time_.
>
> Every time you do a random shuffle, but not within
> a single shuffle.
Why not?
> A theoretically sound (but still unnecessarily slow)
> sorting-based shuffle would first assign a random weight to
> each line, and then sort by that weight.
>
> But contrast with this:
>
> * Count the lines to be shuffled. Call it N.
> * Generate a random number K_1 from 1 to N. Swap line 1 with line K_1.
> * Generate a random number K_2 from 2 to N. Swap line 2 with line K_2.
> ...
> * Generate a random number K_{N-1} from N-1 to N. Swap line N-1 with
> line K_{N-1}.
DIY Yuri.
> Almost easy enough to put in Elisp
...
> and guarantees uniform distribution (as long as individual
> random indexes are uniformly distributed).
BTW, here is my other stuff, I'm pretty sure it all conforms
to modern-day computer science theory of sorting, but I'll let
you verify it just to be sure.
https://dataswamp.org/~incal/emacs-init/sort-incal.el
--
underground experts united
https://dataswamp.org/~incal
- Re: replace-regexp, (continued)
- Re: replace-regexp, Emanuel Berg, 2021/05/08
- Re: replace-regexp, Stefan Monnier, 2021/05/08
- Re: replace-regexp, Emanuel Berg, 2021/05/08
- Re: replace-regexp, Stefan Monnier, 2021/05/08
- Re: replace-regexp, Emanuel Berg, 2021/05/08
- Re: replace-regexp, Emanuel Berg, 2021/05/09
- avoid narrow-to-region (was: Re: replace-regexp), Emanuel Berg, 2021/05/08
- Re: avoid narrow-to-region (was: Re: replace-regexp), Yuri Khan, 2021/05/09
- Re: avoid narrow-to-region (was: Re: replace-regexp), Emanuel Berg, 2021/05/09
- Re: avoid narrow-to-region (was: Re: replace-regexp), Yuri Khan, 2021/05/09
- Re: avoid narrow-to-region (was: Re: replace-regexp),
Emanuel Berg <=
- Re: avoid narrow-to-region (was: Re: replace-regexp), Jean Louis, 2021/05/09
- Re: avoid narrow-to-region (was: Re: replace-regexp), Emanuel Berg, 2021/05/09
- Re: avoid narrow-to-region (was: Re: replace-regexp), Yuri Khan, 2021/05/09
- Re: avoid narrow-to-region (was: Re: replace-regexp), Emanuel Berg, 2021/05/09
- Re: avoid narrow-to-region (was: Re: replace-regexp), Yuri Khan, 2021/05/09
- Re: avoid narrow-to-region (was: Re: replace-regexp), Emanuel Berg, 2021/05/09
- Re: avoid narrow-to-region (was: Re: replace-regexp), Emanuel Berg, 2021/05/09
- Re: avoid narrow-to-region (was: Re: replace-regexp), Emanuel Berg, 2021/05/09
- Re: avoid narrow-to-region (was: Re: replace-regexp), Emanuel Berg, 2021/05/09
- same sound random sort everywhere (was: Re: avoid narrow-to-region (was: Re: replace-regexp)), Emanuel Berg, 2021/05/21