跳到主要內容

貸款投資0050好嗎?

如果貸款利率很低,貸款投資很好,這也難怪低利環境下股票比較貴,為了找到答案我來做一個實驗,在2008年0050最高點時貸款,將全數貸款金額全數買入0050,看看最後結果如何。

回到「數據研究」頁面

模擬情境:

  • 0050股利在除息日完成再投資。
  • 0050高點為2007年10月11日的每股71.9元。
  • 每月定期賣股還債,貸款用本息平均攤還。
  • 股票賣完如果貸款還沒還完,要自己掏錢還。
  • *代表股利再投資。

貸款7年,利率2%

  • 貸款7年,利率2%,貸款100萬,月付金為12,767元。
  • 在2013/03/11時,0050賣完,當期還要貼12,064元。
  • 還剩下19期沒繳,所以還要貼12,767 x 19 + 12,064 = 254,637元。

計算表

日期0050股價股數現值
2007/10/1171.9013,908.211,000,000
2007/10/2467.7014,421.80976,356
2007/11/1263.6014,221.06904,460
2007/12/1162.3514,016.30873,916
2008/01/1157.6513,794.84795,273
2008/02/1254.9513,562.51745,260
2008/03/1160.1013,350.08802,340
2008/04/1163.5013,149.02834,963
2008/05/1262.7012,945.40811,677
2008/06/1159.9012,732.26762,662
2008/07/1152.9012,490.92660,770
2008/08/1155.6012,261.30681,728
2008/09/1148.3711,997.35580,312
2008/10/0940.2411,680.08470,006
2008/10/2432.3412,402.41401,094
2008/11/1133.4612,020.85402,218
2008/12/1133.8011,643.13393,538
2009/01/1032.0111,244.29359,930
2009/02/1133.2510,860.32361,105
2009/03/1134.2510,487.56359,199
2009/04/1039.9710,168.14406,421
2009/05/1146.209,891.80457,001
2009/06/1145.259,609.66434,837
2009/07/1046.789,336.74436,773
2009/08/1148.429,073.07439,318
2009/09/1152.508,829.89463,569
2009/10/1253.608,591.70460,515
2009/10/2353.258,753.04466,100
2009/11/1153.858,515.96458,584
2009/12/1153.858,278.87445,817
2010/01/1157.908,058.37466,580
2010/02/1052.107,813.33407,074
2010/03/1153.657,575.36406,418
2010/04/1255.457,345.11407,287
2010/05/1152.207,100.54370,648
2010/06/1149.626,843.24339,562
2010/07/1252.306,599.13345,134
2010/08/1154.706,598.81360,955
2010/09/1055.256,367.74351,817
2010/10/1156.956,143.56349,876
2010/10/2556.106,384.48358,169
2010/11/1157.506,162.45354,341
2010/12/1059.305,947.15352,666
2011/01/1160.855,737.34349,117
2011/02/1158.905,520.58325,162
2011/03/1158.855,303.64312,119
2011/04/1161.105,094.69311,285
2011/05/1162.054,888.94303,358
2011/06/1060.554,678.08283,258
2011/07/1159.654,464.05266,281
2011/08/1154.104,228.06228,738
2011/09/0954.153,992.29216,183
2011/10/1153.003,751.41198,825
2011/10/2652.153,891.68202,951
2011/11/1150.903,640.85185,319
2011/12/1248.803,379.24164,907
2012/01/1150.653,127.17158,391
2012/02/1053.952,890.53155,944
2012/03/1254.352,655.62144,333
2012/04/1153.302,416.09128,778
2012/05/1151.152,166.49110,816
2012/06/1148.991,905.8993,370
2012/07/1150.551,653.3383,576
2012/08/1052.801,411.5374,529
2012/09/1153.301,172.0062,467
2012/10/1153.30932.4749,700
2012/10/2451.00966.2949,281
2012/11/1250.90715.4736,417
2012/12/1153.65477.5025,618
2013/01/1154.45243.0313,233
2013/02/0655.412.57697
2013/03/1155.90-12,070

貸款10年,利率2%

  • 貸款10年,利率2%,貸款100萬,月付金為9,201元。
  • 在2015/12/11時,0050賣完,當期還要貼1,761元。
  • 還剩下22期沒繳,所以還要貼9,201 x 22 + 1,761 = 204,183元。

計算表

