15 Independent Alleles
Problem
Two events AA and BB are independent if Pr(A and B)Pr(A and B) is equal to Pr(A)×Pr(B)Pr(A)×Pr(B). In other words, the events do not influence each other, so that we may simply calculate each of the individual probabilities separately and then multiply.
More generally, random variables XX and YY are independent if whenever AA and BB are respective events for XX and YY, AA and BB are independent (i.e., Pr(A and B)=Pr(A)×Pr(B)Pr(A and B)=Pr(A)×Pr(B)).
As an example of how helpful independence can be for calculating probabilities, let XX and YY represent the numbers showing on two six-sided dice. Intuitively, the number of pips showing on one die should not affect the number showing on the other die. If we want to find the probability that X+YX+Y is odd, then we don't need to draw a tree diagram and consider all possibilities. We simply first note that for X+YX+Y to be odd, either XX is even and YY is odd or XX is odd and YY is even. In terms of probability, Pr(X+Y is odd)=Pr(X is even and Y is odd)+Pr(X is odd and Y is even)Pr(X+Y is odd)=Pr(X is even and Y is odd)+Pr(X is odd and Y is even). Using independence, this becomes [Pr(X is even)×Pr(Y is odd)]+[Pr(X is odd)×Pr(Y is even)][Pr(X is even)×Pr(Y is odd)]+[Pr(X is odd)×Pr(Y is even)], or (12)2+(12)2=12(12)2+(12)2=12. You can verify this result in Figure 2, which shows all 36 outcomes for rolling two dice.
Given: Two positive integers kk (k≤7k≤7) and NN (N≤2kN≤2k). In this problem, we begin with Tom, who in the 0th generation has genotype Aa Bb. Tom has two children in the 1st generation, each of whom has two children, and so on. Each organism always mates with an organism having genotype Aa Bb.
Return: The probability that at least NN Aa Bb organisms will belong to the kk-th generation of Tom's family tree (don't count the Aa Bb mates at each level). Assume that Mendel's second law holds for the factors.
Sample Dataset
2 1
Sample Output
0.684 方法一:
import itertools
def f(k,n):
p = []
child_num = 2**k
for i in range(n):
p.append(len(list(itertools.combinations([x for x in range(child_num)],i)))*(0.25**i)*(0.75**(child_num-i)))
# combinations('ABCD', 2) AB AC AD BC BD CD
return 1-sum(p) print f(5,8)
15 Independent Alleles的更多相关文章
- 分享最新15个加速 Web 开发的框架和工具
我们为开发人员挑选了15个最新的 Web 开发框架,你肯定尝试一下这些新鲜的框架,有的可能略微复杂,有的提供了很多的配置选项,也有一些窗口小部件和界面交互的选择.他们将帮助你创建更优秀的网站,提供给 ...
- Andrew Ng机器学习公开课笔记–Independent Components Analysis
网易公开课,第15课 notes,11 参考, PCA本质是旋转找到新的基(basis),即坐标轴,并且新的基的维数大大降低 ICA也是找到新的基,但是目的是完全不一样的,而且ICA是不会降维的 对于 ...
- [转]15 个顶级 HTML5 游戏引擎
本文转自:http://www.open-open.com/news/view/13874db 1) HTML5 Game Engine Construct 2 is a leading high q ...
- 分享最新15个加速 Web 开发的框架和工具(梦想天空)
我们为开发人员挑选了15个最新的 Web 开发框架,你肯定尝试一下这些新鲜的框架,有的可能略微复杂,有的提供了很多的配置选项,也有一些窗口小部件和界面交互的选择.他们将帮助你创建更优秀的网站,提供给 ...
- 斯坦福ML公开课笔记15—隐含语义索引、神秘值分解、独立成分分析
斯坦福ML公开课笔记15 我们在上一篇笔记中讲到了PCA(主成分分析). PCA是一种直接的降维方法.通过求解特征值与特征向量,并选取特征值较大的一些特征向量来达到降维的效果. 本文继续PCA的话题, ...
- 基于Hama并联平台Finding a Maximal Independent Set 设计与实现算法
笔者:白松 NPU学生. 转载请注明出处:http://blog.csdn.net/xin_jmail/article/details/32101483. 本文參加了2014年CSDN博文大赛,假设您 ...
- [python] python django web 开发 —— 15分钟送到会用(只能送你到这了)
1.安装python环境 1.1 安装python包管理器: wget https://bootstrap.pypa.io/get-pip.py sudo python get-pip.py 1. ...
- 15个常用GCC命令
GCC编译器非常强大 ,在各个发行的Linux系统中都非常流行,本文介绍的是一些常用的gcc编译选项 下面这段代码将回围绕整个文章: 编辑main.c如下. #include<stdio.h&g ...
- android异常 More than one file was found with OS independent path 'META-INF/XXX'
android 异常总结:一个文件在jar包中出现多次. Error:Execution failed for task ':app:transformResourcesWithMergeJavaRe ...
随机推荐
- JavaScript异步编程__“回调地狱”的一些解决方案
异步编程在JavaScript中非常重要.过多的异步编程也带了回调嵌套的问题,本文会提供一些解决“回调地狱”的方法. setTimeout(function () { console.log('延时触 ...
- python轻量级ORM---peewee
版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/q454684431/article/details/31742367 peewee是一个轻量级的OR ...
- eclipse工程 'cocostudio/CocoStudio.h' file not found
android.mk里有这样配置: LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) $(call import-add-path,$(LOCAL_ ...
- spring下的多线程
链接 1,http://haidaoqi3630.iteye.com/blog/1920944 2,http://www.importnew.com/27440.html .............. ...
- HTML第三讲(选择符)
本次课程讲CSS中的选择符 1.基本选择符 基本选择符有三个 1.标记名选择符 所谓的标记名选择符就是直接在样式中使用标记名定义,譬如以下代码: (此种选择符的特点是所有相同的标记名可以同时定义不需要 ...
- Makefile之自动变量篇
自动变量假设您编写一个编译‘.c’文件生成‘.o’文件的规则:您怎样编写命令‘CC’,使它能够操作正确的文件名?您当然不能将文件名直接写进命令中,因为每次使用隐含规则操作的文件名都不一样. 您应该使用 ...
- pycharm修改代码模板支持中文输出
python2.x默认不支持中文输出,需要在py的开头添加 #coding: utf- 在pycharm里面,选项,editor,file and code templates,选择python sc ...
- [Android] 开发第九天
以下代码完全使用代码来控制 UI 界面,不被推荐使用. package com.oazzz.test2; import android.graphics.LinearGradient; import ...
- [原]Android 开发第一步
使用 android-studio 开发 写文章时的最新 Android-Studio 程序下载:https://dl.google.com/dl/android/studio/ide-zips/3. ...
- [转]iis 重新安装后 重新注册asp.net
iis 重新安装后 重新注册asp.net 服务器IIS问题: 卸载并重新安装了IIS.... 解决方法:原因是IIS重装后要重新安装一下.NET Framework. 开始-->运行--> ...