This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Some illustrations of reliability analysis. | |
| # Time-stamp: <2010-10-17 21:35:51 chl> | |
| x <- c(12,8,22,10,10,6,8,4,14,6,2,22,12,7,24,14,8,4,5,6,14,5,5,16) | |
| GHQ <- data.frame(subject=gl(12,1,24), time=gl(2,12), score=x) | |
| # ---------------------------------------------------- | |
| # Computing reliability (Rx) by hand from ANOVA tables | |
| # ---------------------------------------------------- | |
| # one-way ANOVA (assuming no time trends) | |
| summary(aov(score ~ subject, data=GHQ)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import graph; | |
| import patterns; | |
| size(300,200,IgnoreAspect); | |
| real xmin=-4,xmax=4; | |
| real ymin=0,ymax=1; | |
| real PI=3.141593; | |
| real sd=.6; | |
| real a=1, b=-.5; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import graph; | |
| import patterns; | |
| size(300,200,IgnoreAspect); | |
| real xmin=-4,xmax=4; | |
| real ymin=0,ymax=1; | |
| real PI=3.141593; | |
| real sd=.6; | |
| int a=-1, b=1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import graph; | |
| import patterns; | |
| size(300,200,IgnoreAspect); | |
| real xmin=-4,xmax=4; | |
| real ymin=0,ymax=1; | |
| real PI=3.141593; | |
| real sd=.6; | |
| int a=-1, b=1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cronbach.alpha <- function(data, na.action="omit", signif.level=.05) { | |
| # computes Cronbach's Alpha | |
| # * Input * | |
| # data : a n*k matrix, where each column hold one item responses' | |
| # vector | |
| # na.action : if "omit", then handle missing value in cov/var | |
| # calculation [default] | |
| # signif.level : type I error | |
| # * Output * | |
| # a list with statistic and confidence interval |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Time-stamp: <2010-09-06 19:09:25 chl> | |
| # | |
| # Show multiple boxplot on the same page. | |
| # Part of the code (esp. that concerned with making a bxp | |
| # from scratch comes from P. Murrell. | |
| # | |
| #x <- replicate(50, sample(1:5, 500, rep=TRUE)) | |
| x <- replicate(190, rnorm(500)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| from pylab import * | |
| dt = 0.0005 | |
| t = arange(0.0, 20.0, dt) | |
| s1 = sin(2*pi*100*t) | |
| s2 = 2*sin(2*pi*400*t) | |
| # create a transient "chirp" | |
| mask = where(logical_and(t>10, t>12), 1.0, 0.0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <unistd.h> | |
| #include <sys/types.h> | |
| #include <sys/stat.h> | |
| #include <fcntl.h> | |
| int main(void) { | |
| char * line = NULL; | |
| size_t len = 0; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /usr/bin/env ruby | |
| require 'statsample' | |
| sample=200 | |
| a=sample.times.collect {rand}.to_scale | |
| b=sample.times.collect {rand}.to_scale | |
| c=sample.times.collect {rand}.to_scale | |
| d=sample.times.collect {rand}.to_scale | |
| ds={'a'=>a,'b'=>b,'c'=>c,'d'=>d}.to_dataset |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| require("gsl") | |
| x = 2.0 | |
| P = GSL::Cdf::ugaussian_P(x); | |
| printf("prob(x < %f) = %f\n", x, P); | |
| Q = GSL::Cdf::ugaussian_Q(x); | |
| printf("prob(x > %f) = %f\n", x, Q); |