Data Distributions [PDF]

This worksheet introduces the idea of a distribution. We will look at the distribution of the human height observations

5 downloads 20 Views 4MB Size

Recommend Stories


Fitting data into probability distributions
Just as there is no loss of basic energy in the universe, so no thought or action is without its effects,

categorical data: one-sample distributions
Be grateful for whoever comes, because each has been sent as a guide from beyond. Rumi

Modeling data using directional distributions
The wound is the place where the Light enters you. Rumi

Distributions to model overdispersed count data
The happiest people don't have the best of everything, they just make the best of everything. Anony

Benford law and lognormal distributions | Freakonometrics [PDF]
Mar 28, 2013 - (benford=log(1+1/(1:9))/log(10)) [1] 0.30103000 0.17609126 0.12493874 0.09691001 0.07918125 [6] 0.06694679 0.05799195 0.05115252 0.04575749 > names(benford)=1:9 > sum(benford) [1] 1 > barplot(benford,col="white",ylim=c(-.045,.3)) > abl

Photoelectron angular distributions from rotationally resolved [PDF]
Dec 8, 2017 - Chartrand, Alexander M.; McCormack, Elizabeth F.; Jacovella, Ugo; Holland, David M P; Gans, Berenger; Tang, Xiaofeng; García,. Gustavo A.; Nahon, Laurent; and Pratt, Stephen T., "Photoelectron angular distributions from rotationally re

Joint Distributions
Pretending to not be afraid is as good as actually not being afraid. David Letterman

Probability Distributions
Never let your sense of morals prevent you from doing what is right. Isaac Asimov

Counterfactual distributions
How wonderful it is that nobody need wait a single moment before starting to improve the world. Anne

Probability Distributions
Everything in the universe is within you. Ask all from yourself. Rumi

Idea Transcript


# This is a chunk of R code. All test after a # symbol is a comment

# Set working directory using setwd() function setwd('Enter the path to my working directory')

# Clear all variables in R's memory rm(list=ls()) # Standard code to clear R's memory

2 + 4 # Use R to add two numbers

## [1] 6

human = read.table('HEIGHT.CSV', header=T, sep=',') # Import human height data set humanF = subset(human, SEX=='F') # Extract data for females

wolf = read.table('WOLF.CSV', header=T, sep=',') # Import wolf data set

humanF

hist()

hist(humanF$HEIGHT, breaks=30)

µ

rnorm()

# Generate 10000 data point drawn from a normal distribution normal_data = rnorm(n=10000, mean=2, sd=0.5)

# Produce a histogram of the generated data hist(normal_data, breaks=30)

median(humanF$HEIGHT)

## [1] 1.63

mean()

mad(humanF$HEIGHT)

## [1] 0.0652344

sd() IQR()

range()

range(humanF$HEIGHT)

## [1] 1.428 1.870

# Calculate 1% and 99% quantiles quantile(humanF$HEIGHT, prob=c(0.01, 0.99))

## 1% 99% ## 1.49300 1.77985

hist(wolf$Cpgmg, breaks=40) # Display distribution of wolf cortisol

summary(wolf$Cpgmg)

## Min. 1st Qu. Median Mean 3rd Qu. Max. ## 4.75 12.16 15.60 17.74 20.35 73.19

# A quantile-quantile plot for cortisol in the wolf2 data qqnorm(wolf$Cpgmg) qqline(wolf$Cpgmg)

humanF$HEIGHT

# Generate 10000 values from an exponential distribution # with rate parameter=0.2 exp_data = rexp(n=10000, rate=0.2) # Display first 6 values head(exp_data, n=6)

## [1] 1.3200046 11.1079375 0.7374528 12.5272467 10.9808850 1.6811151

# Use a for-loop to repeatly generate 10000 data points from an exponential # distribution and add it to the last set of data generated.

# Display the average of this summed data for n=1 # Only display the distribution out to values of 15 hist(exp_data, breaks=20, xlim=c(0,15), col='darkgreen')

# Add together 5 exponential variables exp_5 = rexp(n=10000, rate=0.2) for (i in 2:5) { exp_5 = exp_5 + rexp(n=10000, rate=0.2) } # Display the average of this summed data for n=5 # Add this data to the histogram hist(exp_5/5, breaks=20, add=T, col='blue')

# Add together 30 exponential variables exp_30 = rexp(n=10000, rate=0.2) for (i in 2:30) { exp_30 = exp_30 + rexp(n=10000, rate=0.2) } # Display the average of this summed data for n=30 # Add this data to the histogram hist(exp_30/30, breaks=20, add=T, col='red')

# Add a legend to the histogram legend('topright', legend = c('n=1','n=5','n=30'), fill=c('darkgreen','blue','red'))

rnorm() for-loop

Smile Life

When life gives you a hundred reasons to cry, show life that you have a thousand reasons to smile

Get in touch

© Copyright 2015 - 2024 PDFFOX.COM - All rights reserved.