## Revision 304

trunk/contrib/statslib/dnorm.cpp (revision 304)
21 21
* where \f$\mu\f$ is the mean and \f$\sigma\f$

22 22
* is the standard deviation.

23 23
*

24
* The concentrated likelihood is implemented as:

25
* \f[

26
*  0.5 n \ln(\sum_{i=1}^{n}\epsilon^2)

27
* \f]

28
* where \f$\epsilon \f$ is a vector of residuals with an assumed mean 0.

24 29
*

25
*

26 30
*/

27 31

28 32
/**

......
187 191
}

188 192

189 193

194

190 195
/**

191 196
	\author Steven James Dean Martell

192 197
	\date 2011-06-21

193 198
	\param  residual a variable vector of residuals

199
	\return returns the concentrated likelihood for the normal distribution.

200
	\sa

201
**/

202
dvariable dnorm( const dvar_vector& residual )

203
{

204
	RETURN_ARRAYS_INCREMENT();

205
	int n              = size_count(residual);

206
	dvariable SS       = norm2(residual);

207
	dvariable nloglike = 0.5*n*log(SS);

208
	RETURN_ARRAYS_DECREMENT();

209
	return(nloglike);

210
}

211

212
/**

213
	\author Steven James Dean Martell

214
	\date 2011-06-21

215
	\param  obs a matrix of observed values

216
	\param  pred a variable matrix of predicted values

217
	\return returns the concentrated likelihood for the normal distribution.

218
	\sa

219
**/

220
dvariable dnorm( const dmatrix& obs, const dvar_matrix& pred)

221
{

222
	RETURN_ARRAYS_INCREMENT();

223
	int n = size_count(obs);

224
	dvariable SS = sum(elem_div(square(obs-pred),0.01+pred));

225
	RETURN_ARRAYS_DECREMENT();

226
	return 0.5*n*log(SS);

227
}

228

229

230

231
/**

232
	\author Steven James Dean Martell

233
	\date 2011-06-21

234
	\param  residual a variable vector of residuals

194 235
	\param  std a variable vector of standard deviations

195 236
	\return returns the sum of negative loglikelihoods of the normal distribution

196 237
	\sa

trunk/contrib/statslib/vcubicspline.cpp (revision 304)
78 78
   ptr=0;

79 79
 }

80 80

81

82

83

84
/**

85
	\author Steven James Dean Martell

86
	\date 2011-06-21

87
	\brief A Wrapper for the vcubic_spline_function

88
	\param  spline_nodes a vector of spline knots

89
	\param  ip is a vector of interpreted points

90
	\return returns a vector of interpreted points

91
	\sa

92
**/

93
dvar_vector cubic_spline(const dvar_vector& spline_nodes, const dvector& ip)

94
{

95
	RETURN_ARRAYS_INCREMENT();

96
	int nodes=size_count(spline_nodes);

97
	dvector ia(1,nodes);

98
	ia.fill_seqadd(0,1./(nodes-1));

99
	dvector fa = (ip-min(ip))/(max(ip)-min(ip));

100
	vcubic_spline_function ffa(ia,spline_nodes);

101
	RETURN_ARRAYS_DECREMENT();

102
	return(ffa(fa));

103
}

104

105

106

81 107
void bicubic_spline(const dvector& x, const dvector& y, dvar_matrix& knots, dvar_matrix& S)

... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff