Class: GSL::MultiFit::MultidLMNumDiff

Inherits:
MultidLM
  • Object
show all
Defined in:
lib/gsl_extras.rb

Instance Attribute Summary

Attributes inherited from MultidLM

#chi2, #covar, #dof, #my_chi2, #position

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from MultidLM

#eval, #solve

Constructor Details

#initialize(yproc, ndata, ndims, nparams) ⇒ MultidLMNumDiff

Returns a new instance of MultidLMNumDiff.



934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
# File 'lib/gsl_extras.rb', line 934

def initialize(yproc, ndata, ndims, nparams)
	fproc = Proc.new do |x, *gridpoints, y, sigma, f|
# 				gridpoints = (0...@ndims).to_a.map do |i| 
# 					@gridpoints.col(i)
# 				end
		for i in 0...ndata.size do
			f[i] = (@yproc.call(x, *gridpoints.map{|vec| vec[i]}) - y[i])/sigma[i]
		end
	end
	dfproc = Proc.new do |x, *gridpoints, y, sigma, jac|
			for j in 0...nparams do
				xj = x[j]
				xplus = x.dup
				xplus[j] = xj + @delt[j]
				xminus = x.dup
				xminus[j] = xj - @delt[j]

				for i in 0...ndata do
					gp = gridpoints.map{|vec| vec[i]}
					yplus = @yproc.call(xplus, *gp)
					yminus = @yproc.call(xminus, *gp)
					#p "delt", @delt, "sigma", @sigma, "jac", jac, "jac.shape", jac.shape, "result", (yplus - yminus)/2*@delt[j]/sigma[i]
					jac.set(i, j, (yplus - yminus)/2*@delt[j]/sigma[i])
				end
			end
	end	
	super(yproc, fproc, dfproc, ndata, ndims, nparams)


end

Class Method Details

.alloc(*params) ⇒ Object



930
931
932
# File 'lib/gsl_extras.rb', line 930

def self.alloc(*params)
	new(*params)
end

Instance Method Details

#set_data(xstart, delt, *gridpoints, y, sigma) ⇒ Object



964
965
966
967
# File 'lib/gsl_extras.rb', line 964

def set_data(xstart, delt, *gridpoints, y, sigma)
	@delt = (delt || GSL::Vector.alloc([1e-5]*xstart.size))
	super(xstart, *gridpoints, y, sigma)
end