473,385 Members | 1,562 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Coefficient inbreeding algorithm

Hi,

I am making a little program which calculates Wright's inbreeding
coefficient.
What I have a trouble with is converting the formula into a code.

The formula is:
Fx=?[(0,5) n + nŽ + 1 * (1 + FA)]

As I'm using plain text it might not appear correctly. The formula is also
presented here:
http://members.aol.com/malndobe/inbreed.htm

If you can help me, please post.

BR, Pasi
Jul 22 '05 #1
2 3155
Pasi Havia wrote:
Hi,

I am making a little program which calculates Wright's inbreeding
coefficient.
What I have a trouble with is converting the formula into a code.

The formula is:
Fx=?[(0,5) n + nŽ + 1 * (1 + FA)]


So which part are you having problems with?

double ComputeCoeeficient(int n1, int n2) {
return pow(0.5, n1+n2-1);
}

This is if you are using the author's notation for the generations.
(which is off by one for the sire and dame lines, so it ends up being
-1 rather than +1).

Hence for Rover in the example:
return ComputeCoefficeint(2,2); // Fido's coefficient

for Ralph
return ComputeCoefficient(2,1) + // Cindra's coefficient
ComputeCoefficient(3,2); // Eric's coefficent.

If the dogs in the computation were themselves inbred, then you
mutiply the ComputeCoefficeint above by thier coefficients (+1.)
Jul 22 '05 #2
> Pasi Havia wrote:
Hi,

I am making a little program which calculates Wright's inbreeding
coefficient.
What I have a trouble with is converting the formula into a code.

The formula is:
Fx=?[(0,5) n + nŽ + 1 * (1 + FA)]


So which part are you having problems with?

double ComputeCoeeficient(int n1, int n2) {
return pow(0.5, n1+n2-1);
}

This is if you are using the author's notation for the generations.
(which is off by one for the sire and dame lines, so it ends up being
-1 rather than +1).

The formula is:
Fx=?[(0,5) n + nŽ + 1 * (1 + FA)]


So which part are you having problems with?

double ComputeCoeeficient(int n1, int n2) {
return pow(0.5, n1+n2-1);
}

This is if you are using the author's notation for the generations.
(which is off by one for the sire and dame lines, so it ends up being
-1 rather than +1).


No youŽre not right. If some of the sibling have same mother/father then
this calculation won't do. Note that the FA is calculated the same way as Fx
which will lead into recursion.

I already got two alternative options to implement this but I'm having
problems with both of them.

Option #1
Pedigree is in tree structure.

function inbreed(dog k)
inbreed = 0
(mother's_grandparent_, n1) = first_grandparent(k.mother)
(father's_grandparent, n2) = first_grandparent(k.father)
do while mother's_grandparent == null
(mother's_grandparent, n1) = next_grandparent(k.mother,
mother's_grandparent)
do while father's_grandparent == null
(father's_grandparent, n2) = next_grandparent(k.father,
father's_grandparent)
if mother's_grandparent == father's_grandparent
inbreed += (0,5^(n1 + n2 + 1)) * (1 +
inbreed(mother's_grandparent))
Option #2
Using recursion to solve the formula.

function calculate_inbreed(dog)
return inbreed1(dog.mother, 0, dog.father, 0)

function inbreed1(dog1, n1, dog2, n2)
inbreed = inbreed2(dog1, n1, dog2, n2)
if dog1.mother
inbreed += inbreed1(dog1.mother, n1+1, dog2, n2)
if dog1.father
inbreed += inbreed1(dog1.father, n1+1, dog2, n2)
return inbreed

function inbreed2(dog1, n1, dog2, n2)
inbreed = 0
if dog1 == dog2
inbreed += (0,5^(n1 + n2 + 1)) * (1 + inbreed(dog1))
if dog2.mother
inbreed += inbreed_father(dog1, n1, dog2.mother, n2+1)
if dog2.father
inbreed += inbreed_father(dog1, n1, dog2.father, n2+1)
return inbreed

In the option #2 I don't know what calculation I should perform in
inbreed_father method. So the problem goes a little more deep than you first
expected I think ;)

-Pasi
Jul 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Matthew | last post by:
Hello, For a few days now, I have tried a number of methods that are supposed to provide the a(k) and b(k) coefficients for a Fourier series. These methods are listed at the end of this post (in...
6
by: Jack Smith | last post by:
Hello, any help appreciated with following problem. I figured out the algorithm (I think), just having trouble proving it is optimal. Suppose we are given n tasks each of which takes 1 unit...
10
by: bpontius | last post by:
The GES Algorithm A Surprisingly Simple Algorithm for Parallel Pattern Matching "Partially because the best algorithms presented in the literature are difficult to understand and to implement,...
113
by: Bonj | last post by:
I was in need of an encryption algorithm to the following requirements: 1) Must be capable of encrypting strings to a byte array, and decyrpting back again to the same string 2) Must have the same...
2
by: Julio C. Hernandez Castro | last post by:
Dear all, We have just developped a new block cipher called Raiden, following a Feistel Network structure by means of genetic programming. Our intention now consists on getting as much feedback...
7
by: Nena | last post by:
Hi there, I'm trying to include the Numerical Recipes for C++ for the Dev-C++ Editor Version. But so far I've failed. Therefore I've copied all head-files (for example nr.h) into the folder...
18
by: robert | last post by:
Is there a ready made function in numpy/scipy to compute the correlation y=mx+o of an X and Y fast: m, m-err, o, o-err, r-coef,r-coef-err ? Or a formula to to compute the 3 error ranges? ...
9
by: mail | last post by:
Hi I'm very sorry for maybe posting something which was already posted. --How can I compute the binomial coefficient in C++? <-- Is it possible that there is no existing library for that out...
7
by: siddharthkumarr | last post by:
hello everybody...i m a newbie and struggling with a small assignment which involves 1- creating a dynamic array for floating point numbers 2- comparing adjacent numbers and finding the CORRELATION...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.