random variable with normal distribution
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
how can i find the first five moments of a random variable with pdf gaussisn distribution , and finding the characteristic function all in matlab?
採用された回答
Image Analyst
2020 年 12 月 22 日
編集済み: Image Analyst
2020 年 12 月 22 日
To get a bunch of random numbers drawn from a normal distribution, use randn().
r = randn(...........
If you want the nth moment just take the nth root of the sum of the values and divide by the number of samples minus 1.
If you want the central moments, then subtract the mean before raising to a power.
Sounds like homework (so I didn't give the actual MATLAB code, which is actually pretty simple - just a single line of code). Is it homework?
7 件のコメント
saif yahya
2020 年 12 月 22 日
yes it is a homework
saif yahya
2020 年 12 月 22 日
the random variable x is defined by gaussian pdf has a support region x =[a,b], also with specific mean and standard deviation . how to use randn function to define this pdf, and how to find the moments (Mn)
Image Analyst
2020 年 12 月 22 日
Didn't they go over the formula in class? Here is some code including the Wikipedia definition:
fprintf('Beginning to run %s.m ...\n', mfilename);
% https://en.wikipedia.org/wiki/Moment_(mathematics)#Sample_moments
mu = 50;
sigma = 10;
numSamples = 1000000;
r = mu + sigma * randn(1, numSamples);
meanr = mean(r)
sdr = std(r)
histogram(r);
grid on;
xlabel('r')
ylabel('Count');
caption = sprintf('Mu = %.2f, SD = %.2f', mu, sigma);
title(caption);
% Find second moment
n = 2
mom = sum(r.^n) / (numSamples-1)
% Find second central moment
momCentral = sum((r - meanr).^n) / (numSamples-1)
fprintf('Done running %s.m ...\n', mfilename);

You simply need to put into a for loop over n and index the two moments by the loop index. Just add 2 lines of code and take one away. Beware than many universities employ plagiarism detectors.
saif yahya
2020 年 12 月 22 日
thank you very much.do you know how to find the characteristic function of this random variable ?
Image Analyst
2020 年 12 月 23 日
Use histogram() with the 'pdf' option to describe it numerically. Analytically it's the Gaussian function.
saif yahya
2020 年 12 月 23 日
if the above random variable r you defined by randn is truncated to have a region support r=[40,150] how to define the new pdf
Image Analyst
2020 年 12 月 23 日
histogram() will give you the actual, empirical pdf. Not some theoretical analytical function. So the values don't matter. Support doesn't matter. You get what the PDF actually IS.
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Random Number Generation についてさらに検索
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
