[Tutor] Fwd: How to roughly associate the values of two numpy arrays, or python lists if necessary
Peter Otten
__peter__ at web.de
Sun Sep 23 08:04:32 EDT 2018
Peter Otten wrote:
> Maybe you could sort the already-sorted property_b again, with some random
> offset:
>
>>>> import itertools
>>>> def wiggled(items, sigma):
> ... counter = itertools.count()
> ... def key(item): return random.gauss(next(counter), sigma)
> ... return sorted(items, key=key)
> ...
One more example:
>>> s = """\
... But my actual scientific problem requires that the correlation should be
... only approximate and I do not know how close to to a perfect correlation
... it should be. So, I need to introduce some lack of good correlation when
... I set up the correlation. How to do that is my problem.
... """
>>> print(textwrap.fill(" ".join(wiggled(s.split(), 2))))
But actual my scientific the requires that problem should only
correlation approximate be and not do I know how close to a perfect to
correlation should it So, be. I to lack need some introduce
correlation I of good when set correlation. up How to the that do
problem. is my
:)
More information about the Tutor
mailing list