Discrete Vs Continuous Random Variables in R
By: Karthik Janar in data-science Tutorials on 2018-04-30
Discrete Random Variable
Random in statistics does not mean 'haphazard" but it means a kind of order that emerges in the long run. For example we term unpredictable things that happen in our life as 'random". But we rarely see enough repetition of the same random phenomenon to observe a long term regulatrity that probability describes about "random"ness.
If we define X={number of heads in a three coin tosses}, then X can take ONLY values 0,1,2 and 3. Hence X is a discrete variable. And since the coin tosses resulting in Heads can occur randomly in any order, X is a DISCRETE random variable.
x <- c(0,1,2,3)
y <- c(1/8,3/8,3/8,1/8)
barplot(y,names.arg=x,ylab = "Probability", xlab="Discrete X Values", ylim = c(0,1))
continuous Random Variable (X)
However, if we define X ={all values between 0 and 2}, there can be infinitely many possible values, so X is called a continuous random variable. This is demonstrated below.
x <- seq(0,2,length=1000)
y <- dnorm(x, mean = 1, sd = 0.5)
plot(x,y)
Add Comment
This policy contains information about your privacy. By posting, you are declaring that you understand this policy:
- Your name, rating, website address, town, country, state and comment will be publicly displayed if entered.
- Aside from the data entered into these form fields, other stored data about your comment will include:
- Your IP address (not displayed)
- The time/date of your submission (displayed)
- Your email address will not be shared. It is collected for only two reasons:
- Administrative purposes, should a need to contact you arise.
- To inform you of new comments, should you subscribe to receive notifications.
- A cookie may be set on your computer. This is used to remember your inputs. It will expire by itself.
This policy is subject to change at any time and without notice.
These terms and conditions contain rules about posting comments. By submitting a comment, you are declaring that you agree with these rules:
- Although the administrator will attempt to moderate comments, it is impossible for every comment to have been moderated at any given time.
- You acknowledge that all comments express the views and opinions of the original author and not those of the administrator.
- You agree not to post any material which is knowingly false, obscene, hateful, threatening, harassing or invasive of a person's privacy.
- The administrator has the right to edit, move or remove any comment for any reason and without notice.
Failure to comply with these rules may result in being banned from submitting further comments.
These terms and conditions are subject to change at any time and without notice.
Most Viewed Articles (in data-science ) |
Latest Articles (in data-science) |
- Data Science
- Android
- React Native
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview
Comments