I was able to solve Perl Project 2: Descriptive Statistics successfully. However, I'd like to know if I "cheated" by using use terms and functionalities that had not been introduced in the coursework. While I don't actually care about the "cheating," I am concerned that I may have failed to learn a particular tool that I will need when I begin analyzing some transcriptome data. The Input and Output is listed below. Thanks for your thoughts.
#!/usr/bin/perl
use strict; use warnings; use List::Util qw(sum); use List::Util qw(min max);
#This program will determine the following for a string of values entered on the command line: Count, Sum, Mean, Min, Max, Median Value, Population Variance, Sample Variance, Population Standard Deviation, Sample Standard Deviation
die "usage:
stats.pl <number1> <number2> <etc.>\n" unless @ARGV >1;
#Report #1: Counts
my @numbers = @ARGV;
print "Counts: ",( scalar(@numbers)), "\n";
#Report #2: Sum
my $sum = sum(@ARGV);
print "Sum: $sum\n";
#Report #3: Mean
my $mean = (sum(@ARGV)/@ARGV);
print "Mean: $mean\n";
#Report #4: Min Value
my $min = min @ARGV;
print "Min: $min\n";
#Report #5: Max Value
my $max = max @ARGV;
print "Max: $max\n";
#Report #6: Median
my $median = ($min + $max)/2;
print "Median: $median\n";
#Report #7: Population Variance
my @squares = map { ((($_)-$mean)**2)} @numbers;
my @sum = sum(@squares);
my $pop_var = (@sum/5);
print "pop var: $pop_var\n";
#Report #8: Sample Variance
my $samp_var = (@sum/4);
print "samp var: $samp_var\n";
#Report #9: Population Standard Deviation
my $pop_stdev = (($pop_var)**0.5);
print "pop stdev: $pop_stdev\n";
#Report #10: Sample Standard Deviation
my $samp_stdev = (($samp_var)**0.5);
print "samp stdev: $samp_stdev\n";