1
$\begingroup$

I have data

data={{179.1,63.,63.058},{319.,59.,58.765},{9310.7,62.,62.5512},{280.9,60.,60.33},
{18727.1,55.,55.4295},{453.4,66.,66.3213},{323.1,64.,64.0556},{3873.6,45.,45.4111},
{3243.8,68.,68.4577},{225.6,64.,64.4262},{2169.2,64.,64.7714},{599.9,50.,50.6418},
{2224.6,55.,55.0478},{11.2,53.,53.0255},{689.7,55.,54.8958},{309.4,67.,66.8753},{304.1,62.,62.0358},
{200.4,63.,63.1477},{978.9,67.,66.9423},{330.2,60.,59.8176},{642.2,64.,63.9326},{760.,52.,52.0627},
{1247.,41.,41.6266},{226.6,64.,64.3129},{21505.2,64.,64.5351},{12481.1,69.,70.0073},
{369.6,48.,48.1341},{3110.8,55.,55.2583},{3613.1,57.,57.8282},{977.,68.,67.825},{326.,68.,68.6339},
{252.3,60.,60.3246},{3902.8,41.,41.1936},{116.9,49.,49.112},{38.4,66.,65.7397},{978.8,40.,40.2495},
{6345.,61.,61.3724},{1182.,65.,65.7034},{4869.1,52.,52.6189},{73.6,63.,63.1238},{214.4,55.,54.8221},
{635.7,60.,60.4719},{91.6,62.,62.0529},{160.9,69.,68.9743},{7388.9,68.,69.1788},{81.6,48.,48.5237},
{3427.6,60.,60.3152},{7215.5,64.,64.263}};

From above data I select a sample of size 5, ten times. Using

data1 = RandomChoice[data, {10, 5}]

and compute Mean of each three as

data2 = Mean[RandomChoice[data, {10, 5}]]

Now I need to produce data3 as Mean of first values, Variance of second values and Mean of third values (e.g {a,b,c} 'a' is first value, 'b' is second and 'c' is third value in data). Don't know how to proceed, kindly help me in this regards.


Edit: The layout of output should be

{{Mean of first 10 values, Variance of first 10 values, Mean of first 10 values}, {Mean of second 10 values, Variance of second 10 values, Mean of secnd 10 values},...{Mean of fifth 10 values, Variance of fifth 10 values, Mean of fifth 10 values}}.

$\endgroup$
  • $\begingroup$ {Mean@#[[All, 1]], Variance@#[[All, 2]], Variance@#[[All, 3]]} &@data1 like this, or if you're combining variance {Mean@#[[All, 1]], Variance@Flatten[#[[All, {2, 3}]]]} &@data1 $\endgroup$ – Histograms May 28 '15 at 18:09
  • $\begingroup$ @Histograms I think both are not, because output should be in the form {{7377.46, 61.6, 61.9234}, {2101.14, 56.8, 57.0879}, {3596.62, 55.9, 56.3203}, {4024.1, 57.2, 57.6848}, {2191.48, 56.6, 56.9012}} $\endgroup$ – SAAN May 28 '15 at 18:20
  • 1
    $\begingroup$ Does this work {Mean[#[[All, 1]]], Variance[#[[All, 2]]], Mean[#[[All, 3]]]} & /@ RandomChoice[data, {10, 5}] ? I wasn't sure what layout you wanted before. Your layout in the edit is also inconsistent with what your sampling (you said you wanted a sample size of 5 ten times. If instead you want a sample size of 10, 5 times, change {10,5} to {5,10} $\endgroup$ – Histograms May 28 '15 at 18:57
  • $\begingroup$ @Histograms Thanks, My initial thinking are same, but Mean[RandomChoice[data, {10, 5}]] de track me. Now I change data2 as well from your code. $\endgroup$ – SAAN May 29 '15 at 4:38
1
$\begingroup$
MapThread[Compose, {{Mean, Variance, Mean}, Transpose[#]}] & /@ RandomChoice[data, {10, 5}]
{{1915.56, 132.3, 61.7223}, {466.92, 47.2, 60.1022}, {3570.78, 92.3, 
52.7499}, {1528.44, 26.3, 59.6748}, {2116.58, 49.3, 
58.6244}, {942.22, 28.3, 62.5561}, {1256.34, 123.2, 
60.0873}, {1041.24, 10.3, 65.6974}, {1502.46, 11.7, 
59.6119}, {947.08, 58.7, 61.4479}}

p.s. you can read more about Compose in Is there a name for #1@#2&?. So it is not necessary, I just like it :)

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.