//====================================================== file = burst.c ===== //= A simulation of burst errors in a bit stream = //= - Correlation of bit errors is included in this model = //=========================================================================== //= Notes: = //= 1) #define NUM_BITS tunes the execution time and #define MAX_BURST = //= determines maximum burst size to be counted. = //= 4) The "factor" input allows for modeling of correlation. Given = //= a bit error, the next bit has factor * p probability of being = //= in error. = //=-------------------------------------------------------------------------= //= Example execution: = //= = //= Enter probability of a bit error ===================> 0.08 = //= Enter correlation factor (1.0 for independent) =====> 1.00 = //= ---------------------------------------------- burst.c ----- = //= - Results for 10000000 bits... = //= - Pr[a given bit is good] = 0.9200142 = //= - Pr[a given bit is bad] = 0.0799858 = //= - Total number of bursts = 735790 = //= ------------------------------------------------------------ = //= - Pr[a given bit is in a burst of size = 1] = 0.0676811 = //= - Pr[a given bit is in a burst of size = 2] = 0.0054306 = //= - Pr[a given bit is in a burst of size = 3] = 0.0004288 = //= - Pr[a given bit is in a burst of size = 4] = 0.0000360 = //= - Pr[a given bit is in a burst of size = 5] = 0.0000020 = //= ------------------------------------------------------------ = //= - Pr[a given burst is of size = 1] = 0.9198426 = //= - Pr[a given burst is of size = 2] = 0.0738064 = //= - Pr[a given burst is of size = 3] = 0.0058277 = //= - Pr[a given burst is of size = 4] = 0.0004893 = //= - Pr[a given burst is of size = 5] = 0.0000272 = //= ------------------------------------------------------------ = //=-------------------------------------------------------------------------= //= Build: bcc32 burst.c = //=-------------------------------------------------------------------------= //= Execute: burst = //=-------------------------------------------------------------------------= //= Author: Kenneth J. Christensen = //= University of South Florida = //= WWW: http://www.csee.usf.edu/~christen = //= Email: christen@csee.usf.edu = //=-------------------------------------------------------------------------= //= History: KJC (08/17/02) - Genesis (from parity.c) = //=========================================================================== //----- Include files ------------------------------------------------------- #include // Needed for printf() #include // Needed for rand(), RAND_MAX, and ato*() //----- Defines ------------------------------------------------------------- #define TRUE 1 // Boolean true #define FALSE 0 // Boolean false #define NUM_BITS 10000000 // Number of bits to simulate #define MAX_BURST 5 // Maximum burst size to count //===== Main program ======================================================== void main(void) { double p; // Probability of bit error double factor; // Factor affecting subsequent bit int burst[4096]; // Burst count vector int burst_size; // Burst size for this burst int total_bursts; // Total number of bursts int burst_flag; // Within a burst flag double z; // Uniform RV between 0.0 and 1.0 char temp_string[80]; // Temporary string int i, j; // Loop counters // Prompt for probability of a bit error (p) printf("Enter probability of a bit error ===================> "); scanf("%s", temp_string); p = atof(temp_string); // Prompt for correlation "factor" (factor) printf("Enter correlation factor (1.0 for independent) =====> "); scanf("%s", temp_string); factor = atof(temp_string); // Clear the burst count vector for (i=0; i<=MAX_BURST; i++) burst[i] = 0; // Simulate for NUM_BITS burst_size = total_bursts = 0; burst_flag = FALSE; for (i=0; i