[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Equivalent of EXCEL LINEST function?




Bruce Bowler <bbowler@bigelow.org> writes:
> So it is... now for "stupid question #347" (tm).
> 
> How do I turn a vector (which is what I have for x) into an array?
> 
> 	help, x
> 	x		float		= array[12345]
> 	help, y
> 	y		float		= array[12345]
> 	weight = replicate(1.0,n_elements(y))
> 	help, weight
> 	weight		float		= array[12345]
> 	result = regress(x,y,weight,/relative_weight)
> 	% REGRESS: Incompatable arrays.
> 
> Looking at the code for regress, the only condition I violate to cause
> that message is that my X is only 1 dimenesion, not 2...

Probably you want to REFORM the vector into an array ( = reform(x,1,n))

However using REGRESS may be like killing a fly with a shotgun, a bit
of overkill.

Why not use LINFIT and CORRELATE, which standard IDL functions?

p = linfit(x,y, sigma=dp)   ;; DP are parameter uncertainties
r2 = correlate(x,y)

Done!

Craig


-- 
--------------------------------------------------------------------------
Craig B. Markwardt, Ph.D.         EMAIL:    craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
--------------------------------------------------------------------------