Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

密度プロット

密度プロットは、KDEを使用してPDFを推定します。

ScottPlot.Plot myPlot = new();

var ys = SampleData.Faithful;

var hist = Histogram.WithBinCount(80, ys);

var histPlot = myPlot.Add.Histogram(hist);
histPlot.BarWidthFraction = 0.8;

var densityEstimate = hist.Bins.Select((x, i) => KernelDensity.Estimate(x, ys)).ToArray();
double scale = ys.Length;

var rescaledDensityEstimate = densityEstimate.Select(x => x * scale).ToArray();

var scat = myPlot.Add.Scatter(hist.Bins, rescaledDensityEstimate, Colors.Red);
scat.MarkerSize = 0;

myPlot.SavePng("demo.png", 400, 300);
このレシピは、カーネル密度推定カテゴリに含まれる多数のレシピの1つです