home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_08_03
/
8n03074a
< prev
next >
Wrap
Text File
|
1990-03-20
|
1KB
|
52 lines
*****Listing 2*****
--------------------------------------------------------------
/*
*
* This is the function that implements Demptser's rule
* of combination.
* vector1 & vector2 are belief vectors. vector2 will hold
* the result of the combination.
*
*/
combine_using_dempsters_rule(vector1, vector2)
float vector1[LENGTH_OF_BELIEF_VECTOR],
vector2[LENGTH_OF_BELIEF_VECTOR];
{
float denominator, sum_vector[LENGTH_OF_BELIEF_VECTOR];
int a, i, place;
/* set the sums to zero */
for(i=0; i<LENGTH_OF_BELIEF_VECTOR; i++)
sum_vector[i] = 0.0;
/* Now go through the intersection tableau.
* Look for the intersection of non-zero beliefs
* and save their products. */
for(a=1; a<LENGTH_OF_BELIEF_VECTOR; a++){
if(vector2[a] > 0.0){
for(i=0; i<LENGTH_OF_BELIEF_VECTOR; i++){
place = i & a;
if(vector1[i] > 0.0)
sum_vector[place] = (vector1[i] * vector2[a]) + sum_vector[place];
} /* ends loop over i */
} /* ends if vector2[a] > 0.0 */
} /* ends loop over a */
denominator = 1.0 - sum_vector[0];
for(i=1; i<LENGTH_OF_BELIEF_VECTOR; i++)
vector1[i] = sum_vector[i]/denominator;
} /* ends combine_using_dempsters_rule */
Figure 8 - C Code to Implement Dempster's Rule of Combination
----------------------------------------------------------------