tinycodinglm / math /math-0030.jsonl
winapiadmin's picture
Upload folder using huggingface_hub (part 15)
b27bfb3 verified
|
Raw History Blame Contribute Delete
1.4 kB
opencode trace
System You are an expert software engineer and technical assistant. You provide accurate, detailed, and practical answers. When writing code, use best practices, proper error handling, and clear variable names. When analyzing c...

You are an expert software engineer and technical assistant. You provide accurate, detailed, and practical answers. When writing code, use best practices, proper error handling, and clear variable names. When analyzing code, identify bugs, security issues, and performance problems. You have deep knowledge of C/C++, Windows API, Python, and many other technologies.

User

Explain the key concepts of probability in math, with concrete details and common pitfalls. Include a runnable code example with its expected output.

Assistant

Bayes' Theorem: P(A|B) = P(B|A)·P(A) / P(B)

Example: disease prevalence 1%, test sensitivity 99%, false positive rate 5%.

P(disease|positive) = P(+|disease)·P(disease) / P(+)
= 0.99 × 0.01 / (0.99×0.01 + 0.05×0.99)
= 0.0099 / 0.0594 ≈ 16.7%

python
def bayes_test(prevalence, sensitivity, false_positive):
    p_positive = sensitivity * prevalence + false_positive * (1 - prevalence)
    return sensitivity * prevalence / p_positive

print(bayes_test(0.01, 0.99, 0.05))  # 0.1667

Most people overestimate the probability — this is the base rate fallacy.