開始使用免費開始

虧錢的機率

在這個練習中,你會用 DGP 模型來估計機率。

如前所述,這家公司可以加碼花費 3000 元重新設計廣告。這「可能」帶來更高的點擊率與註冊率,但並不保證。我們想透過計算虧錢的機率,來判斷是否值得多花這 3000 元。換句話說,就是高成本方案的營收減去低成本方案的營收小於成本的機率。

一旦我們模擬出營收結果,就能提出許多傳統分析方法難以回答的問題。

這個簡單但強大的架構,是以貝葉斯方法取得機率的基礎。

本練習屬於課程

Python 的統計模擬

檢視課程

練習說明

  • 將高、低成本方案之間的成本差 cost_diff 初始化為 3000
  • 取得高成本方案的營收,指定給 rev_high
  • 計算 rev_high - rev_low 小於 cost_diff 的次數比例。將其命名為 frac,並用它來列印結果。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Initialize cost_diff
sims, cost_diff = 10000, ____

# Get revenue when the cost is 'low' and when the cost is 'high'
rev_low = get_revenue(get_signups('low', ct_rate, su_rate, sims))
rev_high = ____

# calculate fraction of times rev_high - rev_low is less than cost_diff
frac = ____
print("Probability of losing money = {}".format(____))
編輯並執行程式碼