日期0050股價股數現值
2007/10/1171.9013,908.211,000,000
2007/10/2467.7014,421.80976,356
2007/11/1263.6014,277.13908,026
2007/12/1162.3514,129.56880,978
2008/01/1157.6513,969.96805,368
2008/02/1254.9513,802.52758,448
2008/03/1160.1013,649.42820,330
2008/04/1163.5013,504.53857,537
2008/05/1262.7013,357.78837,533
2008/06/1159.9013,204.17790,930
2008/07/1152.9013,030.24689,300
2008/08/1155.6012,864.76715,280
2008/09/1148.3712,674.54613,067
2008/10/0940.2412,445.88500,822
2008/10/2432.3413,215.57427,392
2008/11/1133.4612,940.59432,992
2008/12/1133.8012,668.37428,191
2009/01/1032.0112,380.93396,313
2009/02/1133.2512,104.20402,465
2009/03/1134.2511,835.56405,368
2009/04/1039.9711,605.36463,866
2009/05/1146.2011,406.21526,967
2009/06/1145.2511,202.87506,930
2009/07/1046.7811,006.19514,869
2009/08/1148.4210,816.16523,718
2009/09/1152.5010,640.90558,647
2009/10/1253.6010,469.24561,151
2009/10/2353.2510,665.85567,956
2009/11/1153.8510,494.98565,155
2009/12/1153.8510,324.12555,954
2010/01/1157.9010,165.21588,566
2010/02/1052.109,988.61520,406
2010/03/1153.659,817.11526,688
2010/04/1255.459,651.17535,158
2010/05/1152.209,474.91494,590
2010/06/1149.629,289.48460,944
2010/07/1252.309,113.55476,639
2010/08/1154.709,113.32498,499
2010/09/1055.258,946.79494,310
2010/10/1156.958,785.23500,319
2010/10/2556.109,129.75512,179
2010/11/1157.508,969.73515,759
2010/12/1059.308,814.57522,704
2011/01/1160.858,663.36527,165
2011/02/1158.908,507.15501,071
2011/03/1158.858,350.80491,445
2011/04/1161.108,200.21501,033
2011/05/1162.058,051.93499,622
2011/06/1060.557,899.97478,343
2011/07/1159.657,745.72462,032
2011/08/1154.107,575.65409,842
2011/09/0954.157,405.73401,020
2011/10/1153.007,232.13383,303
2011/10/2652.157,502.55391,258
2011/11/1150.907,321.78372,679
2011/12/1248.807,133.24348,102
2012/01/1150.656,951.58352,098
2012/02/1053.956,781.03365,837
2012/03/1254.356,611.74359,348
2012/04/1153.306,439.12343,205
2012/05/1151.156,259.23320,160
2012/06/1148.996,071.42297,439
2012/07/1150.555,889.40297,709
2012/08/1052.805,715.14301,759
2012/09/1153.305,542.51295,416
2012/10/1153.305,369.89286,215
2012/10/2451.005,564.68283,799
2012/11/1250.905,383.91274,041
2012/12/1153.655,212.41279,646
2013/01/1154.455,043.43274,615
2013/02/0655.404,877.35270,205
2013/03/1155.904,712.75263,443
2013/04/1154.354,543.46246,937
2013/05/1057.904,384.55253,865
2013/06/1156.354,221.26237,868
2013/07/1157.204,060.41232,255
2013/08/1255.003,893.11214,121
2013/09/1157.503,733.10214,653
2013/10/1158.453,575.68208,999
2013/10/2457.553,659.56210,608
2013/11/1156.303,496.13196,832
2013/12/1157.853,337.08193,050
2014/01/1057.553,177.20182,848
2014/02/1156.953,015.64171,741
2014/03/1159.352,860.61169,777
2014/04/1161.152,710.14165,725
2014/05/1261.152,559.68156,524
2014/06/1164.152,416.25155,002
2014/07/1168.302,281.53155,829
2014/08/1166.052,142.23141,494
2014/09/1168.402,007.71137,328
2014/10/1364.001,863.95119,293
2014/10/2463.051,909.77120,411
2014/11/1165.951,770.26116,748
2014/12/1165.251,629.24106,308
2015/01/1265.751,489.3097,922
2015/02/1169.001,355.9693,561
2015/03/1169.051,222.7184,428
2015/04/1069.651,090.6075,960
2015/05/1170.85960.7468,068
2015/06/1168.85827.1056,946
2015/07/1368.10691.9947,124
2015/08/1164.55549.4535,467
2015/09/1163.50404.5525,689
201510/1265.55264.1817,317
2015/10/2664.55272.3717,581
2015/11/1162.15124.327,727
2015/12/1159.850-1,761

貸款14年,利率2%

  • 貸款14年,利率2%,貸款100萬,月付金為6,829元。
  • 在2020/11/11時,0050賣完,當期還要貼4,149元。
  • 還剩下11期沒繳,所以還要貼6,829 x 11 + 4,149 = 79,268元。

計算表

