**dnorm** This is a topic that many people are looking for.

**thevoltreport.com**is a channel providing useful information about learning, life, digital marketing and online courses …. it will help you have an overview and solid multi-faceted knowledge . Today,

**thevoltreport.com**would like to introduce to you

**Statistics 1: dnorm ( ) function in R**. Following along are instructions in the video below:

okay this screencast is talking about the D norm function in R in words what the D norm function does is this weve got our nice Gaussian distribution here Gaussian or normal distribution and attorney distance from zero thats actually called zero there but it x equals zero here but at a distance X from there D norm X gives me that distance there that vertical distance so it starts out at a maximum maximum height here at zero then it gets smaller symmetrically because its symmetrical positive and negative smaller smaller smaller smaller smaller smaller smaller smaller never actually falling to zero its bit difficult to draw it never actually Falls to zero just get smaller and smaller and smaller as you get further and further away from x equals zero so I guess I should set up coordinates x and y like that okay so lets have a look at it in our heres our and as ever the first thing to do is question mark the norm and we see here thats the help page our norm is covered before heres D norm Im not gonna cover this final log argument here but Ill cover these these are their arguments here so D norm X and X is the horizontal distance along the horizontal axis there so thats dust D norm and it gives us the density of the Gaussian distribution so lets just try it heres me our window and well have a look at it if I say X becomes a sequence from equals lets say minus for 2 equals for length equals 100 and if I just type X there Ill just make that bigger Ill just do that again thats my command x equals a sequence from minus 4 to 4 length 100 and if I type so thats X right X again oh you can see it all because of the window theres the first element from – for Susi it can start at minus 4 thats element 99 thats element 200 which is 4 because I told it to start at minus 4 from minus 4 to 4 and 100 long so thats the hundredth element now what I want to do is to use d norm with that value of x there so Ill just bring this up here Im going to go plot X comma D norm X and we can see this Gaussian shape this beautiful Gaussian figure here emerging out of our calculations there it is and this is like the histogram that we saw before if

I go here to our norm of lets say a large number of distribution umber of observations its give me a few more zeros we see a sort of numerical lumpy bumpy random version but this value here this D norm X gives us the perfect mathematical formulation the perfect density function for the Gaussian beautiful alright what I want to do now is to show you how I can use the other to show this one here to show the other the other arguments so weve got X which is the horizontal distance now I want to fool around with the mean and the standard deviation and you can see from here just the same with our norm the mean is 0 and the standard deviation equals 1 unless you override that by telling our that you want to use a particular value so you can try that I can go plot X comma D norm but Ill say a mean equals lets say naught point 5 and you can see how its moved it across there the trouble with this is that once I use my plot statement there if I do another plot statement it what it does it says ah he wants a new graph so it sets up new axes and new new everything and you lose the you lose the original picture to get both on the screen at the same time just hit the up arrow here to get back to that command thats my standard case with a mean of 0 and a standard deviation of 1 if instead of plot if I go points then what this points cmon what this points again what this point its points command here does it doesnt set up a new plot it just puts the points on the existing plot oh there we go so so you can see them both at the same time thats the original one and thats gotta mean if North Point 5 which is down here and I can put more and more on I can say mean of lets say 1.5 and its put put this guy on here lets just go back to the standard case and there it is so because Ive used the plot command it starts again and weve got the nice fresh ones lets go that and then I can say color equals red and then we can say which ones which so thats got the mean of 1.5 which is here and indeed I can show you that by going a b-line

