Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

How can we find the mean of the following type of data?

{{β -> 0.516819}, {β -> 0.499907}, 
 {β -> 0.494064}, {β -> 0.472742}, 
 {β -> 0.537485}, {β -> 0.478291}, 
 {β -> 0.523855}, {β -> 0.483624}, 
 {β -> 0.50126},  {β -> 0.527267}}

Which command could be used to find the mean of this data?

share|improve this question
1  
Welcome to SE! It will help those might answer if you would please post code that is syntactically correct and properly formatted. See editing help. –  Michael E2 Jan 23 at 12:49
    
This should be helpful: Using the result of Solve in subsequent calculations, together with Mean. –  Michael E2 Jan 23 at 12:51
    
@JacobAkkerboom Sorry, it was involuntary. Please rollback my edit to yours if think it better. (or merge both!) –  belisarius Jan 23 at 13:08

3 Answers 3

Mean[beta /. {{beta -> 0.516819}, {beta -> 0.499907}, {beta -> 
     0.494064}, {beta -> 0.472742}, {beta -> 0.537485}, {beta -> 
     0.478291}, {beta -> 0.523855}, {beta -> 0.483624}, {beta -> 
     0.50126}, {beta -> 0.527267}}]
share|improve this answer

Considering the votes, I think Timings are in order.

Double semicolons are intentional, they prevent extra memory use when $HistoryLength > 1

Timing comparison between other answers

nn = 1*^6;
rands = RandomReal[1, nn]; ;
data = {b -> #} & /@ rands; ;

Mean@data[[All, 1, 2]] // Timing
Mean@(b /. data) // Timing

Outputs

{0.069164, 0.500199}
{0.983088, 0.500199}

Perhaps also noteworthy

<<Developer`
data[[All, 1, 2]] // PackedArrayQ
(b /. data) // PackedArrayQ

Outputs

False
False
share|improve this answer

[Beta] is bad syntax, so i replaced all by beta

Mean[{{beta->0.516819},{beta->0.499907},{beta->0.494064},{beta->0.472742},
{beta->0.537485},{beta->0.478291},{beta->0.523855},{beta->0.483624},{beta->0.50126},
{beta->0.527267}}[[All,1,2]]]

If you want the variance, try opening the documentation and search for it

share|improve this answer
    
Thanks a lot ....... –  Reema Irum Jan 23 at 12:56

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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