geometric rv code user defined function

I tried to code geometric rv pdf but it's giving accurate result for p=0.5 onlyl
Here, is the code
t=1:10;
p=0.95;
f=geometric_rv(t, p);
z=pdf('geo', t, p);
figure;
plot(f);
hold on;
stem(z);
legend('User-defined', 'system in-built');
hold off;
function f=geometric_rv(t, p)
f=(1-p)*p.^(t);
end

回答 (1 件)

Torsten
Torsten 2024 年 1 月 26 日
編集済み: Torsten 2024 年 1 月 26 日

0 投票

t=0:10;
p=0.95;
f=geometric_rv(t, p)
f = 1×11
0.9500 0.0475 0.0024 0.0001 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
z=pdf('Geo', t, p)
z = 1×11
0.9500 0.0475 0.0024 0.0001 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000
figure;
plot(f);
hold on;
stem(z);
legend('User-defined', 'system in-built');
hold off;
function f=geometric_rv(t, p)
f=p*(1-p).^t;
end

カテゴリ

ヘルプ センター および File ExchangeGraph and Network Algorithms についてさらに検索

製品

質問済み:

2024 年 1 月 26 日

編集済み:

2024 年 1 月 26 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by