日期0050股價股數現值
2007/10/1171.9013,908.211,000,000
2007/10/2467.7014,421.80976,356
2007/11/1263.6014,314.43910,398
2007/12/1162.3514,204.90885,676
2008/01/1157.6514,086.45812,084
2008/02/1254.9513,962.17767,221
2008/03/1160.1013,848.54832,297
2008/04/1163.5013,741.00872,553
2008/05/1262.7013,632.08854,732
2008/06/1159.9013,518.08809,733
2008/07/1152.9013,388.98708,277
2008/08/1155.6013,266.16737,598
2008/09/1148.3713,124.98634,855
2008/10/0940.2412,955.27521,320
2008/10/2432.3413,756.46444,884
2008/11/1133.4613,552.37453,462
2008/12/1133.8013,350.33451,241
2009/01/1032.0113,136.99420,515
2009/02/1133.2512,931.60429,976
2009/03/1134.2512,732.22436,078
2009/04/1039.9712,561.36502,078
2009/05/1146.2012,413.55573,506
2009/06/1145.2512,262.63554,884
2009/07/1046.7812,116.65566,817
2009/08/1148.4211,975.61579,859
2009/09/1152.5011,845.54621,891
2009/10/1253.6011,718.13628,092
2009/10/2353.2511,938.19635,709
2009/11/1153.8511,811.38636,043
2009/12/1153.8511,684.56629,214
2010/01/1157.9011,566.62669,707
2010/02/1052.1011,435.54595,792
2010/03/1153.6511,308.25606,688
2010/04/1255.4511,185.10620,214
2010/05/1152.2011,054.27577,033
2010/06/1149.6210,916.65541,684
2010/07/1252.3010,786.07564,112
2010/08/1154.7010,785.90589,989
2010/09/1055.2510,662.30589,092
2010/10/1156.9510,542.39600,389
2010/10/2556.1010,955.82614,621
2010/11/1157.5010,837.05623,130
2010/12/1059.3010,721.89635,808
2011/01/1160.8510,609.66645,598
2011/02/1158.9010,493.72618,080
2011/03/1158.8510,377.68610,727
2011/04/1161.1010,265.91627,247
2011/05/1162.0510,155.86630,171
2011/06/1060.5510,043.08608,108
2011/07/1159.659,928.59592,240
2011/08/1154.109,802.36530,308
2011/09/0954.159,676.25523,969
2011/10/1153.009,547.40506,012
2011/10/2652.159,904.40516,514
2011/11/1150.909,770.23497,305
2011/12/1248.809,630.29469,958
2012/01/1150.659,495.47480,945
2012/02/1053.959,368.89505,451
2012/03/1254.359,243.24502,370
2012/04/1153.309,115.11485,836
2012/05/1151.158,981.60459,409
2012/06/1148.998,842.21433,180
2012/07/1150.558,707.11440,145
2012/08/1052.808,577.78452,907
2012/09/1153.308,449.65450,367
2012/10/1153.308,321.53443,538
2012/10/2451.008,623.39439,793
2012/11/1250.908,489.22432,102
2012/12/1153.658,361.94448,618
2013/01/1154.458,236.52448,478
2013/02/0655.408,113.25449,474
2013/03/1155.907,991.09446,702
2013/04/1154.357,865.44427,487
2013/05/1057.907,747.49448,580
2013/06/1156.357,626.30429,742
2013/07/1157.207,506.92429,396
2013/08/1255.007,382.75406,051
2013/09/1157.507,263.99417,679
2013/10/1158.457,147.15417,751
2013/10/2457.557,314.81420,967
2013/11/1156.307,193.51404,995
2013/12/1157.857,075.47409,316
2014/01/1057.556,956.80400,364
2014/02/1156.956,836.89389,361
2014/03/1159.356,721.83398,941
2014/04/1161.156,610.15404,211
2014/05/1261.156,498.48397,382
2014/06/1164.156,392.02410,048
2014/07/1168.306,292.04429,746
2014/08/1166.056,188.65408,760
2014/09/1168.406,088.81416,474
2014/10/1364.005,982.10382,855
2014/10/2463.056,129.17386,444
2014/11/1165.956,025.62397,390
2014/12/1165.255,920.96386,343
2015/01/1265.755,817.10382,474
2015/02/1169.005,718.12394,551
2015/03/1169.055,619.23388,008
2015/04/1069.655,521.18384,550
2015/05/1170.855,424.79384,346
2015/06/1168.855,325.60366,668
2015/07/1368.105,225.33355,845
2015/08/1164.555,119.53330,466
2015/09/1163.505,011.99318,261
2015/10/1265.554,907.81321,707
2015/10/2664.555,059.87326,615
2015/11/1162.154,949.99307,642
2015/12/1159.854,835.89289,428
2016/01/1156.554,715.13266,641
2016/02/0358.954,599.29271,128
2016/03/1163.554,491.83285,456
2016/04/1163.004,383.43276,156
2016/05/1159.854,269.33255,519
2016/06/0865.254,164.67271,745
2016/07/1167.004,062.74272,204
2016/07/2869.054,112.76283,986
2016/08/1169.954,015.13280,858
2016/09/1069.403,916.73271,821
2016/10/1171.453,821.15273,021
2016/11/1170.053,723.66260,843
2016/12/0973.153,630.31265,557
2017/01/1172.403,535.98256,005
2017/02/1072.803,442.18250,591
2017/03/1072.003,347.33241,008
2017/04/1173.903,254.92240,539
2017/05/1176.503,165.65242,173
2017/06/0978.003,078.10240,092
2017/07/1181.552,994.36244,190
2017/07/3181.353,020.13245,688
2017/08/1181.252,936.08238,557
2017/09/1182.552,853.35235,544
2017/10/1183.402,771.47231,141
2017/11/0984.402,690.56227,083
2017/12/1181.502,606.77212,452
2018/01/1183.402,524.89210,575
2018/01/2985.552,589.82221,559
2018/02/0979.052,503.43197,896
2018/03/0982.852,421.00200,580
2018/04/1182.852,338.58193,751
2018/05/1181.602,254.89183,999
2018/06/1182.652,172.26179,537
2018/07/1181.702,088.67170,645
2018/07/2384.552,105.97178,060
2018/08/1085.702,026.28173,652
2018/09/1185.651,946.55166,722
2018/10/1177.401,858.32143,834
2018/11/0977.801,770.54137,748
2018/12/1175.051,679.55126,050
2019/01/1175.501,589.10119,977
2019/01/2274.051,638.46121,328
2019/02/1175.151,547.59116,301
2019/03/1176.151,457.91111,020
2019/04/1181.151,373.76111,480
2019/05/1081.501,289.96105,132
2019/06/1179.401,203.9695,594
2019/07/1182.851,121.5392,919
2019/07/1983.001,130.9993,872
2019/08/0880.651,046.3284,385
2019/09/1183.45964.4880,486
2019/10/0985.80884.8975,924
2019/11/1191.15809.9773,829
2019/12/1193.75737.1369,106
2020/01/1097.30666.9464,893
2020/01/3189.95688.4461,926
2020/02/1191.75614.0156,336
2020/03/1185.30533.9545,546
2020/04/1079.30447.8435,514
2020/05/1185.05367.5431,260
2020/06/1189.05290.8625,901
2020/07/1094.65218.7120,701
2020/07/2198.70220.2621,740
2020/08/11104.80155.1016,254
2020/09/11103.2588.969,185
2020/10/08106.2024.652,618
2020/11/11108.750-4,149

