I need help with this question Let Ui represent a random var
I need help with this question
Let U_i represent a random variable uniformly distributed on (0, 1), i.e. what the computer you when you execute \"rand().\" (a) What distribution do you get for U_1 + u_2? Can you describe it analytically? (b) What distribution do you get for max(U_1, u_2)? Can you describe it analytically? (c) What distribution do you get for min (U_1, u_2)? Can you describe it analytically? (c) What distribution do you get for max(u_1, u_2, u_3)? Can you describe it analytically?Solution
Dear Student,
When we execute rand function it gives us a random number, rand() will return an integer from 0 to 32767 depending on implementation.The generation of random number can also be controlled.If we want to execute a random number between 1 to 10 then following program demonstrate this...
program...
#include<stdio.h>
int main()
{
int random=rand()%10+1;
printf(\"%d\ \",random);
return 0;
}
Output: 4
Every time when you compile and the run the the program you will get different number.
In the above question ui is in the range of (0,1)....so....
Answer No..1
for u1+u2 the following program demonstrate this...i created two random number that is stored on u1 and u2 varibale.and the sum of the number is stored on u variabel.The output that we get is the addition of two random number.
#include<stdio.h>
int main()
{
int u1=rand()%1+1;
int u2=rand()%1+1;
int u=u1+u2;
printf(\"%d\ \",u);
return 0;
}
Output: 2
Answer No-2 Finding max of two numbers.In the below program we are finding max of two random number.
program
#include<stdio.h>
int main()
{
int u1=rand()%1;
int u2=rand()%1+1;
int u=min(u1, u2);
printf(\"%d\",u);
}
int min(int min, int max)
{
if(min>max)
return min;
else
return max;
}
output=1
Answer-3-Finding min of two numbers.In the below program we are finding min of two random number.
#include<stdio.h>
int main()
{
int u1=rand()%1;
int u2=rand()%1+1;
int u=min(u1, u2);
printf(\"%d\",u);
}
int min(int min, int max)
{
if(min<max)
return min;
else
return max;
}
Answer-4-for max(v1,v2,v3)
program==
#include<stdio.h>
int main()
{
int u1=rand()%1;
int u2=rand()%1;
int u3=rand()%1+1;
int u=max(u1, u2, u3);
printf(\"%d\",u);
}
int max(int a, int b, int c)
{
if(a>b && a>c)
return a;
else if(b>a && b>c)
return b;
else
return c;
}
output=1
all the example are tested in the range of (0,1) as assume in the question paper.

