Beta

Cousin marriage: path analysis

Description
Loading description...
Graph Theory
Trees
Recursion
  • Please sign in or sign up to leave a comment.
  • dfhwze Avatar

    Great kata authoring work once again. I can't imagine the time you must have spent on this kata.

    • jpssj Avatar

      Thanks for beta testing it again! (Almost a week.)

    • dfhwze Avatar

      Almost a week, damn! I wonder whether I should have a go at a JS translation. (I also wonder why other solutions remain out on the other kata. I hope it gets approved soon.)

  • dfhwze Avatar

    You may want to change the terms you use.

    • ancestor: self or any ancestor of parents
    • predecessor: parents and any predecessors of parents

    This way, you can also remove the "this is not correct" part of the common ancestor in case one is a predecessor of the other, since an ancestor can include self

    • jpssj Avatar

      I changed the first sentence of the rules to An ancestor of a person is either themself or any direct ascendant of that person. I also removed the sentence about the common ancestor when going down from an ancestor to some of their descendant.

      When I was doing my research, I found that there are other things to take account of when computing the coancestry of two persons for some specific cases (for example when they are ancestor-descendant in one way and cousins in another way). The note is there to inform the user that the formula is not exact for some cases. Maybe I should rephrase it.

    • dfhwze Avatar
      • someone can be both your mother and sister, is your formula able to handle this?
      • can two people have more than 1 common ancestor? for instance, a brother and sister share 2 common ancestors
    • jpssj Avatar
      • no : if I made the things right, the tests only generate family trees with cousin marriage between persons from the same generation
      • that's what I wanted to underline with : in this kata: a person has either both a mother and a father, or neither a father nor a mother
    • dfhwze Avatar
      Suggestion marked resolved by dfhwze 6 months ago
    • jpssj Avatar

      I accommodated the tests to the new definition: there's now one path between someone and themself.

    • dfhwze Avatar

      Why did you mention "on the path p" here? Is the path a parameter on the coefficient of inbreeding?

      Fp is the coefficient of inbreeding of the the common ancestor of a and b on the path p

    • jpssj Avatar

      No, but each path can have a different common ancestor. I see your point, I will think of way to make it clearer.

      Edit: I changed the formula to

      pP12L(p)(1+Fcp)\displaystyle\sum_{\substack{p \in P}} \frac{1}{2^{L(p)}} (1 + F_{c_p})

      Where cpc_p is the common ancestor of a and b on the path p.

    • dfhwze Avatar

      ok next thing that is unclear: sometimes your paths (in expected feedback) are from source to destination, and sometimes the other way around, why is this?

      Inbreeding coefficient for 13: 1/64.
      Coancestry coefficient between 11 and 12: 1/64.
      Paths:
      11 m → 7 m → 3 m → 1 m → 5 m → 9 f → 12 f
      12 f → 9 f → 5 m → 2 f → 3 m → 7 m → 11 m
      

      make sure to sort your paths from src to dest, not by some default python sort

    • jpssj Avatar

      I was, exactly five seconds ago, going to add a note about that. The direction of a path is not important. The path 1 → 2 → 3 is the same than the path 3 → 2 → 1. That's why I chose to show paths in different directions in the sample tests.

    • dfhwze Avatar

      Ok I pass the kata now, except for a timeout. Are there considerable performance constraints? I mean, is caching required or something?

    • jpssj Avatar

      I don't think so. I usually pass the tests between 4 to 6 seconds. Sometimes, rarely, it takes 8 or 9 seconds. If you think that the tests are too unbalanced, I can shrink some of them.

    • dfhwze Avatar

      nah, I'm probably using a horrible CA finder algorithm. EDIT: indeed, my algorithm was ***

    • dfhwze Avatar

      Not sure this is in the descripton already in some form, but I would add a note:

      • a person can have children with at most 1 spouse
    • jpssj Avatar

      That wasn't present. I added a subsection about the family at the beginning of the rules where I put that information.

    • dfhwze Avatar

      I was thinking about a new kata in the series, families on Mars, where each person has 2 fathers and a mother. Calculate the coefficients ... :)

    • jpssj Avatar

      Let's go to Mars! ^^