メインコンテンツ

histfit

分布近似をもつヒストグラム

説明

histfit(data) は、data の要素数の平方根に等しいビンの数を使用して data の値のヒストグラムをプロットし、正規密度関数を当てはめます。

histfit(data,nbins) は、nbins のビンを使用してヒストグラムをプロットし、正規密度関数を当てはめます。

histfit(data,nbins,dist) は、nbins 個のビンがあるヒストグラムをプロットし、dist で指定された分布による密度関数を当てはめます。

histfit(ax,___) は、Axes オブジェクト ax によって指定されたプロットの座標軸を使用します。ax を最初の入力引数として指定し、その後に上記の構文での入力引数の組み合わせが続きます。

h = histfit(___) は、ハンドル h のベクトルを返します。ここで、h(1) はヒストグラムへのハンドル、h(2) は密度曲線へのハンドルです。

すべて折りたたむ

平均 10、分散 1 の正規分布からサイズ 100 の標本を作成します。

rng default; % For reproducibility
r = normrnd(10,1,100,1);

正規分布近似によってヒストグラムを作成します。

histfit(r)

Figure contains an axes object. The axes object contains 2 objects of type bar, line.

histfit は、fitdist を使用して分布をデータに当てはめます。fitdist を使用して、当てはめに使用されたパラメーターを取得します。

pd = fitdist(r,'Normal')
pd = 
  NormalDistribution

  Normal distribution
       mu = 10.1231   [9.89244, 10.3537]
    sigma =  1.1624   [1.02059, 1.35033]

パラメーター推定の横にある区間は分布パラメーターの 95% 信頼区間です。

平均 10、分散 1 の正規分布からサイズ 100 の標本を作成します。

rng default; % For reproducibility
r = normrnd(10,1,100,1);

6 個のビンと正規分布近似によってヒストグラムを作成します。

histfit(r,6)

Figure contains an axes object. The axes object contains 2 objects of type bar, line.

パラメーターが (3,10) のベータ分布からサイズ 100 の標本を作成します。

rng default;  % For reproducibility
b = betarnd(3,10,100,1);

10 個のビンを使用してベータ分布近似をもつヒストグラムを作成します。

histfit(b,10,'beta')

Figure contains an axes object. The axes object contains 2 objects of type bar, line.

パラメーターが (3,10) のベータ分布からサイズ 100 の標本を作成します。

rng default;  % For reproducibility
b = betarnd(3,10,[100,1]);

10 個のビンを使用して平滑化関数近似をもつヒストグラムを作成します。

histfit(b,10,'kernel')

Figure contains an axes object. The axes object contains 2 objects of type bar, line.

平均 3、分散 1 の正規分布からサイズ 100 の標本を生成します。

rng('default') % For reproducibility
r = normrnd(3,1,100,1);

2 つのサブプロットを使用して Figure を作成し、ax1 および ax2 として Axes オブジェクトを返します。対応する Axes オブジェクトを参照し、各座標軸のセットで正規分布近似をもつヒストグラムを作成します。左のサブプロットでは、10 個のビンをもつヒストグラムをプロットします。右のサブプロットでは、5 個のビンをもつヒストグラムをプロットします。対応する Axes オブジェクトを関数 title に渡すことによって、各プロットにタイトルを追加します。

ax1 = subplot(1,2,1); % Left subplot
histfit(ax1,r,10,'normal')
title(ax1,'Left Subplot')

ax2 = subplot(1,2,2); % Right subplot
histfit(ax2,r,5,'normal')
title(ax2,'Right Subplot')

Figure contains 2 axes objects. Axes object 1 with title Left Subplot contains 2 objects of type bar, line. Axes object 2 with title Right Subplot contains 2 objects of type bar, line.

平均 10、分散 1 の正規分布からサイズ 100 の標本を作成します。

rng default % for reproducibility
r = normrnd(10,1,100,1);

正規分布近似によってヒストグラムを作成します。

h = histfit(r,10,'normal')

Figure contains an axes object. The axes object contains 2 objects of type bar, line.

h = 
  2×1 graphics array:

  Bar
  Line

ヒストグラムの棒の色を変更します。

h(1).FaceColor = [.8 .8 1];

Figure contains an axes object. The axes object contains 2 objects of type bar, line.

密度曲線の色を変更します。

h(2).Color = [.2 .2 .2];

Figure contains an axes object. The axes object contains 2 objects of type bar, line.

入力引数

すべて折りたたむ

ベクトルとして指定される入力データ。

例: data = [1.5 2.5 4.6 1.2 3.4]

例: data = [1.5 2.5 4.6 1.2 3.4]'

データ型: double | single

正の整数として指定される、ヒストグラムのビンの数。既定値は data の要素数の平方根を切り上げたものです。分布を当てはめる場合、既定のビンの数には [ ] を使用します。

例: y = histfit(x,8)

例: y = histfit(x,10,'gamma')

例: y = histfit(x,[ ],'weibull')

データ型: double | single

ヒストグラムに当てはめる分布。文字ベクトルまたは string スカラーを指定します。以下の表は、サポートされている分布を示しています。

分布名説明分布オブジェクト
'Beta'ベータ分布BetaDistribution
'BirnbaumSaunders'バーンバウム・サンダース分布BirnbaumSaundersDistribution
'Burr'ブール分布BurrDistribution
'Exponential'指数分布ExponentialDistribution
'Extreme Value' または 'ev'極値分布ExtremeValueDistribution
'Gamma'ガンマ分布GammaDistribution
'Generalized Extreme Value' または 'gev'一般化極値分布GeneralizedExtremeValueDistribution
'Generalized Pareto' または 'gp'一般化パレート分布GeneralizedParetoDistribution
'Half Normal' または 'hn'半正規分布HalfNormalDistribution
'InverseGaussian'逆ガウス分布InverseGaussianDistribution
'Kernel'ノンパラメトリックなカーネル平滑化分布。密度は、data 内のデータの範囲全体にわたる等間隔の 100 個の点において評価されます。これは連続分布標本で最も適切に機能します。KernelDistribution
'Logistic'ロジスティック分布LogisticDistribution
'Loglogistic'対数ロジスティック分布LoglogisticDistribution
'Lognormal'対数正規分布LognormalDistribution
'Nakagami'仲上分布NakagamiDistribution
'Negative Binomial' または 'nbin'負の二項分布NegativeBinomialDistribution
'Normal'正規分布NormalDistribution
'Poisson'ポアソン分布PoissonDistribution
'Rayleigh'レイリー分布RayleighDistribution
'Rician'ライス分布RicianDistribution
'Stable'安定分布StableDistribution
'tLocationScale't 位置-スケール分布tLocationScaleDistribution
'Weibull' または 'wbl'ワイブル分布WeibullDistribution

プロットの座標軸。Axes オブジェクトとして指定します。ax を指定しない場合、histfit は、現在の座標軸を使用してプロットを作成します。Axes オブジェクトを作成する方法の詳細については、axes を参照してください。

出力引数

すべて折りたたむ

プロットのハンドル。ベクトルとして返されます。h(1) はヒストグラムに対するハンドル、h(2) は密度曲線に対するハンドルです。histfit は、曲線の下の総面積がヒストグラムの総面積と一致するように密度を正規化します。

アルゴリズム

histfit は、fitdist を使用して分布をデータに当てはめます。fitdist を使用して、当てはめに使用されたパラメーターを取得します。

拡張機能

すべて展開する

バージョン履歴

R2006a より前に導入