跳至內容

File:Polyreg scheffe.svg

頁面內容不支援其他語言。
這個檔案來自維基共享資源
維基百科,自由的百科全書

原始檔案(SVG 檔案,表面大小:540 × 360 像素,檔案大小:40 KB)


摘要

描述
English: Plot of a cubic polynomial fit using multiple least squares to a simulated data set. Along with the point estimate, a 95% simultaneous confidence band (CB) constructed using Scheffe's method is shown.
日期
來源 自己的作品
作者 Skbkekas
其他版本

[編輯]

SVG開發
InfoField
 
SVG檔案的原始碼通過W3C驗證
 
vector image使用Matplotlib創作。
 
The file size of this SVG plot may be irrationally large because its text has been converted to paths inhibiting translations.
原始碼
InfoField

Python code

import numpy as np
import matplotlib.pyplot as plt
import scipy.special as sp

## Sample size.
n = 100

## Predictor values.
XV = np.random.uniform(low=-4, high=4, size=n)
XV.sort()

## Design matrix.
X = np.ones((n,4))
X[:,1] = XV
X[:,2] = XV**2
X[:,3] = XV**3

## True coefficients.
beta = np.array([0, 0.1, -0.25, -0.25], dtype=np.float64)

## True response values.
EY = np.dot(X, beta)

## Observed response values.
Y = EY + np.random.normal(size=n)*np.sqrt(20)

## Get the coefficient estimates.
u,s,vt = np.linalg.svd(X,0)
v = np.transpose(vt)
bhat = np.dot(v, np.dot(np.transpose(u), Y)/s)

## The fitted values.
Yhat = np.dot(X, bhat)

## The MSE and RMSE.
MSE = ((Y-EY)**2).sum()/(n-X.shape[1])
s = np.sqrt(MSE)

## These multipliers are used in constructing the Scheffe interval.
XtX = np.dot(np.transpose(X), X)
V = [np.dot(X[i,:], np.linalg.solve(XtX, X[i,:])) for i in range(n)]
V = np.array(V)

## The F quantile used in constructing the Scheffe interval.
QF = sp.fdtri(X.shape[1], n-X.shape[1], 0.95)

## The lower and upper bounds of the confidence band.
D = s*np.sqrt(X.shape[1]*QF*V)
LB,UB = Yhat-D,Yhat+D

## Make the plot.
plt.clf()
plt.plot(XV, Y, 'o', ms=3, color='grey')
plt.plot(XV, EY, '-', color='blue', label = "Truth")
plt.plot(XV, Yhat, '-', color='green', label = "Estimate")
plt.plot(XV, LB, '-', color='red', label = "CB")
plt.plot(XV, UB, '-', color='red')
plt.legend(frameon=False)
plt.ylim([-25,20])
plt.gca().set_yticks([-20,-10,0,10,20])
plt.xlim([-4,4])
plt.gca().set_xticks([-4,-2,0,2,4])
plt.xlabel("X")
plt.ylabel("Y")
plt.savefig("polyreg_scheffe.pdf")
plt.savefig("polyreg_scheffe.svg")

授權條款

我,本作品的著作權持有者,決定用以下授權條款發佈本作品:
w:zh:創用CC
姓名標示
此檔案採用創用CC 姓名標示 3.0 未在地化版本授權條款。
您可以自由:
  • 分享 – 複製、發佈和傳播本作品
  • 重新修改 – 創作演繹作品
惟需遵照下列條件:
  • 姓名標示 – 您必須指名出正確的製作者,和提供授權條款的連結,以及表示是否有對內容上做出變更。您可以用任何合理的方式來行動,但不得以任何方式表明授權條款是對您許可或是由您所使用。

說明

添加單行說明來描述出檔案所代表的內容

在此檔案描寫的項目

描繪內容

創用CC姓名標示3.0未本地化 繁體中文 (已轉換拼寫)

image/svg+xml

檔案歷史

點選日期/時間以檢視該時間的檔案版本。

日期/時間縮⁠圖尺寸使用者備⁠註
目前2021年3月8日 (一) 15:27於 2021年3月8日 (一) 15:27 版本的縮圖540 × 360(40 KB)Olexa RiznykFixed Confidence band ("CB") label
2009年4月9日 (四) 21:00於 2009年4月9日 (四) 21:00 版本的縮圖341 × 288(51 KB)SkbkekasAdded axis labels.
2009年4月9日 (四) 20:54於 2009年4月9日 (四) 20:54 版本的縮圖341 × 288(51 KB)Skbkekas{{Information |Description={{en|1=Plot of a cubic polynomial fit using multiple least squares to a simulated data set.}} |Source=Own work by uploader |Author=Skbkekas |Date=April 9, 2009 |Permission= |other_versions= }} <!--{{ImageUploa

下列頁面有用到此檔案:

全域檔案使用狀況

以下其他 wiki 使用了這個檔案:

詮釋資料