Skip to content
Prev 252172 / 398498 Next

Finding pairs with least magnitude difference from mean

No, that's not what I meant, but maybe I didn't understand the question.
What I suggested would involve sorting y, not x: "sort the *distances*".
If you want to minimize the sd of a subset of numbers, you sort the numbers and find a subset that is clumped together.
If the numbers are a function of pairs, you compute the function for all pairs of numbers, and find a subset that's clumped together.
Anyway, it's an idea, not a theorem, so proof is left as an exercise for the esteemed reader.

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Hans W Borchers
Sent: Monday, February 28, 2011 2:17 PM
To: r-help at stat.math.ethz.ch
Subject: Re: [R] Finding pairs with least magnitude difference from mean

 <rex.dwyer <at> syngenta.com> writes:
You probably mean something like the following:

    x <- rnorm(10)
    y <- outer(x, x, "+") - (2 * mean(x))

    o <- order(x)
    sd(c(y[o[1],o[10]], y[o[2],o[9]], y[o[3],o[8]], y[o[4],o[7]], y[o[5],o[6]]))

This seems reasonable, though you would have to supply a more stringent
argument. I did two tests and it works alright.

--Hans Werner

______________________________________________
R-help at r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.




message may contain confidential information. If you are not the designated recipient, please notify the sender immediately, and delete the original and any copies. Any use of the message by you is prohibited.
Message-ID: <36180405F8418449918AD20618D110FC095BF5470F@USETCMSXMB02.NAFTA.SYNGENTA.ORG>
In-Reply-To: <loom.20110228T201544-898@post.gmane.org>