Suppose u have a file
A)1.8 2.5 3.8 1.9 -3.5 -3.5 3.2 -3.9 4.2 4.5 2.8 B)-1.3 -0.9 -0.7 -0.4 -0.8 -3.5 -3.5 -1.6 -4.5 <c> continue.... That is in a file where in each line have to calculate mean and varia +nce where A, B can ignored as just saying that u have separate line +where each line have input data points in one file program is <code> #!/usr/bin/perl -w open( FILE, "< file_1" ) or die "Can't open file_1 : $!"; while( <FILE> ){ @fields = split / /; for($i=0;$i < scalar(@fields); $i++ ){ $sum[$i]+=$fields[$i]; $sumsq[$i]+=$fields[$i]*$fields[$i]; } $n++; } for($i=0;$i < scalar(@sum); $i++ ){ $sum[$i] /= $n; $sumsq[$i] /= $n; $stddev = sqrt( $sumsq[$i] - $sum[$i]*$sum[$i] ); print( $sum[$i]." ".$stddev." " ); } close FILE </code> But while running the program error occured <c> rgument "" isn't numeric in addition (+) at meanStddev.pl line 6, <FIL +E> line 1. Argument "" isn't numeric in addition (+) at meanStddev.pl line 6, <FI +LE> line 1. Argument "" isn't numeric in addition (+) at meanStddev.pl Argument "\n" isn't numeric in addition (+) at meanStddev.pl line 6, < +FILE> line 3. 0.573333333333333 0.867998975933856 0 0 0.833333333333333 1.1785113019 +7758 0 0 1.26666666666667 1.79133717900592 0 0 0.633333333333333 0.89 +566858950296 0 0 -1.16666666666667 1.64991582276861 0 0 -1.1666666666 +6667 1.64991582276861 0 0 1.06666666666667 1.5084944665313 0 0 -1.3 1 +.83847763108502 0 0 1.4 1.97989898732233 0 0 1.5 2.12132034355964 0 0 + 0.933333333333333 1.31993265821489 0 0 -0.433333333333333 0.61282587 +7028341 0 0 -0.3 0.424264068711929 0 0 -0.233333333333333 0.329983164 +553722 0 0 -0.133333333333333 0.188561808316413 0 0 -0.26666666666666 +7 0.377123616632825 0 0 -1.16666666666667 1.64991582276861 0 0 -1.166 +66666666667 1.64991582276861 0 0 -0.533333333333333 0.754247233265651 + 0 0 -1.5 2.12132034355964
any suggestions

20080114 Janitored by Corion: Changed bold tags to code tags


In reply to to calculate mean and variance by cdfd123

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.