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

Create a program that uses two equations that will calculate the effect of varia

ID: 3581068 • Letter: C

Question

Create a program that uses two equations that will calculate the effect of variance on a mean(or average) random signal level using arrays and the random function in the following screenshots given using c programming.

In this problem you will calculate the effect of variance on a mean(or average) random signal level Random signal noise used in electronics theory falls into this category. You will first calculate the limits of variation (a and b below) based on the theoretical value of variance applied to a mean then compare it to random samples generated from a random number generator. The random number generator will use the calculated theoretical signal limits (of the variance on the mean) as the limits to the random generator outputs then up to 1000 random samples will be stored in an array The values stored in the a will be used to find the statistica variance by subtracting each value from the statistical mean and squaring it then summing the total number of results together and dividing by the total number of elements (stored in the array). The statistical mean is the summed average of all the elements in the array (the sum total of the array elements divided by the number of array elements). Theoretical Mean and Variance of a random sequence 2 (b-a a-+b Mean Variance 12 o find the effect of the variance on the mean the two equations above must be solved as two equations in two unknowns (for a and b in terms of Hand a) the results are given as: 12 2 Eq1. Eq2 (5pts optional credit Show algebraic steps to find Eq1 and Eq2 (attach sheet) Based the calculated a and b limits (from Eq1 & Eq2) load a random number sequence into an array rand() (b-a)/RAND MAX a (see pg 179 for floating point random numbers function) array(i)

Explanation / Answer

// C++ program for given problem statement.

#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <iomanip>
#include <math.h>
using namespace std;

int main()
{
   float mean,variance;
   int r=0;
   cout<<"Enter the mean > ";cin>>mean;cout<<" ";
   cout<<"Enter the variance > ";cin>>variance;cout<<" ";
   cout<<"Enter the value upto 1000 > ";
   cin>>r;
   cout<<" ";
   float a,b;
   a=((2*mean)-sqrt(12*variance))/2; //Calculating value of a by using given formula
   b=(2*mean)-a;    //Calculating value of b by using given formula
   float arr[r+1];
   float stat_mean=0;
   float stat_variance=0;
   for(int i=1;i<=r;i++)
   {
       arr[i]=((rand()*(b-a))/RAND_MAX)+a;      //Generating random number and storing in array
       stat_mean+=arr[i];   //summing all array values
   }
   stat_mean=stat_mean/r;    //dividing the total sum by r to calculate statistical mean
   for(int i=1;i<=r;i++)
   {

//Calculation for statistical variance
       arr[i]=stat_mean-arr[i];
       arr[i]=arr[i]*arr[i];
       stat_variance+=arr[i];

   }
   stat_variance=stat_variance/r;
   cout<<"Theoretical: Mean : "<<mean<<" Variance : "<<variance<<" ";
   cout<<"Statistical: Mean : "<<stat_mean<<" Variance : "<<stat_variance<<" ";
   return 0;
}

// Output :

laptop$ g++ mean_var.cpp
laptop$ ./a.out
Enter the mean > 4

Enter the variance > 2

Enter the value upto 1000 > 500

Theoretical: Mean : 4   Variance : 2
Statistical: Mean : 4.0304   Variance : 1.91749

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote