Quick and dirty code illustrating the principle, undoubtedly fraught with syntax errors and incorrectly offset list indexes;
@tables = ('csv_1', 'csv_2', ..., 'csv_n'); # or a directorylist to get all csv files in your directory $num_types = 6; $num_lengths = 9; for $table (0 .. $#tables) { #parse file into 2-d list open(FILE, $tables[$table]); while($line = <FILE>) { @line_parts = split(/delimiter/, $line); push @this_table, [ @line_parts ]; } close(FILE); #keep a running total of counts for each position for $length (1 .. $num_lengths) { for $type (1 .. $num_types) { $totals[$length][$type] = $totals[$length][$type] + $th +is_table[$length-1][$type-1]; $totals_squared[$length][$type] = $totals_squared[$leng +th][$type] + ($this_table[$length-1][$type-1]^2); } } } #you now have everything you need to calcluate mena and sd for every p +osition for $i (0 .. $#totals) { for $j (0 .. $#{$totals[$i]}) { #check syntax! $mean = $totals[$i][$j]/$#tables; $sd = sqrt( ($totals_squared[$i][$j] -($totals[$i][$j]^s/$#t +ables))/ ($#tables-1) ) #note that this considers the data as a 'sample'. #If it is to be considered a 'population', then replace "$#t +ables-1" with $#tables } }
For info on the raw score method of calculating sd, see
http://www.mnstate.edu/wasson/ed602calcsdraws.htm
or
http://www.med.umkc.edu/tlwbiostats/variability.html

In reply to Re: Mean and standard deviation amongst multiple matrices by punch_card_don
in thread Mean and standard deviation amongst multiple matrices by knirirr

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.