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 numpy as np | |
| import scikits.audiolab | |
| import scipy | |
| f = 440 | |
| fs = 11025 #22050 | |
| T = 0.1 | |
| x = scipy.cos((2*scipy.pi*f/fs)*scipy.arange(fs*T)) | |
| for y in range(0,1000): |
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
| 2. | |
| ```{r} | |
| #make matrices | |
| set.seed(693) | |
| A <- matrix(ceiling(runif(4, min=100, max=999)), nrow=2, ncol=2) | |
| B <- matrix(ceiling(runif(4, min=-9, max=9)), nrow=2, ncol=2) | |
| C <- matrix(ceiling(-runif(4, min=100, max=999)), nrow=2, ncol=2) | |
| Z <- matrix(0, nrow=2, ncol=2) | |
| M <- rbind(cbind(Z,Z,A), cbind(Z,B,Z), cbind(C,Z,Z)) |
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
| 2. | |
| ```{r} | |
| #make matrices | |
| set.seed(693) | |
| A <- matrix(ceiling(runif(4, min=100, max=999)), nrow=2, ncol=2) | |
| B <- matrix(ceiling(runif(4, min=-9, max=9)), nrow=2, ncol=2) | |
| C <- matrix(ceiling(-runif(4, min=100, max=999)), nrow=2, ncol=2) | |
| Z <- matrix(0, nrow=2, ncol=2) | |
| M <- rbind(cbind(Z,Z,A), cbind(Z,B,Z), cbind(C,Z,Z)) |
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
| 2. | |
| ```{r} | |
| #make matrices | |
| set.seed(693) | |
| A <- matrix(ceiling(runif(4, min=100, max=999)), nrow=2, ncol=2) | |
| B <- matrix(ceiling(runif(4, min=-9, max=9)), nrow=2, ncol=2) | |
| C <- matrix(ceiling(-runif(4, min=100, max=999)), nrow=2, ncol=2) | |
| Z <- matrix(0, nrow=2, ncol=2) | |
| M <- rbind(cbind(Z,Z,A), cbind(Z,B,Z), cbind(C,Z,Z)) |
This file has been truncated, but you can view the full file.
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
| <!doctype HTML> | |
| <meta charset = 'utf-8'> | |
| <html> | |
| <head> | |
| <link rel='stylesheet' href='//cdnjs.cloudflare.com/ajax/libs/nvd3/1.1.15-beta/nv.d3.min.css'> | |
| <script src='//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js' type='text/javascript'></script> | |
| <script src='//d3js.org/d3.v3.min.js' type='text/javascript'></script> | |
| <script src='//cdnjs.cloudflare.com/ajax/libs/nvd3/1.1.15-beta/nv.d3.min.js' type='text/javascript'></script> |
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
| <!doctype HTML> | |
| <meta charset = 'utf-8'> | |
| <html> | |
| <head> | |
| <link rel='stylesheet' href='//tenxer.github.io/xcharts/css/master.css'> | |
| <script src='//d3js.org/d3.v2.min.js' type='text/javascript'></script> | |
| <script src='//tenxer.github.io/xcharts/js/xcharts.min.js' type='text/javascript'></script> | |
| <style> |
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
| power2 <- function(B1 = B1, B2 = B2, v1.old = u1, v2.old = u2, p = .15) { | |
| N <- length(v1.old) | |
| B1.p <- matrix(0, ncol=5242, nrow=5242) | |
| B1.p <- sapply(1:5242, function(x) (1-p)/sum(B1[x,]) * B1[x,]) | |
| B2.p <- (p/N) * B2 | |
| v1.new <- B1.p %*% v1.old + B2.p %*% v1.old | |
| v1.new <- v1.new / norm(v1.new) | |
| v2.new <- B1.p %*% v2.old + B2.p %*% v2.old |
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
| power <- function(B1 = B1, B2 = B2, v.old = v, tol = 10^-10, p = .15) { | |
| N <- length(v) | |
| B.p <- matrix(0, ncol=5242, nrow=5242) | |
| B.p <- sapply(1:5242, function(x) (1-p)/sum(B1[x,]) * B1[x,]) | |
| v.old <- v | |
| v.new <- B.p %*% v.old + (p/N) * B2 %*% v.old | |
| v.new <- v.new / norm(v.new) | |
| i <- 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
| Elaine Ayo | |
| Math 504 / Homework 10 | |
| March 29, 2015 | |
| ```{r echo=FALSE, message=FALSE} | |
| library(MASS) | |
| library(Matrix) | |
| library(ggplot2) |
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
| data <- read.table("~/Dropbox/numericalmethods/nonlinear.txt", header=TRUE, quote="\"") | |
| #param order: d, r | |
| fxn.4 <- list( | |
| f.x = function(params, data) return( sum((data$y - params[1]*exp(-params[2] * data$x) )^2) ), | |
| grad = function(params, data, f.x, h) { | |
| d.d <- (f.x(params = c(params[1] + h, params[2]), data) - f.x(params, data)) / h | |
| d.r <- (f.x(params = c(params[1], params[2] + h), data) - f.x(params, data)) / h | |
| return(c(d.d,d.r)) | |
| }, |
NewerOlder