geometric rv code user defined function

3 visualizzazioni (ultimi 30 giorni)
Anjali
Anjali il 26 Gen 2024
Modificato: Torsten il 26 Gen 2024
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

Risposte (1)

Torsten
Torsten il 26 Gen 2024
Modificato: Torsten il 26 Gen 2024
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

Categorie

Scopri di più su Graph and Network Algorithms in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by