Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange
2 added 128 characters in body
source | link

Pyth, 4444 35 34 bytes


?eA.DhQ2+eQ*G,-eQJ*E@hc1thQ2+eQJ*G,-eQKE+eQK
.N?eA.DN2+T*G+LT_B*Y@hc1tN2*G+LT_BY
.N?eA.DhQ2+eQ*G,-eQJ*E@hc1thQ2+eQJ*G,-eQKE+eQKDN2+T*G+LT_B*Y@cNtN2*G+LT_BY

Try it online!Try it online! (The code above defines a function. :.* is appended on the link to invoke the function.)

The maths

This constructs the data symmetrically. If N is even, then the data are just the mean plus or minus the standard deviation. However, if N is odd, then we just opened a can of worms, since the mean has to be present for the data to be symmetric, and so the fluctuations have to be multiplied by a certain factor.

If n is even

  • Half of the data are μ+σ.
  • Half of the data are μ-σ.

If n is odd

  • One datum is μ.
  • Less than half of the data are μ+σ*sqrt(1+1n/(n-1)).
  • Less than half of the data are μ-σ*sqrt(1+1n/(n-1)).

Pyth, 44 bytes

?eA.DhQ2+eQ*G,-eQJ*E@hc1thQ2+eQJ*G,-eQKE+eQK

Try it online!

The maths

This constructs the data symmetrically. If N is even, then the data are just the mean plus or minus the standard deviation. However, if N is odd, then we just opened a can of worms, since the mean has to be present for the data to be symmetric, and so the fluctuations have to be multiplied by a certain factor.

If n is even

  • Half of the data are μ+σ.
  • Half of the data are μ-σ.

If n is odd

  • One datum is μ.
  • Less than half of the data are μ+σ*sqrt(1+1/(n-1)).
  • Less than half of the data are μ-σ*sqrt(1+1/(n-1)).

Pyth, 44 35 34 bytes


?eA.DhQ2+eQ*G,-eQJ*E@hc1thQ2+eQJ*G,-eQKE+eQK
.N?eA.DN2+T*G+LT_B*Y@hc1tN2*G+LT_BY
.N?eA.DN2+T*G+LT_B*Y@cNtN2*G+LT_BY

Try it online! (The code above defines a function. :.* is appended on the link to invoke the function.)

The maths

This constructs the data symmetrically. If N is even, then the data are just the mean plus or minus the standard deviation. However, if N is odd, then we just opened a can of worms, since the mean has to be present for the data to be symmetric, and so the fluctuations have to be multiplied by a certain factor.

If n is even

  • Half of the data are μ+σ.
  • Half of the data are μ-σ.

If n is odd

  • One datum is μ.
  • Less than half of the data are μ+σ*sqrt(n/(n-1)).
  • Less than half of the data are μ-σ*sqrt(n/(n-1)).
1
source | link

Pyth, 44 bytes

?eA.DhQ2+eQ*G,-eQJ*E@hc1thQ2+eQJ*G,-eQKE+eQK

Try it online!

The maths

This constructs the data symmetrically. If N is even, then the data are just the mean plus or minus the standard deviation. However, if N is odd, then we just opened a can of worms, since the mean has to be present for the data to be symmetric, and so the fluctuations have to be multiplied by a certain factor.

If n is even

  • Half of the data are μ+σ.
  • Half of the data are μ-σ.

If n is odd

  • One datum is μ.
  • Less than half of the data are μ+σ*sqrt(1+1/(n-1)).
  • Less than half of the data are μ-σ*sqrt(1+1/(n-1)).