貸款14年,利率1.63%

  • 貸款14年,利率1.63%,貸款100萬,月付金為6,661元。
  • 在2021/08/11時,0050還沒賣完,現值為7,131元,剩2期沒繳,應該還要貼一點錢。
日期0050股價股數現值
2007/10/1171.9013,908.211,000,000
2007/10/2467.7014,421.80976,356
2007/11/1263.6014,317.07910,566
2007/12/1162.3514,210.24886,008
2008/01/1157.6514,094.70812,559
2008/02/1254.9513,973.48767,843
2008/03/1160.1013,862.64833,145
2008/04/1163.5013,757.75873,617
2008/05/1262.7013,651.51855,950
2008/06/1159.9013,540.31811,065
2008/07/1152.9013,414.39709,621
2008/08/1155.6013,294.59739,179
2008/09/1148.3713,156.88636,398
2008/10/0940.2412,991.35522,772
2008/10/2432.3413,794.77446,123
2008/11/1133.4613,595.70454,912
2008/12/1133.8013,398.63452,874
2009/01/1032.0113,190.54422,229
2009/02/1133.2512,990.21431,924
2009/03/1134.2512,795.72438,254
2009/04/1039.9712,629.07504,784
2009/05/1146.2012,484.90576,802
2009/06/1145.2512,337.69558,281
2009/07/1046.7812,195.30570,496
2009/08/1148.4212,057.73583,836
2009/09/1152.5011,930.86626,370
2009/10/1253.6011,806.59632,833
2009/10/2353.2512,028.31640,507
2009/11/1153.8511,904.61641,063
2009/12/1153.8511,780.91634,402
2010/01/1157.9011,665.87675,454
2010/02/1052.1011,538.02601,131
2010/03/1153.6511,413.86612,354
2010/04/1255.4511,293.74626,238
2010/05/1152.2011,166.13582,872
2010/06/1149.6211,031.89547,403
2010/07/1252.3010,904.53570,307
2010/08/1154.7010,904.37596,469
2010/09/1055.2510,783.81595,805
2010/10/1156.9510,666.84607,477
2010/10/2556.1011,085.15621,877
2010/11/1157.5010,969.31630,735
2010/12/1059.3010,856.98643,819
2011/01/1160.8510,747.51653,986
2011/02/1158.9010,634.42626,368
2011/03/1158.8510,521.24619,175
2011/04/1161.1010,412.22636,187
2011/05/1162.0510,304.87639,417
2011/06/1060.5510,194.86617,299
2011/07/1159.6510,083.20601,463
2011/08/1154.109,960.07538,840
2011/09/0954.159,837.06532,677
2011/10/1153.009,711.38514,703
2011/10/2652.1510,074.51525,386
2011/11/1150.909,943.65506,132
2011/12/1248.809,807.15478,589
2012/01/1150.659,675.64490,071
2012/02/1053.959,552.17515,340
2012/03/1254.359,429.62512,500
2012/04/1153.309,304.65495,938
2012/05/1151.159,174.42469,272
2012/06/1148.999,038.45442,794
2012/07/1150.558,906.68450,233
2012/08/1052.808,780.53463,612
2012/09/1153.308,655.56461,341
2012/10/1153.308,530.58454,680
2012/10/2451.008,840.03450,841
2012/11/1250.908,709.16443,296
2012/12/1153.658,585.01460,586
2013/01/1154.458,462.67460,793
2013/02/0655.408,342.44462,171
2013/03/1155.908,223.28459,681
2013/04/1154.358,100.72440,274
2013/05/1057.907,985.68462,371
2013/06/1156.357,867.47443,332
2013/07/1157.207,751.02443,358
2013/08/1255.007,629.91419,645
2013/09/1157.507,514.07432,059
2013/10/1158.457,400.11432,536
2013/10/2457.557,573.70435,866
2013/11/1156.307,455.39419,738
2013/12/1157.857,340.24424,633
2014/01/1057.557,224.50415,770
2014/02/1156.957,107.54404,774
2014/03/1159.356,995.30415,171
2014/04/1161.156,886.38421,102
2014/05/1261.156,777.45414,441
2014/06/1164.156,673.61428,112
2014/07/1168.306,576.09449,147
2014/08/1166.056,475.24427,690
2014/09/1168.406,377.86436,245
2014/10/1364.006,273.78401,522
2014/10/2463.056,428.01405,286
2014/11/1165.956,327.01417,266
2014/12/1165.256,224.93406,176
2015/01/1265.756,123.62402,628
2015/02/1169.006,027.08415,869
2015/03/1169.055,930.61409,509
2015/04/1069.655,834.98406,406
2015/05/1170.855,740.96406,747
2015/06/1168.855,644.22388,604
2015/07/1368.105,546.41377,710
2015/08/1164.555,443.21351,359
2015/09/1163.505,338.32338,983
2015/10/1265.555,236.70343,266
2015/10/2664.555,398.95348,502
2015/11/1162.155,291.78328,884
2015/12/1159.855,180.48310,052
2016/01/1156.555,062.69286,295
2016/02/0358.954,949.70291,785
2016/03/1163.554,844.88307,892
2016/04/1163.004,739.15298,567
2016/05/1159.854,627.86276,977
2016/06/0865.254,525.77295,307
2016/07/1167.004,426.35296,566
2016/07/2869.054,480.84309,402
2016/08/1169.954,385.62306,774
2016/09/1069.404,289.64297,701
2016/10/1171.454,196.41299,834
2016/11/1170.054,101.32287,298
2016/12/0973.154,010.26293,351
2017/01/1172.403,918.26283,682
2017/02/1072.803,826.76278,588
2017/03/1072.003,734.25268,866
2017/04/1173.903,644.11269,300
2017/05/1176.503,557.04272,114
2017/06/0978.003,471.64270,788
2017/07/1181.553,389.96276,452
2017/07/3181.353,419.13278,147
2017/08/1181.253,337.15271,144
2017/09/1182.553,256.46268,821
2017/10/1183.403,176.59264,928
2017/11/0984.403,097.67261,444
2017/12/1181.503,015.94245,799
2018/01/1183.402,936.07244,869
2018/01/2985.553,011.58257,641
2018/02/0979.052,927.32231,404
2018/03/0982.852,846.92235,867
2018/04/1182.852,766.52229,206
2018/05/1181.602,684.89219,087
2018/06/1182.652,604.30215,245
2018/07/1181.702,522.77206,110
2018/07/2384.552,543.65215,066
2018/08/1085.702,465.93211,330
2018/09/1185.652,388.16204,546
2018/10/1177.402,302.10178,182
2018/11/0977.802,216.48172,442
2018/12/1175.052,127.73159,686
2019/01/1175.502,039.50153,982
2019/01/2274.052,102.85155,716
2019/02/1175.152,014.21151,368
2019/03/1176.151,926.74146,721
2019/04/1181.151,844.66149,694
2019/05/1081.501,762.93143,679
2019/06/1179.401,679.04133,315
2019/07/1182.851,598.64132,447
2019/07/1983.001,612.12133,806
2019/08/0880.651,529.53123,357
2019/09/1183.451,449.71120,978
2019/10/0985.801,372.07117,724
2019/11/1191.151,299.00118,404
2019/12/1193.751,227.95115,120
2020/01/1097.301,159.49112,818
2020/01/3189.951,196.87107,658
2020/02/1191.751,124.27103,152
2020/03/1185.301,046.1889,239
2020/04/1079.30962.1876,301
2020/05/1185.05883.8775,173
2020/06/1189.05809.0772,047
2020/07/1094.65738.6969,917
2020/07/2198.70743.9373,426
2020/08/11104.80680.3771,303
2020/09/11103.25615.8663,587
2020/10/08106.20553.1458,743
2020/11/11108.75491.8853,492
2020/12/11118.75435.7951,750
2021/01/11132.30385.4450,994
2021/01/22137.45394.0054,155
2021/02/05134.80344.5846,450
2021/03/11134.70295.1339,754
2021/04/09137.95246.8534,053
2021/05/11133.25196.8626,231
2021/06/11138.10148.6320,525
2021/07/09137.75100.2713,812
2021/07/21136.70100.5313,742
2021/08/11137.2051.987,131

