MATLAB code to Geometric Random Variable

In summary, a geometric random variable in MATLAB is a discrete random variable used to represent the number of trials needed to achieve a specific success with a constant probability of success. To generate this variable, you can use the geornd function with the probability of success as a parameter. You can also change the probability of success and visualize the data using functions such as histogram and ecdfplot. Additionally, you can use a geometric random variable for statistical analysis by using functions such as geostat, geopdf, and fitgeopdf. These functions allow you to calculate statistics, probability density functions, and perform hypothesis testing and confidence interval calculations.
  • #1
neeraj.patel1
4
0

Homework Statement



Generate Geometric RV with Porbabilty of succcess 0.1 using only rand()


Homework Equations



rand()
geometric rv P=(1-p)^(k-1) * p where p=0.1, k is number of trial in which we get 1st success


The Attempt at a Solution



rand(n)
 
Physics news on Phys.org
  • #2
neeraj.patel1 said:

Homework Statement



Generate Geometric RV with Porbabilty of succcess 0.1 using only rand()


Homework Equations



rand()
geometric rv P=(1-p)^(k-1) * p where p=0.1, k is number of trial in which we get 1st success


The Attempt at a Solution



rand(n)

Can you explain your attempt at a solution?
 

1. What is a geometric random variable in MATLAB?

A geometric random variable in MATLAB is a discrete random variable that represents the number of trials needed to achieve a specific success in a series of independent trials with a constant probability of success. It is often used to model situations such as the number of coin flips needed to get a heads or the number of attempts needed to successfully solve a puzzle.

2. How do I generate a geometric random variable in MATLAB?

To generate a geometric random variable in MATLAB, you can use the geornd function. This function takes in the probability of success as a parameter and returns a single value representing the number of trials needed to achieve success. You can also specify the size of the output to generate multiple values at once.

3. Can I change the probability of success for a geometric random variable in MATLAB?

Yes, you can change the probability of success for a geometric random variable in MATLAB by specifying it as a parameter in the geornd function. You can also use the geostat function to calculate statistics such as mean and variance for different values of the probability of success.

4. How can I visualize a geometric random variable in MATLAB?

You can visualize a geometric random variable in MATLAB by using the histogram function to plot a histogram of the generated values. You can also use the ecdfplot function to plot the empirical cumulative distribution function. These visualizations can help you understand the distribution of the data and check if it matches the theoretical geometric distribution.

5. Can I use a geometric random variable in MATLAB for statistical analysis?

Yes, you can use a geometric random variable in MATLAB for statistical analysis. You can use functions such as geostat and geopdf to calculate statistics and probability density function for the variable. You can also use the fitgeopdf function to fit a geometric distribution to your data and perform hypothesis testing or confidence interval calculations.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
10
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
960
  • Engineering and Comp Sci Homework Help
Replies
9
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
12
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
888
  • Set Theory, Logic, Probability, Statistics
Replies
8
Views
1K
Back
Top