For info on the raw score method of calculating sd, see@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 } }
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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |