Pick a depth. Each prompt opens in your AI pre-loaded with the lesson. Click a row to preview the prompt.
Before any probability calculation, you need a clean answer to two questions: what are the possible outcomes, and which subsets of outcomes do we care about? That is a sample space and an event. I keep meeting smart builders who ship buggy probabilistic reasoning because they never wrote down the sample space — they conflated 'event' with 'outcome' and double-counted, or implicitly assumed equally-likely outcomes when they were not. This is the rebar inside the building. Get this concrete now and the rest of the course will feel like accounting.
A sample space is the set of all possible outcomes of an experiment. An event is any subset of . Roll two distinguishable dice; is the set of ordered pairs with , so . The event 'sum equals 7' is the subset , of size 6.
sum(w) == 11 and verify — the only ordered pairs are and .repeat=2 with repeat=3 for three dice. Print and the size of the event 'sum equals 10' — it should be 27, not 6.list(...) can hold it — you are already brushing against measure theory.// main.go
package main
import "fmt"
func main() {
// Build the sample space: all ordered pairs (d1, d2) for two dice
type pair struct{ a, b int }
var omega []pair
for d1 := 1; d1 <= 6; d1++ {
for d2 := 1; d2 <= 6; d2++ {
omega = append(omega, pair{d1, d2})
}
}
fmt.Printf("|Omega| = %d\n", len(omega))
// Event A: outcomes where the sum equals 7
var A []pair
for _, w := range omega {
if w.a+w.b == 7 {
A = append(A, w)
}
}
fmt.Printf("|A| = %d -> %v\n", len(A), A)
fmt.Printf("P(sum=7) = %g\n", float64(len(A))/float64(len(omega)))
}
go run main.go