# Spring DAO with Jdbc and Hibernate

tanglei198577 分享于

一：简介      1.定义：spring的dao不是新发明一种技术，而是对原来技术的一种封装，定义了一套          简单实用的api      2.使用dao的好处：降低了业务逻

up vote 2 down vote favorite I was reading a paper which looked at investigating trends in monthly wind speed data for the past 20 years or so. The paper uses a number of different statistical approaches, which I am trying to replicate here. The first method used is a simple linear regression model of the form $$y(t) = a_{1}t + b_{1}$$ where $a_{1}$ and $b_{1}$ can be determined by standard least squares. Then they specify that some of the potential error in the linear regression model can be removed explicitly by accounting for the seasonal signal by fitting a model of the form: $$y(t) = a_{2}t + b_{2}\sin\left(\frac{2\pi}{12t} + c_{2}\right) + d_{2}$$ where coefficients $a_{2}$, $b_{2}$, $c_{2}$, and $d_{2}$ can be determined by least squares. They then go on to specify that this model was also tested with additional harmonic components of 3, 4, and 6 months. Using the following data as an example:

%

1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960y = [112

115

145

171

196

204

242

284

315

340

360

417

% Jan

118

126

150

180

196

188

233

277

301

318

342

391

% Feb

132

141

178

193

236

235

267

317

356

362

406

419

% Mar

129

135

163

181

235

227

269

313

348

348

396

461

% Apr

121

125

172

183

229

234

270

318

355

363

420

472

% May

135

149

178

218

243

264

315

374

422

435

472

535

% Jun

148

170

199

230

264

302

364

413

465

491

548

622

% Jul

148

170

199

242

272

293

347

405

467

505

559

606

% Aug

136

158

184

209

237

259

312

355

404

404

463

508

% Sep

119

133

162

191

211

229

274

306

347

359

407

461

% Oct

104

114

146

172

180

203

237

271

305

310

362

390

% Nov

118

140

166

194

201

229

278

306

336

337

405

432 ]; % Dectime = datestr(datenum(yr(:),mo(:),1));jday = datenum(time,'dd-mmm-yyyy');y2 = reshape(y,[],1);plot(jday,y2) Can anyone demonstrate how the model above can be written in matlab? matlab least-squares share | improve this question asked Jan 27 '15 at 13:23 Emma Tebbs 652 1 5 13 migrated from stats.stackexchange.com Jan 27 '15 at 16:28 This question came from our site for people interested in statistics, machine learning, data analysis, data mining, and data visualization.

Have a look on

1 Spring配置文件，applicationContext-db.xml

<xml version="1.0" encoding="UTF-8">

how to do least squares on matlab: uk.mathworks.com/help/curvefit/least-squares-fitting.html –

Ander Biguri Jan 27 '15 at 16:29

What you could do is calculating all the combinations of t, and fit them into a linear regression. –

Yang Zhang Jan 27 '15 at 18:45

You could expand the sin() term into a power series and then do a regular least squares fit for a polynomial. –

AnonSubmitter85 Jan 27 '15 at 20:04 add a comment

|

1 Answer 1 active oldest votes up vote 2 down vote Notice that your model is actually linear, we can use a trigonometric identity to show that. To use a nonlinear model use nlinfit. Using your data I wrote the following script to compute and compare the different methods: (you can comment out the opts.RobustWgtFun = 'bisquare'; line to see that it's exactly like the linear fit with the 12 periodicity) % y = [112

115 ...y2 = reshape(y,[],1);t=(1:144).';% trendT = [ones(size(t)) t];B=T\y2;y_trend = T*B;% least squeare, using linear fit and the 12 periodicity onlyT = [ones(size(t)) t sin(2*pi*t/12) cos(2*pi*t/12)];B=T\y2;y_sincos = T*B;% least squeare, using linear fit and 3,4,6,12 periodicitiesaddharmonics = [3 4 6];T = [T bsxfun(@(h,t)sin(2*pi*t/h),addharmonics,t) bsxfun(@(h,t)cos(2*pi*t/h),addharmonics,t)];B=T\y2;y_sincos2 = T*B;% least squeare with bisquare weights, % using non-linear model of a linear fit and the 12 periodicity onlyopts = statset('nlinfit');opts.RobustWgtFun = 'bisquare';b0 = [1;1;0;1];modelfun = @(b,x) b(1)*x+b(2)*sin((b(3)+x)*2*pi/12)+b(4);b = nlinfit(t,y2,modelfun,b0,opts);% plot a comparisonfigureplot(t,y2,t,y_trend,t,modelfun(b,t),t,y_sincos,t,y_sincos2)legend('Original','Trend','bisquare weight - 12 periodicity only', ...

'least square - 12 periodicity only','least square - 3,4,6,12 periodicities', ...

'Location','NorthWest');xlim(minmax(t')); share | improve this answer edited Feb 11 '15 at 1:59 answered Feb 11 '15 at 0:53 dvb 1,162 8 23 add a comment

|

Spring DAO之JDBC     Spring提供的DAO(数据访问对象)支持主要的目的是便于以标准的方式使用不同的数据访问技术， 如JDBC，Hibernate或者JDO等。它不仅可以让

up vote 2 down vote favorite I was reading a paper which looked at investigating trends in monthly wind speed data for the past 20 years or so. The paper uses a number of different

×
• 登录
• 注册

×