How to do it...

Perform the following steps:

  1. For a normal distribution, the user can use dnorm, which will return the height of a normal curve at 0:
        > dnorm(0)
        Output:
    
       [1] 0.3989423  
  1. Then, the user can change the mean and the standard deviation in the argument:
        > dnorm(0,mean=3,sd=5)
        Output:
    
        [1] 0.06664492  
  1. Next, plot the graph of a normal distribution with the curve function:
        > curve(dnorm,-3,3)
Standard normal distribution
  1. In contrast to dnorm, which returns the height of a normal curve, the pnorm function can return the area under a given value:
        > pnorm(1.5)
        Output:
    
        [1] 0.9331928  
  1. Alternatively, to get the area over a certain ...

Get Machine Learning with R Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.