結論

以上模擬都是在運氣非常不好的時刻開始貸款投資的,即使如此,在利率為1.63%,貸款期限為14年的狀況下,都可以幾乎打平成本,換句話說,只要貸款期限再拉長,利率再更低,就非常有機會賺錢。

留言

這個網誌中的熱門文章

母體變異數(population variance)、樣本變異數(sample variance)及自由度(degrees of freedom)

母體指的是所有的數據,樣本指的是從母體抽樣的數據,舉例來說,一個班級有40人,它們的身高,40個身高數據,若只針對這個班,就是母體,但是,卻只是代表全校學生身高的一部分,也就是樣本。 回到「機率統計」頁面 樣本平均數(mean)不是母體平均數,樣本變異數(variance)也不是母體變異數,一個班40個人身高的平均數很難剛好是全校學生的身高平均數。 一個班40個人的身高變異數也不會是全校學生的身高變異數。 變異數計算 母體變異數的定義如下: 而樣本變異數的定義如下: 奇怪的地方 平均數 雖然樣本平均數不是母體平均數,不過,如果不斷重複從同一個母體抽樣平均,會得到一個近似母體平均數的數字。舉例來說,從一個學校所有學生中,不斷隨機選出40個學生取平均數,再將這些平均數平均,結果會接近直接算全校學生的身高平均數。 也就是說樣本平均數的期望值就是母體平均數: 變異數 樣本變異數跟母體變異數就沒這麼單純了。奇怪的地方是,為什麼樣本變異數公式的除術是n-1,而不是像平均數計算一樣用n? 為何樣本變異數要除的是(n-1)? 除數為n的話,變異數會太小 如果樣本變異數的除數是n,樣本變異數就會常常比母體變異數小。為什麼呢? 因為,樣本是從母體抽取的,抽樣的數據算出平均,並且抽樣的數據會相對的接近抽樣的平均,總不會剛好抽出的樣本平均數剛好是母體平均數,且樣本數據離樣本平均數就像母體數據離母體平均數一樣分散吧? 假設母體數據為0-99的整數,共100個數據,從中選出10個數字,然後計算樣本的平均數,分別用n及n-1當作除數算出變異數,連續執行200次,並將200個樣本平均數及200個樣本變異數平均。 也就是取得樣本平均數及樣本變異數的期望值,結果如下: 母體平均數 = 49.5 ...

