統計を使用して::記述モジュールをCDFプロット用のデータを準備?

StackOverflow https://stackoverflow.com/questions/2418969

  •  19-09-2019
  •  | 
  •  

質問

誰もが(私は浮動小数点数の束を持っている)CDFをプロットするためにデータを準備する方法を知っていますか?私は、統計::記述のモジュールはgnuplotを使って上と初見に計画していました最高のフィット感を見えたが、私はここにいくつかの助けを必要とするかもしれないように見えます。

役に立ちましたか?

解決

あなたの質問は少しあいまいですが、これは、あなたが開始される可能性があります:

use strict;
use warnings;

use Statistics::Descriptive;
my $stat = Statistics::Descriptive::Full->new;

# Generate some data.
my @data = map { rand 100 } 1 .. 10000;
$stat->add_data(@data);

# Put the data into a frequency distribution with 10 bins.
# The distribution will be represented as a hash, where a hash
# key represents the max value within a bin and the hash value
# is the frequency count for that bin (I'm fudging this a bit;
# see the documentation for more accurate details).
my $n_bins = 10;
my %dist = $stat->frequency_distribution($n_bins);
my @bin_maxes = sort {$a <=> $b} keys %dist;

# Check it out.    
for my $m (@bin_maxes) {
    printf "%6.3f %4d\n", $m, $dist{$m};
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top