vertical vertical at 1.5 a beeline vertical at one point five and then well see oh there we go thats one point five you see its between zero and two so thats showing us the mean of the red points there so we can shift we can shift the mean left and right as we wish lets try mean equals lets try – lets try – – I dont want to use red again Im having a little bit of difficulty keeping everything Ill just make up there we go so Ill make it lets say blue there we go and we can see this beautiful Gaussian picture over the left I mean if – – there so we can slide the mean around left and right as we weigh what Im gonna do now if I go question mark D norm again Oh incidentally you see Im just coasting on you see how Im just casually using these points and a beeline functions if you want to know more about this a beeline thing just go question mark a beeline and it fires up the health paid help page for a beeline which is which is all this stuff here but we still got the original help page there so you can get help on anything by going question mark what Im going to do is go back to the default case XD norm of X and thats what we started with what Im gonna do now is to change the what Im gonna do now is to change the standard deviation argument ah no no its this one isnt it change the standard deviation argument so lets have a look at that find me our window so Im going to plot D norm X comma standard deviation equals well standard deviation equals one is the default but if I guess standard deviation equals two oh I meant to say points thats plot lets plot again so thats why I lost the original command if I go points here we go whats happened here is that theres the standard mean 0 standard deviation equals 1 this one is showing a wider standard deviation so wider a wider picture a wider distribution because weve set at the standard deviation twice as wide so it should be twice the distribution should be twice as wide when two things have happened yes its got wider but its also got lower because hes got to maintain the total area equal to one and so we can see this lost area here and here

that gained it here Ill do that again lets try that and then Ill say color equals red just so we can see the age you can see what something else has happened with the standard deviation of 2 you see ive not quite – forest at low enough because we still got quite a lot of probability on the red curve at least out here and out here so when I defined X I should have gone a little bit further and Ill do that now X becomes a sequence from oops from equals lets say minus 7 to equal 7 length equals 100 again plot X gives me that and then this one here and then we can see all of this curve which is quite nice okay now I can also make the standard deviation lets do a blue one here standard deviation smaller I can make it nought point seven lets say now whats happened here theres the blue points there its squashed it out right up here the curve would carry on going up there but but but its because Im plotting the points and not rescaling the axes its just omitting to plot these points suppose the axes here to get those as well what I can do is go back to the original one there but I can specify the Y limits of zero and well how high is this one this ones naught point four so well go up to one lets try there we go and because were going all the way up to one here we can see it looks a little bit squashed so now I can go and do this one here with the standard deviation of naught point seven and we see all of it and indeed I can take the standard deviation down even smaller lets say not 0.4 and we can see we can see this picture here and theres no reason why I cant play with both of them at the same time read both of the arguments Im making the mean equals one lets say so here weve got a standard deviation of north point four in a mean of one we can see these red curves here thing down there oops Im having difficulty controlling this lets go back to our old one plot X D norm of X and we can see they ceased use this it scaled it automatically because Ive not given it a while in argument to scale the plot we can see that the value at zero

that it gets in fact we might be able to see it a bit better yeah here we go you can see it takes the value at zero is no point for just a tiny tiny bit under naught point four so well just verify that Dean norm zero and it should be about null point four oh look its no point three nine eight so thats pretty good its actually one over the square root of two times pi if you want the accurate value which is that but lets just do one more valid the reason I want to do this is that I want to just check that this curve here or this like this set of points are plotted here corresponds to reality its just like a reality check so if I go D norm of zero I say its not point four and it is so what that means is that Ive just checked that my understanding is correct here Ill just do one more and then Ill stop lets try the value at minus two and that comes out to this value here which is about looks like about point naught 5 doesnt it so lets try the norm of minus 2 and it should be about point naught 5 oh look at that point naught 5 3 something so thats not bad theres just one more thing I want to check we can see by eye that this curve is symmetrical and if you look at the equation for it for the density you can see that it is exactly symmetrical so that tells us that D norm of +2 should be the same as d norm of minus 2 so lets have a look at that so theres d normal turn it should be the same value and it is because that agrees like that well thats wonderful yeah I think thats great actually Im just gonna do one more thing lets say a hundred now D norm of 100 you see this axis here zero two actually less two four six 100 is going to be like yards and yards in the odds way its going to be miles away to my right but what you should know is that D norm of 100 should be almost zero because this curve has been flying down towards zero and its going very very very small Saudi number 100 should be infinitesimal should be infinitesimally small they go and it comes out to be exactly zero okay theres Dean on Im gonna stop there

tags:

dnorm, dnorm(), R programming language

Thank you for watching all the articles on the topic **Statistics 1: dnorm ( ) function in R**. All shares of thevoltreport.com are very good. We hope you are satisfied with the article. For any questions, please leave a comment below. Hopefully you guys support our website even more.