Through the simulation, show that probability of getting HEAD by tossing a fair coin is about 0.5. Write your observation from the simulation run.
if possible please explain the steps as I am new

댓글 수: 1

per isakson
per isakson 2022년 1월 20일
편집: per isakson 2022년 1월 20일
One way
vec = randi([0,1],1,1000);
number_of_heads = sum( vec );
number_of_tails = 1000 - number_of_heads
number_of_tails = 534

댓글을 달려면 로그인하십시오.

 채택된 답변

KSSV
KSSV 2022년 1월 20일
편집: KSSV 2022년 1월 20일

1 개 추천

n = 1000 ; % number of tosses
H = 0 ; % initialize Head count
T = 0 ; % initialize Tails count
% loop of toss
for i = 1:n
if rand > 0.5 % count as heads if random number is > 0.5
H = H+1 ;
else % count as tails if random num,ber is < 0.5
T = T+1 ;
end
end
% getting head
ph = H/n
ph = 0.4890
% Getting Tails
Pt = T/n
Pt = 0.5110

댓글 수: 2

ANKIT  GOSWAMI
ANKIT GOSWAMI 2022년 1월 20일
please can u explain steps
KSSV
KSSV 2022년 1월 20일
Edited the code with comments

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Mathematics and Optimization에 대해 자세히 알아보기

제품

릴리스

R2021b

태그

질문:

2022년 1월 20일

편집:

2022년 1월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by