473,698 Members | 2,313 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3191
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 ComputeCoeefici ent(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 ComputeCoeffice int(2,2); // Fido's coefficient

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

If the dogs in the computation were themselves inbred, then you
mutiply the ComputeCoeffice int 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 ComputeCoeefici ent(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 ComputeCoeefici ent(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_grand parent_, n1) = first_grandpare nt(k.mother)
(father's_grand parent, n2) = first_grandpare nt(k.father)
do while mother's_grandp arent == null
(mother's_grand parent, n1) = next_grandparen t(k.mother,
mother's_grandp arent)
do while father's_grandp arent == null
(father's_grand parent, n2) = next_grandparen t(k.father,
father's_grandp arent)
if mother's_grandp arent == father's_grandp arent
inbreed += (0,5^(n1 + n2 + 1)) * (1 +
inbreed(mother' s_grandparent))
Option #2
Using recursion to solve the formula.

function calculate_inbre ed(dog)
return inbreed1(dog.mo ther, 0, dog.father, 0)

function inbreed1(dog1, n1, dog2, n2)
inbreed = inbreed2(dog1, n1, dog2, n2)
if dog1.mother
inbreed += inbreed1(dog1.m other, n1+1, dog2, n2)
if dog1.father
inbreed += inbreed1(dog1.f ather, 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
2838
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 Java). However, not one of these methods seems to provide the correct coefficients for the following function; f(x) = 2 - 2 * cos(x)
6
8886
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 time to complete. Suppose further that each task has a deadline by which it is expected to finish. IF a task is not finished by the deadline, a standard penalty of $10 is applied. The problem is to find a schedule of the tasks that minimizes the...
10
4972
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, knowledge of fast and practical algorithms is not commonplace." Hume and Sunday, "Fast String Searching", Software - Practice and Experience, Vol. 21 # 11, pp 1221-48
113
12308
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 algorithm work with strings that may or may not be unicode 3) Number of bytes back must either be <= number of _TCHARs in * sizeof(_TCHAR), or the relation between output size and input size can be calculated simply. Has to take into account the...
2
7287
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 as possible from users, so we encourage you to test the algorithm and send us your opinion. We would also like to receive enhancements and new versions of the algorithm, developed in other source languages and platforms. Our idea on developing...
7
3181
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 where my program is. When compiling my program two windows are poping up. The first one is saying "Total errors 0" and "Size of
18
22392
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? -robert PS: numpy.corrcoef computes only the bare coeff:
9
10024
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 there (expect something that big like the gnu scientific library)? I searched the groups but couldn't find some good answers to this
7
1729
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 COEFFICIENT.... can u tell me what functions to use so dat i can start of with?? i wud b rlyyyy grateful...thanxxx
0
8676
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9161
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8897
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7732
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6522
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4370
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2332
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.