{- |
Ceneralization of "Numeric.Probability.Example.Boys"
Consider a family of n children. Given that there are k boys in the family,
what is the probability that there are m boys in the family?
-}moduleNumeric.Probability.Example.NBoyswhereimportqualifiedNumeric.Probability.Distribution asDistimportNumeric.Probability.Distribution (Event ,(?? ),(?=<< ),)importNumeric.Probability.Example.Boys (Dist ,Probability ,Child (Boy ),birth ,)importControl.Monad(replicateM)typeFamily =[Child ]family::Int->Dist Family familyn =replicateMn birth countBoys::Family ->IntcountBoys =length.filter(==Boy )boys::Int->Event Family boys k f =countBoys f >=k nBoys::Int->Int->Int->Probability nBoys n k m =boys m ?? boys k ?=<< familyn numBoys::Int->Int->Dist IntnumBoys n k =Dist.map countBoys (boys k ?=<< familyn )-- * Special cases-- | only boys in a family that has one boyonlyBoys1::Int->Probability onlyBoys1 n =nBoys n 1n 

AltStyle によって変換されたページ (->オリジナル) /