summaryrefslogtreecommitdiff
path: root/291/CH12/EX12.4b/eg12_4b.sce
diff options
context:
space:
mode:
Diffstat (limited to '291/CH12/EX12.4b/eg12_4b.sce')
-rwxr-xr-x291/CH12/EX12.4b/eg12_4b.sce26
1 files changed, 26 insertions, 0 deletions
diff --git a/291/CH12/EX12.4b/eg12_4b.sce b/291/CH12/EX12.4b/eg12_4b.sce
new file mode 100755
index 000000000..9b5114092
--- /dev/null
+++ b/291/CH12/EX12.4b/eg12_4b.sce
@@ -0,0 +1,26 @@
+function result= prob(N, M, K)
+ if(N==1 & M==0)
+ if(K >0)
+ result = 1;
+ else
+ result =0;
+ end
+
+ elseif (N==0 & M==1)
+ if(K <0)
+ result = 0;
+ else
+ result =1;
+ end
+ elseif (N==0 & M==0 &K==0)
+ result =1;
+ else
+ result = (prob(N-1, M, K-N-M)*N/(N+M)) + (prob(N, M-1, K)*M/(N+M));
+ //result = prob(N-1, M, K-N-M)*N/(N+M) + prob(N, M-1, K);
+ //result = result + prob(N, M-1, K);
+ end
+endfunction
+
+function result =pval(n,m,t)
+ result = 2*min(prob(n,m,t), 1-prob(n,m,t-1));
+endfunction \ No newline at end of file