- 光環效應 (Halo Effect),指在人際知覺中所形成的以偏概全的主觀印象。一個人的某種品質,或一個物品的某種特性一旦給人以非常好的印象,在這種印象的影響下,人們對這個人的其他品質,或這個物品的其他特性也會給予較好的評價。和光環效應相反的是惡魔效應,即對人的某一品質,或對物品的某一特性有壞的印象,會使人對這個人的其他品質,或這一物品的其他特性的評價偏低。
- 我們會對顯而易見的東西看不見,我們也會無視於我們的看不見 (We can be blind to the obvious, and we are also blind to our blindness)
- 專家在分析事情時,都會有一個前提或假設,但人們卻很少質疑其前提或假設
- 個人在做決策時,並不是如傳統財務理論假設理性的個人,會對所有的可能情境及可能性做詳盡的分析,事實上,大部分的投資人不但是非理性的,而且常常不能充份瞭解到自己所面對狀況,因而產生認知偏誤 (cognitive bias),常以經驗法則或直覺作為決策的依據,反應在投資行為上,則有過度反應或反應不足的現象
- 很多時候,投顧在跟你推薦買進某張股票的時候,連最基本的問題 (如此檔股票的現值是否 underpriced) 都無法回答,他很可能根本不知道自己在做什麼
- 前景理論 (Prospect Theory):
- 人們在面臨獲得時,往往小心翼翼,不願冒風險;而在面對損失時,人人都變成了冒險家。
- 人們對損失和獲得的敏感程度是不同的,損失的痛苦要遠遠大於獲得的快樂。這也是為什麼很多人在股市賺一點錢就賣掉股票,賠錢的股票卻一直留著不放手。
- 人類最大的問題是,我們對於我們相信的、知道的太有自信,常常忽略我們所知有限
- 人們會從過去學到經驗,但因為擁有後見之明(hindsight),就覺得胸有成竹,對於未來就覺得很篤定,忘記我們是活在不確定的世界
- 人腦中會有兩個系統
- 系統一 (System 1):是 automatic system,屬於自動化、反射性、快速、不費力的思考方式。如運算 1 + 1 等於多少、看著報紙念出一則報導、理解一個簡單的句子等
- 系統二 (System 2):是 effortful system,屬於較費力、需專注力、邏輯思考、牽涉複雜運算、推理的思考方式。如填寫稅單、比較兩隻手機的優缺點、把車子停在一個格子較小的停車格
- 直覺 (系統一)可以幫助你省下很多力氣。如同你熟練了開車的技術之後,在每天通勤的道路上,幾乎不用動腦就可以到達目的地,這就是系統一在主導駕駛行為。如果是你到日本開車,租車公司會提醒你在日本是右駕,由於與原本的左駕習慣不同,當系統一無法應付時,便會把系統二叫出來,注意行車安全
- 系統二 (System 2) 會持續地監控你的行為,如當你在盛怒之下還是要保持禮貌,在下雨的晚上開車會更加注意行車安全
- 在遇到熟悉的情境,或是短期的預測,System 1 可以扮演非常稱職的角色。但是 System 1 常有偏誤(bias),因為其僅適用於特定的情境
- System 1 會自動運作且無法隨心所欲地關閉它,所以我們無可避免的會產生直覺錯誤、認知幻覺,System 1 的偏誤是無法避免的。但是,將 System 2 用來取代 System 1 來做日常的決策是不切實際的,因為它運作緩慢且沒效率,我們能做的是:學習識別我們所處的情境的犯錯機率,當風險很高時要盡量避免犯下重大錯誤
- 若你的 working memory 被佔據的越滿,你思考的能力就會越降低
- System 2 與家裡的電路一樣都是有其限度的,但是他們對於過載的時候的反應不同。電路系統若發現用電過量,就會跳電,所有電器用品會全部失去電力;System 2 一樣會啟動保護,但是只會保留最重要的資訊,其他都會予以忽略
- 你對一件事情很熟悉了以後,當你在重複做這件事情時,所需耗用的力氣就會比較小;高度聰明的人可以用比較少的力氣與時間就可以解決問題。在經濟活動裡,需花費的力氣都是成本,當我們學會技能後,就會去平衡成本與效益,想辦法以較少的成本達成最大的效益,這是人類的天性
- System 2 的一個重要的能力是能使用任務清單,其可以把一連串的指令寫入腦中的記憶體,System 2 會遵守這些指令並控制習慣性的反應,如從一篇文章中算出 f 這個單字出現幾次。但是當你又接收到第二個指令,如算出下一頁的逗號出現幾次,這時你會需要比第一個任務花更大的力氣,尤其若有時間壓力的話,因為當指令改變時,其對 System 2 的挑戰度會更提高
- 為了避免腦袋超載,我們通常會把一個困難的任務分解成多個簡單的步驟,並將中間產生的結果寫入長期記憶中或是紙張上,避免 working memory 超載,一切都是遵守 the law of least effort (最省力法則)
- 自我控制是非常需要專注力與體力的,這類的任務是由 System 2 來執行的,它會用來控制的你思考與行為
- 有的人傾向使用 System 1,有些人比較會善用 System 2。這與智力 (intelligence) 無關,反而與理性 (rationality) 有關,高智商並無法對判斷偏誤免疫,反而是理性的人比較能做好自我控制,不被直覺牽著鼻子走
- 心理學中提到的促發效應 (priming effects) 是一種內隱記憶的效應,而這個效果是指受到一種刺激 (即知覺模式)時,會影響到另一個刺激的反應。如SO_P這個單字填空,若你受到聽覺會視覺的刺激是 FOOD 相關,你就會寫出SOUP;若受到的刺激是WASH相關,你就會很自然地寫出SOAP
- 當你在一個 lab 裡面都是接觸到 old 相關的字眼的測驗,離開 lab 時發現他們的行動卻變慢了,這就是所謂的「意念動作效應」(ideomotor effect)。這個效應也可以倒過來做,動作也會強化意念。德國的研究者請學生在房間中走五分鐘,每一分鐘走三十步,這是一般大學生步伐速度的三分之一,然後請他們在電腦上辨認一閃而過的單字,結果發現這些慢走的學生,對老年有關的字辨識特別快 。簡言之,當你想著老年的話,你的動作就會傾向像個老人;當你的動作像老人的話,就會強化老年的想法,這個效應是雙向的
- 許多宗教都將沐浴視為一種凈化儀式,它代表了洗去污垢和罪惡。這種跨文化的共性背後很可能有心理學的原因。有心理學研究證明,清潔確實能夠減輕人的罪惡感,而人在回憶自己的罪惡之後也更容易聯想到肥皂、洗等清潔相關的詞彙。心理學家將其命名為「麥克白效應」(Lady Macbeth effect),這個名字來自於莎翁名劇《麥克白》中的麥克白夫人,她在殺人之後總覺得自己手上沾滿了鮮血,總想要洗手。
- 你目前的狀態是 cognitive ease (認知放鬆) 或 cognitive stained (認知緊張),都會影響你的思考與判斷。當你在 cognitive ease (認知放鬆) 的狀態,你可能會擁有好心情,看到你想看的,聽到你想聽的,信任你的直覺;當你在cognitive stained (認知緊張) 的狀態,通常你會感覺到緊繃,做事也會比較謹慎、多疑,會花更多的精力在你現在做的事情上,更少犯錯,你會相對地少用直覺做事,也擁有較少有創造力
- 如果你希望你傳達的訊息內容能說服他人,你的訊息的字體必須要清楚、紙張必須要用高等級的紙,字體與背景的對比要鮮明。如果你有用到顏色的話,亮藍色與亮紅色會比綠色、黃色、深藍色來的好。你可以注意看看上市上櫃公司財報的印刷
Total Pageviews
2018/04/01
[閱讀筆記] Thinking, Fast and Slow (1/9)
Labels:
Investment,
Reading
2018/03/31
2018/03/14
[Mac] 如何重灌 macOS
Process
How-To
執行步驟如下:
Step 1 Screenshot - 在 OS X 工具程式選擇 "磁碟工具程式"
Step 2 Screenshot - 選擇要格式化的硬碟,按下[清除]
Step 3 Screenshot - 填妥名稱、格式,按下[清除]
Step 4 Screenshot - 清除完成後,按下[完成]按鈕,並退出磁碟工具程式
Step 5 Screenshot - 在 OS X 工具程式選擇 "重新安裝 OS X"
Step 6 Screenshot - 按下 [繼續]
Step 7 Screenshot - 在軟體許可協議頁面按下[同意]
Step 8 Screenshot - 選擇要安裝的硬碟
Step 9 Screenshot - 開始安裝 OS X
按下電源鍵後,馬上依序按下 Command(⌘) + R,等候 OS X 工具程式畫面
How-To
執行步驟如下:
Step 1 Screenshot - 在 OS X 工具程式選擇 "磁碟工具程式"
Step 2 Screenshot - 選擇要格式化的硬碟,按下[清除]
Step 3 Screenshot - 填妥名稱、格式,按下[清除]
Step 4 Screenshot - 清除完成後,按下[完成]按鈕,並退出磁碟工具程式
Step 5 Screenshot - 在 OS X 工具程式選擇 "重新安裝 OS X"
Step 6 Screenshot - 按下 [繼續]
Step 7 Screenshot - 在軟體許可協議頁面按下[同意]
Step 8 Screenshot - 選擇要安裝的硬碟
Step 9 Screenshot - 開始安裝 OS X
Labels:
Mac
2018/03/13
[jsoup] How to use jsoup selector to retrieve value?
Problem
I try to get "2412 中華電" from this page: https://goodinfo.tw/StockInfo/StockDetail.asp?STOCK_ID=2412
jsoup provide select method to find elements that match the Selector CSS query, with this element as the starting context. Matched elements may include this element, or any of its children. But how to define the CSS selector?
How-To
You can use Google Chrome to help you get the CSS Selector:
Here has the sample code:
I try to get "2412 中華電" from this page: https://goodinfo.tw/StockInfo/StockDetail.asp?STOCK_ID=2412
jsoup provide select method to find elements that match the Selector CSS query, with this element as the starting context. Matched elements may include this element, or any of its children. But how to define the CSS selector?
1 2 3 4 5 6 | public static void main(String[] args) throws IOException { String cssSelector = "???"; String url = "https://goodinfo.tw/StockInfo/StockDetail.asp?STOCK_ID=2412"; Document doc = Jsoup.connect(url).get(); String name = doc.select(cssSelector).text(); } |
How-To
You can use Google Chrome to help you get the CSS Selector:
Here has the sample code:
1 2 3 4 5 6 | public static void main(String[] args) throws IOException { String cssSelector = "body > table:nth-child(3) > tbody > tr > td:nth-child(3) > table > tbody > tr:nth-child(1) > td > table:nth-child(1) > tbody > tr > td > table > tbody > tr:nth-child(1) > td > span:nth-child(1) > a"; String url = "https://goodinfo.tw/StockInfo/StockDetail.asp?STOCK_ID=2412"; Document doc = Jsoup.connect(url).get(); String name = doc.select(cssSelector).text(); } |
Labels:
jsoup
2018/03/12
[snakeyaml] How to generate YAML via Java?
Problem
How to generate YAML via Java?
The expected YAML content looks like:
How-To
Add snakeyaml dependency to pom.xml
Here has sample code which implement via snakeyaml
How to generate YAML via Java?
The expected YAML content looks like:
1 2 3 4 5 6 7 8 9 | intents: - greet - inform - others - question entities: - userid - is_account_locked - pass_company_check |
How-To
Add snakeyaml dependency to pom.xml
1 2 3 4 5 | <dependency> <groupId>org.yaml</groupId> <artifactId>snakeyaml</artifactId> <version>1.19</version> </dependency> |
Here has sample code which implement via snakeyaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | package test.albert.snakeyaml; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; import org.yaml.snakeyaml.DumperOptions; import org.yaml.snakeyaml.Yaml; import lombok.AllArgsConstructor; import lombok.Data; import lombok.extern.slf4j.Slf4j; @Slf4j public class SnakeYamlTest { public static void main(String[] args) { // Set DumperOptions options DumperOptions options = new DumperOptions(); options.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); options.setPrettyFlow(true); // Create Yaml instance with DumperOptions Yaml yaml = new Yaml(options); // Prepare map data for YAML Map<String, Object> map = new HashMap<>(); map.put("intents", Arrays.asList("greet", "inform", "others", "question")); map.put("entities", Arrays.asList("userid", "is_account_locked", "pass_company_check")); // Serialize a Java object into a YAML String String output = yaml.dump(map); log.info("\n" + output); } } |
Labels:
Java
2018/03/11
[Kindle] Cannot Find Word Wise Function in eBook
Problem
I had order an eBook, Thinking in Systems: A Primer, from Amazon.com.
According to its product specification, this eBook support word wise
If this eBook support word wise, you can find word wise in the lower right corner
But the eBook which I bought cannot find Word Wise function in the lower right corner.
I contacted with Amazon customer service. Customer service had confirmed that the eBook is defective, they need to contact the publisher about updating the eBook. They will me once Amazon get any update about the eBook, then I can place the order for the eBook once it is updated.
Problem resolution process is as following:
I had order an eBook, Thinking in Systems: A Primer, from Amazon.com.
According to its product specification, this eBook support word wise
If this eBook support word wise, you can find word wise in the lower right corner
But the eBook which I bought cannot find Word Wise function in the lower right corner.
I contacted with Amazon customer service. Customer service had confirmed that the eBook is defective, they need to contact the publisher about updating the eBook. They will me once Amazon get any update about the eBook, then I can place the order for the eBook once it is updated.
Problem resolution process is as following:
Labels:
Kindle
2018/03/10
[Python] How to open a url with urllib via proxy ?
Problem
When I try to open a URL via urllib, but I get this error message:
Here has the code snippet:
How-to
This error result from failing to connect to this URL. I need to configure proxy in my network environment as I connect. Hence, the updated code will look like:
When I try to open a URL via urllib, but I get this error message:
File "C:\Users\albert\AppData\Local\Programs\Python\Python36-32\lib\http\client.py", line 936, in connect (self.host,self.port), self.timeout, self.source_address) File "C:\Users\albert\AppData\Local\Programs\Python\Python36-32\lib\socket.py", line 722, in create_connection raise err File "C:\Users\albert\AppData\Local\Programs\Python\Python36-32\lib\socket.py", line 713, in create_connection sock.connect(sa) TimeoutError: [WinError 10060] 連線嘗試失敗,因為連線對象有一段時間並未正確回應,或是連線建立失敗,因為連線的主機無法回應。
Here has the code snippet:
import urllib.request, json from test.json.row import row with urllib.request.urlopen("http://od.moi.gov.tw/api/v1/rest/datastore/A01010000C-000628-023") as url: data = json.loads(url.read().decode()) print(data) dataList = [] count = 1 for value in data['result']['records']: if(count > 1): no = value['No'] # 編號 address = value['Address'] # 地點位置 deptNm = value['DeptNm'] # 管轄警察局 branchNm = value['BranchNm'] # 分局 dataList.append(row(no, address, deptNm, branchNm)) print('no={}, address={}, deptNm={}, branchNm={}'.format(no, address, deptNm, branchNm)) count += count
How-to
This error result from failing to connect to this URL. I need to configure proxy in my network environment as I connect. Hence, the updated code will look like:
import urllib.request, json from test.json.row import row import os os.environ['http_proxy'] = 'http://proxy.cht.com.tw:8080' with urllib.request.urlopen("http://od.moi.gov.tw/api/v1/rest/datastore/A01010000C-000628-023") as url: data = json.loads(url.read().decode()) print(data) dataList = [] count = 1 for value in data['result']['records']: if(count > 1): no = value['No'] # 編號 address = value['Address'] # 地點位置 deptNm = value['DeptNm'] # 管轄警察局 branchNm = value['BranchNm'] # 分局 dataList.append(row(no, address, deptNm, branchNm)) print('no={}, address={}, deptNm={}, branchNm={}'.format(no, address, deptNm, branchNm)) count += count
Labels:
Python
2018/03/09
[Python] UnicodeDecodeError: 'cp950' codec can't decode byte 0x99 in position 241: illegal multibyte sequence
Problem
When I try to read a file via Python, I get an error message as following:
Here has the code snippet:
How-To
Remember add encoding when opening file, here has the updated code snippet:
When I try to read a file via Python, I get an error message as following:
1 2 3 4 | Traceback (most recent call last): File "D:\work\myworkspace\PyTest\src\test\getdata.py", line 11, in <module> json = json_file.read() UnicodeDecodeError: 'cp950' codec can't decode byte 0x99 in position 241: illegal multibyte sequence |
Here has the code snippet:
json_file = open("D:/test/test.json", "r") json = json_file.read() print(json) json_file.close()
How-To
Remember add encoding when opening file, here has the updated code snippet:
json_file = open("D:/test/test.json", "r", encoding='utf8') json = json_file.read() print(json) json_file.close()
Labels:
Python
2018/03/08
[Java] Utilize JAXB to Read / Write XML
Scenario
The XML content looks like:
How-To
Create three POJOs:
Create a test case to implement XML marshalling and unmarshalling:
The XML content looks like:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <products> <product id="P01"> <description>Sony Alpha 7 II</description> <price>1620</price> <createdBy> <email>albert@gmail.com</email> <id>1</id> <name>Albert</name> </createdBy> </product> <product id="P02"> <description>Sony Alpha 7R II</description> <price>2585</price> <createdBy> <email>albert@gmail.com</email> <id>1</id> <name>Albert</name> </createdBy> </product> </products> |
How-To
Create three POJOs:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | package test.albert.xml; import java.util.ArrayList; import java.util.List; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import lombok.ToString; @XmlRootElement(name = "products") @ToString public class Products { List<Product> products; public List<Product> getProducts() { return products; } @XmlElement(name = "product") public void setProducts(List<Product> products) { this.products = products; } public void add(Product product) { if (this.products == null) { this.products = new ArrayList<Product>(); } this.products.add(product); } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | package test.albert.xml; import java.math.BigDecimal; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlRootElement; import lombok.AllArgsConstructor; import lombok.NoArgsConstructor; import lombok.ToString; /** * @XmlRootElement: This annotation is used at the top level class to indicate * the root element in the XML document. The name attribute in * the annotation is optional. If not specified, the class name * is used as the root XML element in the document. * @XmlAttribute: This annotation is used to indicate the attribute of the root * element. * @XmlElement: This annotation is used on the properties of the class that will * be the sub-elements of the root element. * */ @AllArgsConstructor @NoArgsConstructor @ToString @XmlRootElement(name = "product") public class Product { @XmlAttribute(name = "id") private String productId; @XmlElement(name = "description") private String description; @XmlElement(name = "price") private BigDecimal price; @XmlElement(name = "createdBy") private User createdBy; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | package test.albert.xml; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; import lombok.ToString; @ToString @NoArgsConstructor @AllArgsConstructor @Data public class User { private Long id; private String name; private String email; } |
Create a test case to implement XML marshalling and unmarshalling:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | package test.albert.xml; import java.io.File; import java.math.BigDecimal; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Marshaller; import javax.xml.bind.Unmarshaller; import org.junit.After; import org.junit.Before; import org.junit.Test; import lombok.extern.slf4j.Slf4j; @Slf4j public class JAXBTest { private Product sonayA7ii; private Product sonayA7Rii; private String xmlFile; @Before public void setUp() { User albert = new User(1L, "Albert", "albert@gmail.com"); sonayA7ii = new Product("P01", "Sony Alpha 7 II", new BigDecimal(1620), albert); sonayA7Rii = new Product("P02", "Sony Alpha 7R II", new BigDecimal(2585), albert); xmlFile = "F:" + File.separator + "product.xml"; } @Test public void testObjectToXml() throws JAXBException { Products products = new Products(); products.add(sonayA7ii); products.add(sonayA7Rii); JAXBContext jaxbContext = JAXBContext.newInstance(Products.class); Marshaller marshaller = jaxbContext.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true); marshaller.marshal(products, new File(xmlFile)); marshaller.marshal(products, System.out); } @Test public void testXmlToObject() throws JAXBException { File file = new File(xmlFile); JAXBContext jaxbContext = JAXBContext.newInstance(Products.class); Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); Products products = (Products) unmarshaller.unmarshal(file); log.debug(products.toString()); } @After public void tearDown() { sonayA7ii = null; sonayA7Rii = null; xmlFile = ""; } } |
Labels:
Java
Subscribe to:
Posts (Atom)