如何在Chart.js的圖上加上X軸或Y軸名稱

 Chart.js可以幫助網頁顯示各類圖表,要在X軸及Y軸上標示名稱方法如下: 找到Chart物件。 在Chart物件內找到options。 在options內找到scales,若無,自行加上scales。 即可在scales下設定X軸及Y軸的標示。 程式碼範例 <div> <canvas id="myChart"></canvas> </div> <script src="https://cdn.jsdelivr.net/npm/chart.js"></script> <script> const labels = [ '1', '2', '3', '4', '5', '6', ]; const data = { labels: labels, datasets: [{ label: '數據', backgroundColor: 'rgb(255, 99, 132)', borderColor: 'rgb(255, 99, 132)', data: [0, 10, 5, 2, 20, 30, 45], }] }; const config = { type: 'line', data, options: {scales:{ x:{ title:{ display:true, text:"月" } }, y:{ title:{ display:true, text:"unit" } } } } }; var myChart = new Chart( document.ge...

Blogger文章在Google搜尋引擎找不到,怎麼辦?

剛開始經營部落格,最令人不解及懊惱的其中一件事就是為什麼我的文章發布了,在Google搜尋引擎不管怎麼搜尋都找不到;文章找不到就沒辦法建立自然流量了。 回到「部落格經營血淚史」頁面 Google Search Console無法為Blogger建立索引,出現伺服器錯誤(5XX)⇨ 這是因為Google搜尋引擎還沒將新的文章或網頁放進去索引(index)裡。 可以用手動的方式,將新文章或網頁加入Goolge搜尋引擎索引裡。 首先,在Google搜尋「google search console」。 進去後,輸入網站網址如下圖,兩者選其一。 輸入網站網址並點點擊「繼續後」後,選擇「前往資源」。 視窗上側,找到「檢查XXX中的任何網址」,輸入要加入Google搜尋引擎索引的網頁(文章)網址。 如果該網頁不在Google搜尋引擎索引內,結果會出現「網址不在 Google 服務中」,這時需點擊「要求建立索引」。 這樣就完成了;大概過4-6天就會編入Google搜尋引擎索引了,不過,不需要一直重新提出建立索引的要求,因為這樣不會比較快編入索引。 如何提交Blogger Sitemap? 到Google Search Console的Sitemap,填入落格網址並加上 /sitemap.xml ,舉例來說,我的部落格就是https://quanist.blogspot.com/sitemap.xml,送出即可。 送出之後要等大約10分鐘,正常來說就會從「Couldn't fetch 」轉為顯示「成功」。 如何提交Blogger Atom Sitemap? 文章數少於500篇:到Google Search Console的Sitemap,填入部落格網址並加上 /atom.xml?redirect=false&start-index=1&max-results=500 ,舉例來說,我的部落格就是https://quanist.blogspot.com/atom.xml?redirect=false&start-index=1&max-results=500,送出即可。 文章數少於1000篇:到Google Search Cons...

中央極限定理(central limit theorem)證明

中央極限定理(central limit theorem )指的是從一個獨立同分布(Independent and identically distributed, i.i.d)取出之變數數量趨近無限多時,其平均數(mean)將趨近常態分布(normal distribution)。 回到「機率統計」頁面 目錄: 動差母函數(moment generating function) 常態分布的動差母函數 中央極限定理證明 中央極限定理模擬 中央極限定理應用 動差母函數(moment generating function) 動差母函數為機率密度函數(probability density fFunction, PDF)及累積分佈函數(cumulative distribution function CDF)之外,另一種描述機率分布模型的一種方式。 定義 M X (t) = E[e tx ] 而 e tx 的泰勒級數(Taylor series)為 e tx  = 1 + tx + t 2 x 2 /2! +  t 3 x 3 /3! + ... 則 M X (t) 的泰勒級數為 M X (t) = E[e tx ]  = 1 + tE[x] +  t 2 /2! E[x 2 ] +  t 3 /3! E[x 3 ] + ... 因此,當t = 0時,以t取 動差母函數m次微分,就可以找到其分布模型的第m動差。 特性 M X+Y (t) = E[e t(x+y) ] =  E[e tx+ty ] =  E[e tx e ty ]  =  E[e tx ]  E...

HYG、LQD 與 TLT 風險報酬比較

10 年期公債除了站上 4%,再撰寫這篇文章時,已經在 4.3% 徘迴,上次在 這篇文章 研究了現在是否應該要買 LQD 而不是 TLT,本篇文章我想研究非投資等級債是否更適合。 買點 HYG 現在 HYG 價格為 74.04,距離近一次低點 2020/3/20 的 69.75,差別為 5.794% LQD 上次低點在 2020/10/14 的 100.38 附近,與目前的 105.01 相差 4.612%。 TLT 上次低點在 2022/11/4 的 94.22 附近,與目前的 95.16相差 1%。 殖利率上升時,公司債的表現 TLT 2009-01-06 到 2010-01-05 跌了 16.364% 這段期間美國 30 年期公債殖利率從 3.04% 漲到  3.74%,漲了 0.7%。 TLT 2012-11-14 到 2013-11-13 跌了 15.701% 這段期間 美國 30 年期公債殖利率從 2.73% 漲到  3.83%,漲了 1.1%。 TLT 2016-07-29 到 2017-07-28 跌了 10.307% 這段期間 美國 30 年期公債殖利率從 2.18% 漲到  2.89%,漲了 0.71%。 TLT 2021-11-18 到 2023-8-15 跌了 32.695% 這段期間美國 30 年期公債殖利率從 1.97% 漲到  4.35%,漲了 2.38%。 結論 HYG 現在也很便宜,在公債殖利率還有可能持續上漲狀況下,表現可能勝過公債及投資等級公司債。

Google Search Console無法為Blogger建立索引,出現伺服器錯誤(5XX)

這幾天,我把我Blogger的網址改了幾次,為了測試Google是否有把我的網頁加進搜尋索引,我到了Google Search Console做了測試,結果出現錯誤,伺服器錯誤(5xx)! 回到「部落格經營」頁面 ⇦Blogger文章在Google搜尋引擎找不到,怎麼辦? Google AdSense要幾篇文章才能通過之審查甘苦談⇨ 我非常驚訝,我用的是Google自家的部落格平台,怎麼可能被Google封鎖;我想可能是我剛改網址,系統還不允許排入谷歌搜尋引擎。 官方網站「Google Search Console說明(註1)」出現的解釋是 當 Googlebot 無法存取網址、要求逾時,或是網站處於流量高峰狀態時,就會出現伺服器錯誤。在此情況下,Googlebot 便不得不放棄要求。 我能找誰詢問,解決「Googlebot便不得不放棄要求」的問題?我就滿心憂慮地去睡覺了。 隔天一早起來,我第一件事就是重新在Google Search Console測試我的網頁,還好過了。真是虛驚一場。 另外,如過要查詢伺服器狀態可以到Google Search Console的「設定」去看。 點選「設定」。 點選「檢索統計資料」的「開始報表」。 點選「主機狀態」,即可查看伺服器各種數據。 註1擷取自「Google Search Console說明」,https://support.google.com/webmasters/answer/7440203?hl=zh-Hant#zippy=%2C%E4%BC%BA%E6%9C%8D%E5%99%A8%E9%8C%AF%E8%AA%A4,2021/6/13 回到「部落格經營」頁面 ⇦Blogger文章在Google搜尋引擎找不到,怎麼辦? Google AdSense要幾篇文章才能通過之審查甘苦談⇨

一體成形式馬桶馬桶蓋怎麼拆及上裝式馬桶蓋膨脹螺絲原理介紹

家裡有主臥室廁所馬桶的馬桶蓋緩降有點壞掉,也就是沒有緩降功能,蓋馬桶蓋不小心會「碰」的一聲,關起來。 為了省錢,想要自己買馬桶蓋來換就好,就開始了馬桶蓋茶拆除研究之旅。 一看到主臥馬桶馬桶蓋才發現,原來沒有我想像的簡單,原因如下: 馬桶蓋兩側的空隙非常小,手要伸進去都很困難,何況是要轉鬆裡面的螺絲。 費盡千辛萬苦,終於從馬桶左側下方把手伸進去,也頂多只能摸到一邊的螺絲。 馬桶右側有一些水管,也就是說我根本不可能把手伸進去,摸到另一側的螺絲。 最後,花費了2-3天的偵探式思考,終於想到,說不定馬桶蓋向上拔起就拆除了,果真,只要將馬桶蓋立起來,往上拔就拆掉了。 附記:我家主臥廁所馬桶型號為:Derek C693NA 照片及拆除影片 馬桶前側照 馬桶蓋後側照 馬桶上方照 馬桶蓋拆除 上裝式馬桶蓋膨脹螺絲介紹 後來我另外買了上裝式馬桶蓋,包裹拆開來看到零件,附的膨脹螺絲我還是第一次看到,研究許久才知道怎麼裝。 原理 首先,拿出以下配件,可以看到上面有四個突出部 這個配件是用來裝在膨脹螺絲裡面的,它的突出部要跟膨脹螺絲相對應的開口及縫結合 然後,將螺絲從另一邊裝入 將螺帽從第一步驟介紹的配件端鎖上,直到螺帽進入該配件,與其吻合,接下來塞進安裝馬桶蓋的孔洞中,轉緊螺絲,這時,因為第一步驟的配件4個突出部已經卡住膨脹螺絲,膨脹螺絲已被孔洞夾住,且螺帽也被第一步驟的配件卡住,旋轉螺絲時,配件就會順著螺帽被往上鎖,擠開膨脹螺絲,最後把馬桶蓋安裝座鎖緊。  從正面將組裝好的膨脹螺絲塞進馬桶蓋安裝孔中,鎖緊即可

賭徒破產理論(Gambler's ruin)機率公式證明

賭徒破產理論(Gambler's ruin)指指的是兩位賭徒,每局賭1元,A賭徒有i元,B賭徒有n-i元,兩人不斷的賭,直到一人輸光為止。 回到「機率統計」頁面 前言 假設A賭徒勝率為p,輸的機率就是1-p,稱為q,我們要求算A贏光所有錢的機率。 讓p(i)代表A賭徒擁有i元的時候,獲得最後勝利的機率。 p(0) = 0,因為已經輸光所有錢並且賭局已結束。 p(n) = 1,因為已經贏光所有錢並且賭局已結束。 那麼p(i)呢? 遞迴公式(recursive formula) 假設A有i元,它下一局有可能贏,有可能輸。贏的機率為p,輸的機率為1-p = q。 不論這一局是贏還是輸,A要贏光所有錢的機率還是沒有算出來。 這局贏了,接下來贏光所有錢的機率為p(i+1)。 這局輸了,接下來贏光所有錢的機率為p(i-1)。 因此,p(i) = p*p(i+1) + q*p(i-1),且可以繼續延伸,例如p(i+1) = p*p(i+2) + q*p(i)、p(i-1) = p*p(i-) + q*p(i-2)... 每個公式需要套用原本的公式,稱為遞迴公式公式,而遞迴公式解法可以像解微分方程(differential equation)一樣,可以先用猜的! 例如dx/dt = rx,微分之後x還是在公式裡,可以先猜測x = e^y。 猜測 假設,p(i) = x i ,並帶入p(i) = p*p(i+1) + q*p(i-1),得到  x i   = p* x i+1  + q * x i-1 x = p* x 2  + q p* x 2  - x + q = 0 解一元二次方程式得 x = 1 或 x = q/p 微分方程 p(i) = x i , x = 1 或 x = q/p,且有兩已知數 p(0) = 0 及 p(n) = 1。 而x i 的x有兩個根(root),必須都帶入線性組合(linear combination)公式求解。 p(i) = A(1) i  + B ( q/p ) i  =  A +  B ( q/p ) i  p(0) = A + B = 0 , A = -B p(n) = A + B ( q/p ) n   = 1 ...