hessian-matrix

The curious case of ARIMA modelling using R

柔情痞子 提交于 2019-12-09 20:00:50
问题 I observed something strange while fitting an ARMA model using the function arma{tseries} and arima{stats} in R. There is a radical difference in the estimation procedures adopted by the two functions, Kalman filter in arima{stats} as opposed to ML estimation in arma{tseries}. Given the difference in the estimation procedures between the two functions, one would not expect the results to be radically different for the two function if we use the same timeseries. Well seems that they can!

R Hessian Matrix

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-08 02:04:38
问题 I need to create the Hessian matrix of a function given as: func <- expression(sin(x+y)+cos(x-y)) vars <- c("x", "y") I need the second order derivatives as expressions too, and I need to evaluate them lot of times, so I made a list of first order derivatives, and a list of list of second order derivatives. funcD <- lapply(vars, function(v) D(func, v)) funcDD <- list(); for (i in 1:length(vars)) funcDD[[i]] <- lapply(vars, function(v) D(funcD[[i]], v)) So far, it works. > funcDD [[1]] [[1]][

R Hessian Matrix

▼魔方 西西 提交于 2019-12-06 07:54:59
I need to create the Hessian matrix of a function given as: func <- expression(sin(x+y)+cos(x-y)) vars <- c("x", "y") I need the second order derivatives as expressions too, and I need to evaluate them lot of times, so I made a list of first order derivatives, and a list of list of second order derivatives. funcD <- lapply(vars, function(v) D(func, v)) funcDD <- list(); for (i in 1:length(vars)) funcDD[[i]] <- lapply(vars, function(v) D(funcD[[i]], v)) So far, it works. > funcDD [[1]] [[1]][[1]] -(sin(x + y) + cos(x - y)) [[1]][[2]] -(sin(x + y) - cos(x - y)) [[2]] [[2]][[1]] cos(x - y) - sin

The curious case of ARIMA modelling using R

China☆狼群 提交于 2019-12-04 16:12:21
I observed something strange while fitting an ARMA model using the function arma{tseries} and arima{stats} in R. There is a radical difference in the estimation procedures adopted by the two functions, Kalman filter in arima{stats} as opposed to ML estimation in arma{tseries}. Given the difference in the estimation procedures between the two functions, one would not expect the results to be radically different for the two function if we use the same timeseries. Well seems that they can! Generate the below timeseries and add 2 outliers. set.seed(1010) ts.sim <- abs(arima.sim(list(order = c(1,0

numpy second derivative of a ndimensional array

陌路散爱 提交于 2019-11-30 12:04:37
问题 I have a set of simulation data where I would like to find the lowest slope in n dimensions. The spacing of the data is constant along each dimension, but not all the same (I could change that for the sake of simplicity). I can live with some numerical inaccuracy, especially towards the edges. I would heavily prefer not to generate a spline and use that derivative; just on the raw values would be sufficient. It is possible to calculate the first derivative with numpy using the numpy.gradient(

numpy second derivative of a ndimensional array

泪湿孤枕 提交于 2019-11-30 01:57:22
I have a set of simulation data where I would like to find the lowest slope in n dimensions. The spacing of the data is constant along each dimension, but not all the same (I could change that for the sake of simplicity). I can live with some numerical inaccuracy, especially towards the edges. I would heavily prefer not to generate a spline and use that derivative; just on the raw values would be sufficient. It is possible to calculate the first derivative with numpy using the numpy.gradient() function. import numpy as np data = np.random.rand(30,50,40,20) first_derivative = np.gradient(data)

Compute hessian with respect to several variables in tensorflow

我的梦境 提交于 2019-11-29 08:47:17
Computing Hessian in tensorflow is quite easy: x = tf.Variable([1., 1., 1.], dtype=tf.float32, name="x") f = (x[0] + x[1] ** 2 + x[0] * x[1] + x[2]) ** 2 hessian = tf.hessians(f, x) This correctly returns [[ 8., 20., 4.], [20., 34., 6.], [ 4., 6., 2.]] In my real case instead of using one single variable x holding three values, I need to split it in two variables: x (holding the first two) and y (holding the last one). x = tf.Variable([1., 1.], dtype=tf.float32, name="x") y = tf.Variable([1.], dtype=tf.float32, name="y") f = (x[0] + x[1] ** 2 + x[0] * x[1] + y) ** 2 I tried a naive hessian =

Compute hessian with respect to several variables in tensorflow

做~自己de王妃 提交于 2019-11-28 02:05:35
问题 Computing Hessian in tensorflow is quite easy: x = tf.Variable([1., 1., 1.], dtype=tf.float32, name="x") f = (x[0] + x[1] ** 2 + x[0] * x[1] + x[2]) ** 2 hessian = tf.hessians(f, x) This correctly returns [[ 8., 20., 4.], [20., 34., 6.], [ 4., 6., 2.]] In my real case instead of using one single variable x holding three values, I need to split it in two variables: x (holding the first two) and y (holding the last one). x = tf.Variable([1., 1.], dtype=tf.float32, name="x") y = tf.Variable([1.]