Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Develop a program in C to compare the analytical reliabilities of the series and

ID: 3679386 • Letter: D

Question

Develop a program in C to compare the analytical reliabilities of the series and parallel configurations with simulation results. Allow the user to enter the individual component reliability and the number of trials to use in the simulation. Generate a random number (event) for each component in the simulation; this is a total of 3 random numbers. Use these 3 for the simulation series test and same 3 for simulation parallel test. This will make the simulations an apples-to-apples comparison when evaluating results. The input/output formats for your program should look like this:

Enter individual component reliability: 0.8

Enter in the number of trials: 3

Enter in the unsigned integer seed: 47

Analytical reliability:

Series: 0.512 Parallel: 0.992

Simulation reliability, 3 trials

Series: 0.667 Parallel: 1.000

Additional example of program execution using other test data:

Enter individual component reliability: 0.8

Enter in the number of trials: 100

Enter in the unsigned integer seed: 123

Analytical reliability:

Series: 0.512 Parallel: 0.992

Simulation reliability, 100 trials

Series: 0.470 Parallel: 1.000

Additional example of program execution using other test data:

Enter individual component reliability: 0.8

Enter in the number of trials: 1000

Enter in the unsigned integer seed: 3535

Analytical reliability:

Series: 0.512 Parallel: 0.992

Simulation reliability, 1000 trials

Series: 0.530 Parallel: 0.990

Explanation / Answer

/***** C program  to compare the analytical reliabilities of the series and parallel configurations*******/

#include <stdio.h>
#include <math.h>
#include <stdlib.h>

double rand_float(double a, double b);

int main()
{
   srand ((unsigned)time(NULL));  
   unsigned int seed;
   int n;
   double component_reliability, a_series, a_parallel;
   double series_success =0, parallel_success =0;
   double num1, num2, num3;

   printf("Enter individual component reliability: ");
   scanf("%lf",&component_reliability);

   printf("Enter number of Trials: ");
   scanf("%d",&n);

   printf("Enter unsigned integer seed: ");
   scanf("%u",&seed);

   printf(" ");

   a_series = pow(component_reliability,3);
   a_parallel = 3*component_reliability - 3*pow(component_reliability,2)+pow(component_reliability,3);

   int i;
   for ( i = 0; i < n; ++i)
   {
       num1 = rand_float(0,1);
       num2 = rand_float(0,1);
       num3 = rand_float(0,1);

       if((num1 <= component_reliability) && (num2 <= component_reliability) && (num3 <= component_reliability))
           series_success++;

       if((num1 <= component_reliability) || (num2 <= component_reliability) || (num3 <= component_reliability))
           parallel_success++;          
   }

   printf("Analatical Reliability ");
   printf("Series: %.3lf Parallel: %.3lf ",a_series,a_parallel );
   printf("Simulation Reliability, %d Trials ",n );
   printf("Series: %.3lf Parallel: %.3lf ", series_success/n ,parallel_success/n );

   return 0;

}

double rand_float(double a, double b)
{

   return (rand()/RAND_MAX)*(b-a)+a;
}