Questions
I have the following assignment for probability class: I am supposed to write a routine (code)...

I have the following assignment for probability class:

I am supposed to write a routine (code) in MATLAB that does solve the following problem for me:

a) Generate N=10000 samples of a Uniform random variable (X) using the rand () command. This Uniform RV should have a range of -1 to +3.

b) Generate (Estimate) and plot the PDF of X from the samples.

You are not allowed to use the Histogram () command, any commands from the Matlab Statistics toolbox, or any routines from the companion textbook website!

c) Compute the expected value of X (average value) from the samples.

d) Generate (Estimate) and plot the CDF of X from the PDF in part b. e) Derive a new random variable Y using Y=X 2 f) Repeat steps b, c, d for the derived random Y.

Be sure to place appropriate axis labels and titles on your Matlab plots.

In: Statistics and Probability

There is a pair of functions in stdlib.h (make sure to include it) that are used...

There is a pair of functions in stdlib.h (make sure to include it) that are used for generating pseudo-random numbers. These are "srand" and "rand". Examples are on pages 686 and 687. E.g., function "srand(3)" provides the seed value of 3 to the srand function. (3 is just a number, and probably isn't even a good number for this purpose, but that's a discussion for another time). The reason that we use a seed value is so that we can reproduce the series of random numbers. Thus, we call them pseudo-random numbers. Being able to reproduce them is important to verify and debug code.

Write a C program to generate a set of random numbers for a given seed value (call it lab8_part1.c). Prompt the user for the seed value, or 0 to quit. Then print 5 random values. When you run your program, try a few different seed values, then try one that you've already tried. Verify that you get the same sequence.

In: Computer Science

1. Given below are a set of foreign exchange quotes for several currencies against the Australian...

1. Given below are a set of foreign exchange quotes for several currencies against the Australian dollar as of August 5, 2020.

Australian Dollar Exchange Rates

Currency Sell / buy
US, dollar 0.7143/0.7143
UK, pound   0.5458/0.5459
China, yuan Renminbi   4.9872/4.9907
Hong Kong, dollar 5.5349/5.5364
India, rupee   53.572/53.669
Japan, yen   75.70/75.70
Malaysia, ringgit 3.0104/3.0139
Philippines, peso   34.953/35.135
South Africa, rand   12.2272/12. 2340
Switzerland, franc 0.6551/0.6551
Thailand, baht 22.1892/22.2317

(c) Create a table showing the bid and ask quotes of each of the following currency pairs:

(i) GBP/CHF

(ii) PHP/THB

(iii) HKD/MYR

(iv) JPY/INR

(v) RMB/ZAR

Please, answer all parts (c) and step by step and in clear way

In: Finance

Write a program to simulate rolling a six-sided fair die. Allow the user to enter the...

Write a program to simulate rolling a six-sided fair die. Allow the user to enter the

number of rolls.

Your program should use rand() to get the result of die rolling.

Compute the number of occurrences for each number roll.

Calculate the percentage for each number roll.

Out put the results in the following format.

Use a do while loop to allow the user to repeat the process.

Here is the sample run for your program:

Please enter the number of die rolls

25

Number Frequency Percentage

1 3 0.12

2 6 0.24

3 10 0.40

4 1 0.04

5 3 0.12

6 2 0.08

Do you want to continue rolling die another time? Press Y or N

Y

Please enter the number of die rolls

10

I want to be able to do it with a switch statement but am unsure

In: Computer Science

Using Pass-by-Reference for Out Parameters Write a single function that counts the number of positive, negative...

Using Pass-by-Reference for Out Parameters Write a single function that counts the number of positive, negative and zero values in an integer array. Return the number of positive values, the number of negative values and the number of zero values. Use pass-by-reference to use parameters as “out parameter”: these are variables passed by reference into a function with the purpose of holding the result of the function after it terminates. Your function should have the following declaration: void countPosNegZero(int array[], int numElements, int &positive, int &negative, int &zero); where array is the array with the values, numElements is the number of elements in the array, positive will hold the number of positive values in the array, negative will hold the number of negative values in the array and zero will hold the number of zero values in the array. Add a test-main function that tests your program with several different arrays (use the rand() method to create arrays with random values ranging over negative and positive values).

c++

In: Computer Science

#include <stdio.h> #include <stdlib.h> #include <time.h> void sort(int a[], int size); void printArray(int a[], int size);...

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

void sort(int a[], int size);
void printArray(int a[], int size);

int main(){
        int arraySize, limit, count,

        srand(time(0)); 

        print f("Enter the size of array\n");
        scanf("%d", arraySize);

        int array[arraySize];

        printf("Enter the upper limit\n");
        scanf("%d", &limit);

        count = 0;
        while(count <= arraySize){
                array[count] = (rand() % (limit + 1));
                count++;
        }

        printArray(array, &arraySize);

        sort(array, arraySize);

        printArray(array, arraySize);

        Return 0;
}

void printArray(int a[], int size){
        int i = 0;
        printf("Array: [");
        while(i < size){
                if(i != size - 1){
                        printf("%d, ", a[i]);
                } else {
                        printf("%d]\n", a[i]);
                }
                printf("%d, ", a[i]);
        }
}

Find the bugs in the given code and write the correct line of code where the bug is. There are a total of 7 bugs.

In: Computer Science

**I need to make this program to make sure that the numbers are unique. In another...

**I need to make this program to make sure that the numbers are unique. In another word, if the number has been generated and appear early, it should continue to find the next number until the number is unique.

Hint: use the array to check whether the number has been generated.

#include <iostream>

#include <cstdlib>

#include <ctime>

using namespace std;

int main() {

srand(time(NULL));

int n, low, high;

cout << "Enter how many random numbers you would like to see: ";

cin >> n;

cout << "Enter the lower limit now: ";

cin >> low;

cout << "And now enter the higher limit: ";

cin >> high;

cout << n << " random numbers:";

for (int i = 0; i < n; ++i) {

cout << " " << low + (rand() % (high-low+1)) << endl;

}

cout << endl;

return 0;

}

Please show me how it can be done and explain code needed if possible. Thanks!

In: Computer Science

A bond has a face value of $1,000, coupon of 5% (the first payment is in...

A bond has a face value of $1,000, coupon of 5% (the first payment is in a year), and maturity in two tears. The bond’s price today is $963.84. What is the bond’s yield to maturity?

In: Finance

The price of natural gas varies from country to country. Suppose the country price is normally...

The price of natural gas varies from country to country. Suppose the country price is normally distributed with a mean of $5 per thousand cubic feet and standard deviation of $0.8.

(a) What is the first quartile of the price of natural gas? What is the 95th percentile of the price of natural gas? Show your work.

(b) We are analyzing a group of seven countries. What is the probability that the price of natural gas would exceed $5 in more than five of those countries? Show your work.

(c) Take two countries and assume that their prices of natural gas are independent. What is the probability that the price of gas is lower than $4 in at least one of them?

In: Statistics and Probability

The mean weight of an adult is 71 71 kilograms with a variance of 100 100...

The mean weight of an adult is 71
71
kilograms with a variance of 100
100
.

If 181
181
adults are randomly selected, what is the probability that the sample mean would differ from the population mean by greater than 1.2
1.2
kilograms? Round your answer to four decimal places.

In: Statistics and Probability