sigma

MLE error in R: initial value in 'vmmin' is not finite

匿名 (未验证) 提交于 2019-12-03 01:10:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Suppose I have 2 data.frame objects: df1 <- data.frame(x = 1:100) df1$y <- 20 + 0.3 * df1$x + rnorm(100) df2 <- data.frame(x = 1:200000) df2$y <- 20 + 0.3 * df2$x + rnorm(200000) I want to do MLE. With df1 everything is ok: LL1 <- function(a, b, mu, sigma) { R = dnorm(df1$y - a- b * df1$x, mu, sigma) -sum(log(R)) } library(stats4) mle1 <- mle(LL1, start = list(a = 20, b = 0.3, sigma=0.5), fixed = list(mu = 0)) > mle1 Call: mle(minuslogl = LL1, start = list(a = 20, b = 0.3, sigma = 0.5), fixed = list(mu = 0)) Coefficients: a b mu sigma 23

one Dimensional gauss convolution function in Matlab

匿名 (未验证) 提交于 2019-12-03 01:10:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to write a function that returns a one dimentional gauss filter. the function took sigma as a parameter. The problem is that the function returns the same array for all sigmas. function gaussFilter=gauss(sigma) width = 3 * sigma; support = (-width :sigma: width); gaussFilter= exp( - (support).^2 / (2*sigma^2)); gaussFilter = gaussFilter/ sum(gaussFilter); Note that support array is calculated correctly but the problem arise when applying the exp. 回答1: The idea is that the filter needs to be wide enough to represent the Gaussian

Numpy divide by zero. Why?

匿名 (未验证) 提交于 2019-12-03 00:59:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: import pygame import random import math import numpy as np import matplotlib.pyplot as plt fx = np.zeros([11]) fy = np.zeros([11]) x = np.zeros([11]) y = np.zeros([11]) x[0] = 11 y[0] = 1 sigma = 1.01 e = 1.1 dt = 0.1 def LJ(x,y): for i in range(1,10): for j in range(1,10): rx = (x[i]-x[j]) ry = (y[i]-y[j]) fx[i] = 24*e*(((2/rx)*sigma/rx**12)-((1/rx)*sigma/rx**6)) fy[i] = 24*e*(((2/ry)*sigma/ry**12)-((1/ry)*sigma/ry**6)) print fx, fy Why am I still getting errors RuntimeWarning: divide by zero encountered in double_scalars and RuntimeWarning

Low pass gaussian filter with a specified cut off frequency

匿名 (未验证) 提交于 2019-12-03 00:57:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I'm playing around with hybrid images , and wanted to use a gaussian filter to low pass filter an image. However, to make hybrid images, 2 filters are supposed to be used on the 2 images being combined with different cut off frequencies. Does fspecial() allow us to specify cut off frequencies when we employ it to make a gaussian filter? (I know that we can specify the filter size and sigma and that there is some relation between sigma and cut off frequency). If we can only specify cut off frequencies using sigma, then what sigma would I need

Error in optim: function cannot be evaluated at initial parameters [closed]

匿名 (未验证) 提交于 2019-12-03 00:57:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: So I've run into this weird error in R. I have a simple function which returns an error term when comparing real and simulated prices, called hestondifferences() . when I try to find the local minima via: res<-optim(fn=hestondifferences, par = c(vT=vT, rho=rho, k=k, sigma=sigma)) I get the error message: Error in optim(fn = hestondifferences, par = c(vT = vT, rho = rho, k = k, : function cannot be evaluated at initial parameters What confuses me is that calling the function directly with the initial parameters hestondifferences(vT, rho, k,

jags.parallel: setting less clusters than chains: “Error in res[[ch]] : subscript out of bounds”

