- norma()
dnorm(x, mean, sd)>norma()
pnorm(x, mean, sd)>normaq()
qnorm(p, mean, sd)>norma()
rnorm(n, mean, sd)>Dove,
– X rappresenta l'insieme di dati di valori – media(x) rappresenta la media del set di dati X . Il suo valore predefinito è 0.>– SD(x) rappresenta la deviazione standard del set di dati X . Il suo valore predefinito è 1.>– N è il numero di osservazioni. – P è un vettore di probabilità
Funzioni per generare una distribuzione normale in R
norma()
dnorm()> la funzione nella programmazione R misura la funzione di densità della distribuzione. Nelle statistiche, viene misurato con la formula seguente:>Dove,
è cattivo e
è la deviazione standard. Sintassi: dnorm(x, mean, sd)>Esempio:
# creating a sequence of values> # between -15 to 15 with a difference of 0.1> x>=> seq(>->15>,>15>, by>=>0.1>)> > y>=> dnorm(x, mean(x), sd(x))> > # output to be present as PNG file> png(>file>=>'dnormExample.webp'>)> > # Plot the graph.> plot(x, y)> > # saving the file> dev.off()> |
>
>Produzione:
norma()
pnorm()> La funzione è la funzione di distribuzione cumulativa che misura la probabilità che un numero casuale X assuma un valore inferiore o uguale a x, ovvero in statistica è dato da->Sintassi:
pnorm(x, mean, sd)>Esempio:
# creating a sequence of values> # between -10 to 10 with a difference of 0.1> x <>-> seq(>->10>,>10>, by>=>0.1>)> > y <>-> pnorm(x, mean>=> 2.5>, sd>=> 2>)> > # output to be present as PNG file> png(>file>=>'pnormExample.webp'>)> > # Plot the graph.> plot(x, y)> > # saving the file> dev.off()> |
>
>Produzione :
normaq()
qnorm()> la funzione è l'inverso di pnorm()>funzione. Prende il valore di probabilità e fornisce un output che corrisponde al valore di probabilità. È utile per trovare i percentili di una distribuzione normale. Sintassi: qnorm(p, mean, sd)>Esempio:
# Create a sequence of probability values> # incrementing by 0.02.> x <>-> seq(>0>,>1>, by>=> 0.02>)> > y <>-> qnorm(x, mean(x), sd(x))> > # output to be present as PNG file> png(>file> => 'qnormExample.webp'>)> > # Plot the graph.> plot(x, y)> > # Save the file.> dev.off()> |
>
>Produzione:
norma()
rnorm()> La funzione nella programmazione R viene utilizzata per generare un vettore di numeri casuali normalmente distribuiti. Sintassi: rnorm(x, mean, sd)>Esempio:
# Create a vector of 1000 random numbers> # with mean=90 and sd=5> x <>-> rnorm(>10000>, mean>=>90>, sd>=>5>)> > # output to be present as PNG file> png(>file> => 'rnormExample.webp'>)> > # Create the histogram with 50 bars> hist(x, breaks>=>50>)> > # Save the file.> dev.off()> |
>
>Produzione :