MACHINE LEARNING RECIPES
DATA CLEANING PYTHON
DATA MUNGING
PANDAS CHEATSHEET
ALL TAGS
# How to create a random distribution in R?

# How to create a random distribution in R?

This recipe helps you create a random distribution in R

Random numbers are generated in quite a few cases in statistics to carry out sampling and simulation. Mostly, a data scientist is in a need of a set of random numbers which are mostly taken from two types of distribution:

- Uniform distribution
- Normal distribultion

These random numbers generated mimic the properties of uniform or normal distribution in a certain interval.

In this recipe, you will learn how to create a random distribution using rnorm.

Note: Whenever we are generating random numbers, you are using an algorithm that requires a seed whose function is to initialise. These numbers are actually pseudorandom numbers which can be predicted if we know the seed and the generator. Setting a seed means iniltialising a pseudorandom generator. We set a seed when we need the same output of numbers everytime you want to generate random numbers. If we don't set a seed, the generated pseudorandom numbers are different on each execution.

We use rnorm() function to carry out this task.

Syntax: rnorm(n, min = , max = )

where:

- n = size of the distribution
- min, max = specifies the interval in which you would like the distribution to be

Additionally, use set.seed() function to set a seed. We specify any integer in the function as a seed.

```
# setting a seed
set.seed(20)
# using random numbers from normal distribution between 1 and 30
random_dist = rnorm(10000, mean = 0, sd = 1)
#plotting a histogram of the generated numbers using hist() function
hist(random_dist, breaks = 100)
```

Note:

- The distribution remains constant even after multiple execution.
- You can see that the mean, mode and median co-incides in the above plot indicating a normal distribution

In this machine learning project you will work on creating a robust prediction model of Rossmann's daily sales using store, promotion, and competitor data.

In this data science project in R, we are going to talk about subjective segmentation which is a clustering technique to find out product bundles in sales data.

In this data science project, you will learn how to perform market basket analysis with the application of Apriori and FP growth algorithms based on the concept of association rule learning.

In this NLP AI application, we build the core conversational engine for a chatbot. We use the popular NLTK text classification library to achieve this.

In this machine learning project, you will develop a machine learning model to accurately forecast inventory demand based on historical sales data.

Data Science Project in Python- Build a machine learning algorithm that automatically suggests the right product prices.

Build your own image similarity application using Python to search and find images of products that are similar to any given product. You will implement the K-Nearest Neighbor algorithm to find products with maximum similarity.

In this supervised learning machine learning project, you will predict the availability of a driver in a specific area by using multi step time series analysis.

In this human activity recognition project, we use multiclass classification machine learning techniques to analyse fitness dataset from a smartphone tracker.

Machine Learning Project in R- Predict the customer churn of telecom sector and find out the key drivers that lead to churn. Learn how the logistic regression model using R can be used to identify the customer churn in telecom dataset.