The Need for Averages

Averages arise everywhere. In sports, we want to project the average number of games that a team is expected to win; in gambling, we want to project the average losses incurred playing blackjack; in business, companies want to calculate their average expected sales for the next quarter.
Molecular biology is not immune from the need for averages. Researchers need to predict the expected number of antibiotic-resistant pathogenic bacteria in a future outbreak, estimate the predicted number of locations in the genome that will match a given motif, and study the distribution of alleles throughout an evolving population. In this problem, we will begin discussing the third issue; first, we need to have a better understanding of what it means to average a random process.

Problem

For a random variable X taking integer values between 1 and nn, the expected value of X is Calculating Expected Offspring - 图1. The expected value offers us a way of taking the long-term average of a random variable over a large number of trials.
As a motivating example, let XX be the number on a six-sided die. Over a large number of rolls, we should expect to obtain an average of 3.5 on the die (even though it’s not possible to roll a 3.5). The formula for expected value confirms that Calculating Expected Offspring - 图2.
More generally, a random variable for which every one of a number of equally spaced outcomes has the same probability is called a uniform random variable (in the die example, this “equal spacing” is equal to 1). We can generalize our die example to find that if XX is a uniform random variable with minimum possible value aa and maximum possible value bb, then Calculating Expected Offspring - 图3. You may also wish to verify that for the dice example, if Y is the random variable associated with the outcome of a second die roll, then Calculating Expected Offspring - 图4.
Given: Six nonnegative integers, each of which does not exceed 20,000. The integers correspond to the number of couples in a population possessing each genotype pairing for a given factor. In order, the six given integers represent the number of couples having the following genotypes:

  1. AA-AA
  2. AA-Aa
  3. AA-aa
  4. Aa-Aa
  5. Aa-aa
  6. aa-aa

Return: The expected number of offspring displaying the dominant phenotype in the next generation, under the assumption that every couple has exactly two offspring.

Sample Dataset

  1. 1 0 0 1 0 1

Sample Output

  1. 3.5

Solution

其实本题是一个概率问题,主要是让求数学期望值,因为每对夫妇可以生两个孩子,因此期望要乘上 2 ,最后求的是所有夫妇子代显性个体的期望。
Calculating Expected Offspring - 图5

  1. AA2AA, AA2Aa, AA2aa, Aa2Aa, Aa2aa, aa2aa = map(int, input())
  2. print(AA2AA * 2 + AA2Aa * 2 + AA2aa * 2 + Aa2Aa * 3 / 2 + Aa2aa)