문제해결(PS)/ROSALIND

Calculating Expected Offspring ( 기대 자식 계산하기)

곰탱이장 2024. 7. 28. 16:50

https://rosalind.info/problems/iev/

 

ROSALIND | Calculating Expected Offspring

It appears that your browser has JavaScript disabled. Rosalind requires your browser to be JavaScript enabled. Calculating Expected Offspring solved by 11701 2012년 12월 4일 7:02:57 오전 by Rosalind Team Topics: Heredity, Probability The Need for Aver

rosalind.info

Problem

For a random variable X𝑋 taking integer values between 1 and n𝑛, the expected value of X𝑋 is E(X)=nk=1k×Pr(X=k)E(𝑋)=∑𝑘=1𝑛𝑘×Pr(𝑋=𝑘). 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 X𝑋 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 E(X)=6k=1k×Pr(X=k)=3.5E(𝑋)=∑𝑘=16𝑘×Pr(𝑋=𝑘)=3.5.

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 X𝑋 is a uniform random variable with minimum possible value a𝑎 and maximum possible value b𝑏, then E(X)=a+b2E(𝑋)=𝑎+𝑏2. 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 E(X+Y)=7E(𝑋+𝑌)=7.

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 0 0 1 0 1

Sample Output

3.5

 

 이 문제는 각 커플이 2마리씩 낳을때 다음 세대에 태어날 우성형의 자식의 기댓값을 구하는 문제이다. 1~3 교배는 100%, 4번은 75%, 5번은 50%, 6번은 0%로 우성형의 자식이 나온다는 것을 안다면 그냥 단순한 산수문제로 풀 수 있다

geno = list(map(int,input().split()))
D=2*sum(geno[0:3])+geno[3]*3/2+geno[4]
print(D)