匿名 (未验证) 提交于 2019-12-03 00:56:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have only 2 core CPU so logically I want to set only two parallel threads/clusters for jags.parallel . unfortunatelly, when I try it and the number of chains is 3 or 4, jags fails with an error: Error in res[[ch]] : subscript out of bounds Is lower number of threads (than chains) not allowed? I have not encountered such statement in the documentation. Anyway, it doesn't make sense to run 4 chains in 4 threads/clusters, when your CPU only has 2 cores! Threads will fight for CPU, caches won't be used optimally and the result will be much

Machine Learning-Programming Exercise 1: Linear Regression

匿名 (未验证) 提交于 2019-12-03 00:37:01
数据描述 数据下载链接 导入python包 import numpy as np import matplotlib import matplotlib.pyplot as plt 子函数描述 #将文本记录转化为Numpy #filename为文件名,k为属性维数 def file2matrix(filename,k): fr = open(filename) numberOfLines = len(fr.readlines()) #get the number of lines in the file returnMat = np.zeros((numberOfLines,k)) #prepare matrix to return classLabelVector = np.zeros((numberOfLines,1)) #prepare labels return fr = open(filename) index = 0 for line in fr.readlines(): line = line.strip() listFromLine = line.split(',') returnMat[index,:] = listFromLine[0:k] classLabelVector[index,:] = float(listFromLine[-1]) index +=

手撕OpenCV源码之GaussianBlur

匿名 (未验证) 提交于 2019-12-03 00:22:01
首先看源码: void cv::GaussianBlur( InputArray _src, OutputArray _dst, Size ksize, double sigma1, double sigma2, int borderType ) { //初始化及边界类型等的判断 CV_INSTRUMENT_REGION() int type = _src .type () ; Size size = _src .size () ; _dst .create ( size, type ) ; if( borderType != BORDER_CONSTANT && (borderType & BORDER_ISOLATED) != 0 ) { if( size .height == 1 ) ksize .height = 1 ; if( size .width == 1 ) ksize .width = 1 ; } //容易理解,高斯滤波器如果尺寸为 1 ,根据高斯函数可以知道该系数为 1 ,所以就是将输入复制到输出 if( ksize .width == 1 && ksize .height == 1 ) { _src .copyTo (_dst) ; return ; } //OpenCV中针对一些ksize = 3 和 5 的情况做了OpenCL优化

瑞利分布的随机数

匿名 (未验证) 提交于 2019-12-03 00:14:01
产生瑞利分布的随机数。 瑞利分布的概率密度函数为 \[ f(x) = \frac{x}{\sigma ^{2} }e^{-x^{2}/2\sigma ^{2}} \ x > 0 \] 瑞利分布的均值为 \(\sigma \sqrt{\frac{\pi }{2}}\) ,方差为 \(\left ( 2 - \frac{\pi }{2} \right )\sigma ^{2}\) 。 首先用逆变换法产生参数 \(\beta = 2\) 的指数分布的随机变量 \(y\) ,其概率密度函数为 \(f(y) = \frac{1}{2} e^{-\frac{y}{2}}\) ;然后通过变换 \(x = \sigma \sqrt{y}\) ,产生瑞利分布的随机变量 \(x\) ,具体方法如下: 产生均匀分布的随机数 \(u\) ,即 \(u \sim U(0,1)\) ; 计算 \(y = - 2 \ ln(u)\) ; 计算 \(x = \sigma \sqrt{y}\) 。 是用C语言实现产生瑞利分布随机数的方法如下: /************************************ sigma ---瑞利分布的参数sigma seed ---随机数种子 ************************************/ #include "math.h" #include

Gaussian kernels: convert FWHM to sigma

匿名 (未验证) 提交于 2019-12-03 00:06:01
Gaussian kernels: convert FWHM to sigma When smoothing images and functions using Gaussian kernels, often we have to convert a given value for the full width at the half maximum (FWHM) to the standard deviation of the filter (sigma, ). This happens because the implementation generally is in terms of sigma, while the FWHM is the more popular parameter in certain areas. The conversion is trivial, but it may well worth write it up here. The probability density function (pdf) for the Gaussian distribution with mean and standard deviation is: If the filter is centered at the origin, the mean is 0