Question

create vba procedure which prompts the user for the size of the data s/he is interested...

create vba procedure which prompts the user for the size of the data s/he is interested in generating. prompt the user for a mean and standard deviation for the normal distribution; store these in variables. prompt the user for a lambda value for the exponential distribution; store this in a variable. prompt the user for a lower and upper bound value for the uniform distribution; store these in variables. then call the following three functions: a. normal function: (pass size, mean, stdev) generate a column of random values from the normal distribution. b. exponential function: (pass size, lambda) generate another column of random values from the exponential distribution. c. uniform distribution:(pass size, lower and upper bound) generate another column of random values from the uniform distribution.

do this in vba please

0 0
Add a comment Improve this question Transcribed image text
Answer #1

VBA Code:

Sub statfuntions()
'variable declarations
Dim size As Integer
Dim mean As Double
Dim SD As Double
Dim Lambda As Double
Dim LoBound As Double
Dim UpBound As Double
Dim Out As Boolean
  
'getting input from the user
size = InputBox("Enter the size of data to be generated")
mean = InputBox("Enter the Mean of a Normal Distrubution")
SD = InputBox("Enter the SD of a Normal Distrubution")
Lambda = InputBox("Enter the Lamda of a Exponential Distrubution")
LoBound = InputBox("Enter the lower bound of a Uniform Distrubution")
UpBound = InputBox("Enter the upper bound of a Uniform Distrubution")
'calling functions to generate values
Out = normal(size, mean, SD)
Out = exp(size, Lambda)
Out = uniform(size, LoBound, UpBound)
End Sub
Function normal(size, mean, stdev)
For i = 1 To size
'generate normal function values in column A
Cells(i, 1) = WorksheetFunction.Norm_Dist(Rnd(), mean, stdev, False)
Next i
normal = True
End Function
Function exp(size, Lambda)
For i = 1 To size
'generate exponential function values in column B
Cells(i, 2) = WorksheetFunction.Expon_Dist(Rnd(), Lambda, False)
Next i
exp = True
End Function
Function uniform(size, lb, ub)
For i = 1 To size
'generate uniform function values in column C
Cells(i, 3) = Rnd() * (ub - lb + 1) + lb
Next i
uniform = True
End Function

Sample Output:

Entered values:

size = 10
mean = .5
SD = .2
Lambda = .5
LoBound = 1
UpBound = 10

Output:

