/* Poisson fishing problem in Picat. https://www.reddit.com/r/probabilitytheory/comments/1fgmhgw/poisson_fishing_problem/ """ Question goes like this: A fisherman catches fish according to a Poisson process with rate 0.6 per hour. The fisherman will keep fishing for two hours. If he has caught at least one fish, he quits. Otherwise, he continues until he catches at least one fish. (a) Find the probability that the total time he spends fishing is between two and five hours. Solution and my conflicting approach: First of all he'll fish for more than 2 hrs if he catches no fish in first two hrs and the probability of that is P(k=0,t=2). 1.After two hrs, the probability that he fish for 3 more hrs is that he gets 1 fish in the interval of 3 hrs which is P(k=1,t=3). So total probability is P1 = P(k=0,t=2).P(k=1,t=3) 2. After 2 hrs, the probability that waiting time is less than 3hrs is P(0 go. /* This model: The probability (p) that the fishing is between 2 and 5 hours - according to this model - is very close to 0.5 (perhaps exactly 0.5?). var : len Probabilities: 1: 0.4425000000000000 2: 0.2480000000000000 3: 0.1328000000000000 4: 0.0811000000000000 5: 0.0410000000000000 6: 0.0256000000000000 7: 0.0132000000000000 8: 0.0068000000000000 9: 0.0032000000000000 10: 0.0022000000000000 11: 0.0018000000000000 12: 0.0008000000000000 14: 0.0004000000000000 15: 0.0003000000000000 13: 0.0002000000000000 17: 0.0001000000000000 mean = 2.2613 Histogram (total 10000) 1: 4425 ############################################################ (0.443 / 0.443) 2: 2480 ################################## (0.248 / 0.691) 3: 1328 ################## (0.133 / 0.823) 4: 811 ########### (0.081 / 0.904) 5: 410 ###### (0.041 / 0.945) 6: 256 ### (0.026 / 0.971) 7: 132 ## (0.013 / 0.984) 8: 68 # (0.007 / 0.991) 9: 32 (0.003 / 0.994) 10: 22 (0.002 / 0.996) 11: 18 (0.002 / 0.998) 12: 8 (0.001 / 0.999) 13: 2 (0.000 / 0.999) 14: 4 (0.000 / 1.000) 15: 3 (0.000 / 1.000) 17: 1 (0.000 / 1.000) var : total Probabilities: 1: 0.7333000000000000 2: 0.2153000000000000 3: 0.0457000000000000 4: 0.0052000000000000 5: 0.0005000000000000 mean = 1.3243 Histogram (total 10000) 1: 7333 ############################################################ (0.733 / 0.733) 2: 2153 ################## (0.215 / 0.949) 3: 457 #### (0.046 / 0.994) 4: 52 (0.005 / 0.999) 5: 5 (0.001 / 1.000) var : p Probabilities: true: 0.5029000000000000 false: 0.4971000000000000 mean = [true = 0.5029,false = 0.4971] Histogram (total 10000) false : 4971 ########################################################### (0.497 / 0.497) true : 5029 ############################################################ (0.503 / 1.000) */ go ?=> reset_store, run_model(10_000,$model,[show_probs,mean,show_histogram]), nl, % show_store_lengths,nl, % fail, nl. go => true. model() => Lambda = 6/10, Fishing = [], while (Fishing.sum == 0) NumFish = poisson_dist(Lambda), Fishing := Fishing ++ [NumFish] end, Len = Fishing.len, Total = Fishing.sum, P = check( (Len >= 2, Len <= 5)), add("len",Len), add("total",Total), add("p",P).