0% found this document useful (0 votes)
5 views4 pages

unit 4

The document outlines various probability distributions available in R, including Normal, Binomial, and Poisson distributions, along with their corresponding functions for generating random numbers, calculating probabilities, and quantiles. It also compares R and Python in terms of data visualization, production capabilities, model interpretability, syntax complexity, and model creation. Overall, it provides a comprehensive overview of statistical functions in R and a brief comparison with Python.

Uploaded by

lomic31750
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views4 pages

unit 4

The document outlines various probability distributions available in R, including Normal, Binomial, and Poisson distributions, along with their corresponding functions for generating random numbers, calculating probabilities, and quantiles. It also compares R and Python in terms of data visualization, production capabilities, model interpretability, syntax complexity, and model creation. Overall, it provides a comprehensive overview of statistical functions in R and a brief comparison with Python.

Uploaded by

lomic31750
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

In R, you can work with various probability distributions using built-in functions from the `stats`

package. These functions allow you to generate random numbers from specific distributions,
calculate probability density or mass functions, cumulative distribution functions, and quantiles.
Here are some commonly used probability distributions and their corresponding functions in R:

1. **Normal Distribution (`rnorm`, `dnorm`, `pnorm`, `qnorm`)**:

In R, a normal distribution represents a symmetric bell-shaped curve where most values cluster
around the mean, with fewer values further away. It's commonly used for modeling real-world
data due to its versatility and widespread occurrence in natural phenomena.

- `rnorm(n, mean, sd)`: Generates n random numbers from a normal distribution with mean
and standard deviation specified.

- `dnorm(x, mean, sd)`: Computes the probability density at x for a normal distribution with
mean and standard deviation specified.

- `pnorm(q, mean, sd)`: Calculates the cumulative probability up to q for a normal distribution
with mean and standard deviation specified.

- `qnorm(p, mean, sd)`: Calculates the quantile corresponding to the cumulative probability p
for a normal distribution with mean and standard deviation specified.

Pgm:-

random_numbers <- rnorm(1000, mean = 0, sd

density_at_x <- dnorm(0, mean = 0, sd = 1)

cumulative_prob <- pnorm(0, mean = 0, sd = 1)

quantile <- qnorm(0.5, mean = 0, sd = 1)


2. **Binomial Distribution (`rbinom`, `dbinom`, `pbinom`, `qbinom`)**:

.In R, the binomial distribution represents the probability of getting a certain number of
successes in a fixed number of independent Bernoulli trials, each with the same probability of
success.

- `rbinom(n, size, prob)`: Generates n random numbers from a binomial distribution with
number of trials (size) and probability of success (prob) specified.

- `dbinom(x, size, prob)`: Computes the probability mass function at x for a binomial
distribution with number of trials (size) and probability of success (prob) specified.

- `pbinom(q, size, prob)`: Calculates the cumulative probability up to q for a binomial


distribution with number of trials (size) and probability of success (prob) specified.

- `qbinom(p, size, prob)`: Calculates the quantile corresponding to the cumulative probability p
for a binomial distribution with number of trials (size) and probability of success (prob)
specified.

Pgm:-

random_numbers <- rbinom(1000, size = 10, prob = 0.5)

pmf_at_x <- dbinom(5, size = 10, prob = 0.5)

cumulative_prob <- pbinom(5, size = 10, prob = 0.5)

quantile <- qbinom(0.5, size = 10, prob = 0.5)


3. **Poisson Distribution (`rpois`, `dpois`, `ppois`, `qpois`)**:

In R, a Poisson distribution models the probability of a certain number of events occurring in a


fixed interval of time or space, given a constant rate of occurrence. It's useful for modeling rare
events

- `rpois(n, lambda)`: Generates n random numbers from a Poisson distribution with mean
(lambda) specified.

- `dpois(x, lambda)`: Computes the probability mass function at x for a Poisson distribution
with mean (lambda) specified.

- `ppois(q, lambda)`: Calculates the cumulative probability up to q for a Poisson distribution


with mean (lambda) specified.

- `qpois(p, lambda)`: Calculates the quantile corresponding to the cumulative probability p for
a Poisson distribution with mean (lambda) specified.

Pgm:-

random_numbers <- rpois(1000, lambda = 5)

pmf_at_x <- dpois(3, lambda = 5)

cumulative_prob <- ppois(3, lambda = 5)

quantile <- qpois(0.5, lambda = 5)


R programming Py

Data visualization libraries and tools are good R has poor data visualization than python.
in R language

Production is poor than python. Production is better than R.

Model Interpretability is good in R Model Interpretability is not good in python.


programming language.

R has relative complex syntax and learning. Syntax is simple in python

Model creation is similar to Python. Model creation is similar to R.

You might also like