1.605681972 0.316248 3.438452
1.627171553 0.403218 10.79078
1.871084548 0.356251 1.609162
0.264526537 0.388923 4.902915
1.90394053 0.386735 4.649954
1.243204969 0.396675 5.898947
0.234798297 0.419 2.556631
0.491259712 0.408377 5.744592
0.115551771 0.436917 3.572677
1.948378754 0.486293 7.287519
Add a comment
Know the answer?
Add Answer to:
create vba procedure which prompts the user for the size of the data s/he is interested...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • please help Create a program that prompts the user for a sentence and then displays the...

    please help Create a program that prompts the user for a sentence and then displays the hash of the sentence. Refer to the textbook Chapter 5.2 and the Support Video in zyBook section 3.1 for more instruction on hashing. Program Requirements: The program should prompt the user for the "sentence" to be hashed and then compute the hash of the sentence by summing the numeric value of each letter in the sentence (use A=a=1, B=b=2 ... Z=z=26, space=31) and applying...

  • The value of the R function "mean" applied to a vector $\mathbf{v}=(v_1,v_2,...v_n)$ is the arithmentic mean...

    The value of the R function "mean" applied to a vector $\mathbf{v}=(v_1,v_2,...v_n)$ is the arithmentic mean of the vector: $\bar{v}=\frac{1}{n} \sum_{i=1}^nv_i$. The value of the R function "var" applied to the vector $\mathbf{v}$ equals $\frac{1}{n-1} \sum_{i=1}^n(v_i-\bar{v})^2$, a measure of how much the values differ from the mean. For $\lambda\in\{4,25,100\}$, create samples of size 100,000 from the Poisson distribution with parameter $\Lambda$ and the Normal distribution with mean equal to $\lambda$ and sd equal to $\sqrt{\Lambda}$. Please compare the values of...

  • 1. There are times when a shifted exponential model is appropriate. That is, let the pdf of X be ...

    1. There are times when a shifted exponential model is appropriate. That is, let the pdf of X be (a) Find the cdf of X. (b) Find the mean and variance of X. 2. Suppose X is a Gamma random variable with pdf 「(a)go Show that the moment generating function is M(t) 3, Let X equal the nurnber out of n 48 mature aster seeds that will germinate when p- 0.75 is the probability that a particular seed germinates. Approximate...

  • Python 3.7 please help please use central limit theory In this problem you will verify the...

    Python 3.7 please help please use central limit theory In this problem you will verify the Central Limit Theorem (CLT) which states that averages, from repeated random samples of any distribution, follow a normal distribution 1. (5 points) Draw a random sample of 5,000 random numbers from a uniform distribution X ~U (20,80] and store them into a vector called xy and plot a histogram of these 5,000 numbers 2. (5 points) Draw a random sample of 5,000 random numbers...

  • ​Declare an array with 1000 elements of type int Then in a loop generate 1000 random numbers and assign one to each element in the array The random numbers should be between 1 and 50 Then, prompt the user to enter a number, store this number in a local

    Rules to follow are:Declare an array with 1000 elements of type intThen in a loop generate 1000 random numbers and assign one to each element in the arrayThe random numbers should be between 1 and 50do not use rand or srand, use code is providedThen, prompt the user to enter a number, store this number in a local variable, the number should be safety checked using the GetInteger() functionThen, iterate through the array and determine how many times the user's...

  • R studio #Exercise : Calculate the following probabilities : #1. Probability that a normal random variable...

    R studio #Exercise : Calculate the following probabilities : #1. Probability that a normal random variable with mean 22 and variance 25 #(i)lies between 16.2 and 27.5 #(ii) is greater than 29 #(iii) is less than 17 #(iv)is less than 15 or greater than 25 #2.Probability that in 60 tosses of a fair coin the head comes up #(i) 20,25 or 30 times #(ii) less than 20 times #(iii) between 20 and 30 times #3.A random variable X has Poisson...

  • The Binomial and Poisson Distributions Both the Binomial and Poisson Distributions deal with discrete data where...

    The Binomial and Poisson Distributions Both the Binomial and Poisson Distributions deal with discrete data where we are counting the number of occurrences of an event. However, they are very different distributions.  This problem will help you be able to recognize a random variable that belongs to the Binomial Distribution, the Poisson Distribution or neither. Characteristics of a Binomial Distribution Characteristics of a Poisson Distribution The Binomial random variable is the count of the number of success in n trials:   number of...

  • Lottery Game (15 Numbers). Design and implement a C++ program that generates 15 random non-repeating positive...

    Lottery Game (15 Numbers). Design and implement a C++ program that generates 15 random non-repeating positive integer numbers from 1 to 999 (lottery numbers) and takes a single input from the user and checks the input against the 15 lottery numbers. The user wins if her/his input matches one of the lottery numbers. Your implementation must have a level of modularity (using functions) Functions you need to implement: Define function initialize() that takes array lotterNumbers[] as a parameter and assigns...

  • Please answer this question with RStudio. 4. In this problem, you will illustrate the idea of...

    Please answer this question with RStudio. 4. In this problem, you will illustrate the idea of resampling and sampling distributions. A ganma distribution with shape k and scale θ has density exp(-v/0) Assume shape k = 2 and scale θ = 3 (a) Use the function dgamma in R to evaluate the density for a range of values between 0 and 20. Produce a plot of the density (b) The (true) mean and variance of the gamma distribution are simple...

  • For this c++ assignment, Overview write a program that will process two sets of numeric information....

    For this c++ assignment, Overview write a program that will process two sets of numeric information. The information will be needed for later processing, so it will be stored in two arrays that will be displayed, sorted, and displayed (again). One set of numeric information will be read from a file while the other will be randomly generated. The arrays that will be used in the assignment should be declared to hold a maximum of 50 double or float elements....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT