إعداد البيانات للحصول على مؤامرة 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