geometric rv code user defined function

조회 수: 3 (최근 30일)
Anjali
Anjali 2024년 1월 26일
편집: Torsten 2024년 1월 26일
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일
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

카테고리

Help CenterFile Exchange에서 Graph and Network Algorithms에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by