geometric rv code user defined function

14 vues (au cours des 30 derniers jours)
Anjali
Anjali le 26 Jan 2024
Modifié(e) : Torsten le 26 Jan 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

Réponses (1)

Torsten
Torsten le 26 Jan 2024
Modifié(e) : Torsten le 26 Jan 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

Catégories

En savoir plus sur Graph and Network Algorithms dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by