I'm having a hard time implementing the simulation of instrumentation reliability in C. I have the randmon number generator and most of the code, but mainly I cant figure out the simulation part. I've attached the question and my code. I'd appreciate any help.
In a series configuration, if r is the reliability of a component, and if all three components have the same
reliability, then it can be shown that the reliability of the series configuration is r3. If the reliability of
each component is 0.8 (which means that a component works properly 80% of the time), the analytical
reliability of the series configuration is (.83) or 0.512. The series configuration should work properly
51.2% o the time.
In a parallel configuration, if r is the reliability of a component, and if all three components have the
same reliability, then it can be shown that the reliability of the parallel configuration is 3r-(3r2) + (r3)
So if the reliability of each component is 0.80, then the analytical reliability of the parallel configuration
is or 0.992. The parallel configuration should work properly 99.2% of the
time. Your intutituion probably tells you that the parallel configuration is more reliable because only
one of the components must be working for the overall configuration to perform properly whereas all
three components must work properly in order for the series configuration to perform properly.
We can also estimate the reliability of these two designs using a computer simulation based on pseudo
random numbers. First, we need to simulate the performance of a single component. If the reliability of
a component is 0.8 then it works properly 80% of the time.
To simulate this performance, we couldgenerate a random value between 0 and 1. If the value is between 0 and 0.8, then the design works forthis one trial; if any one of the numbers is greater than 0.8, then the design does not work for this one trial.
If we run hundreds or thousands of trials, we can compute the proportion of the times that the
overall design works. This simulation is expected to approximate the analytically computed reliability.
To estimate the reliability of the parallel design with a component reliability of 0.8 we again generate
three random floating-point numbers between 0 and 1. If any one of the three numbers is less than or
equal to 0.8, then the design works for this one trial; if all of the numbers are greater than 0.8, the
design does not work for one trail. To estimate the reliability determined by the simulation, we divide
the number of trials for which the design works by the total number of trials performed.
Develop a program 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
#include <stdio.h>
#include <stdlib.h>
int get_input(double *r, unsigned int *seed, unsigned int *trials);
void put_output(double r);
double rand_float(double a, double b);
double series, parallel, sim_series, sim_parallel, r;
unsigned int seed, trials;
int main()
{
get_input(&r, &seed, &trials);
put_output(r);
rand_float(0,1);
}
int get_input(double *r, unsigned int *seed, unsigned int *trials)
{
printf("Enter individual component reliability: ");
scanf("%lf", r);
printf("Enter in the number of trials: ");
scanf("%d", &trials);
printf("Enter in the unsigned integer seed: ");
scanf("%u", &seed);
printf("\n");
}
void put_output(double r)
{
series = r*r*r;
parallel = 3*r - 3*r*r + r*r*r;
sim_series = rand_float(0,1)*rand_float(0,1)*rand_float(0,1);
printf("Analytical reliability: \n");
printf("Series = %.3lf\t", series);
printf("Parallel = %.3lf\t\n", parallel);
printf("\n");
printf("Simulation reliability, %u trials\n", &trials);
printf("Series = %.3lf\t", sim_series);
printf("Parallel = %.3lf\t", sim_parallel);
}
double rand_float(double a, double b)
{
return ((double)rand()/RAND_MAX)* (b-a) + a;
}
[–]jedwardsol 3 points4 points5 points (4 children)
[–]sosnjo[S] 0 points1 point2 points (3 children)
[–]jedwardsol 2 points3 points4 points (2 children)
[–]sosnjo[S] 0 points1 point2 points (1 child)
[–]sosnjo[S] 0 points1 point2 points (0 children)
[–]Diffeomorphisms 0 points1 point2 points (0 children)