Basic Concepts of Statistics, Probability and Python
Create a Jupyter notebook and solve each exercise in an individual cell.
Each team must submit the Jupyter notebook and defend it on February 5, 2026. The defense will be carried out by one of the team members chosen at random.
Note that the function to be employed throughout this practice is:
\[h\left(x\right) = x^4 - 4x^2 + 4\]
Exercise 0: Matrix Manipulation
Write a program that (after an initial solo design) prompts from the keyboard three integers \(N\), \(M\), and \(K\); validates that \(N \ge 1\), \(M \ge 1\), and \(K \ge 0\); and constructs an \(N \times M\) matrix whose entries are uniformly sampled integers from the closed interval \([0, K]\). The algorithm must classify every entry and extract the sets of even numbers, odd numbers, and prime numbers, where \(0\) and \(1\) are treated as non-prime and primality is decided via trial division up to \(\lfloor \sqrt{x} \rfloor\) with early termination. For each category, report both (a) the total count over all matrix positions and (b) the sorted set of unique values; handle duplicates correctly, and note that if \(K < 2\) the prime set is empty by definition. Structure the solution modularly (separate input handling, matrix generation, and classification), include basic input-error recovery, and optionally expose a random-seed parameter to ensure reproducibility. After independently drafting pseudocode, engage a peer as a “more knowledgeable other” to critique modularity and efficiency, then implement the revised design, test it on at least two contrasting cases (e.g., small matrices and edge \(K\) values), and submit a concise analytical note that justifies your validation choices and discusses time complexity; conclude with a brief reflection explaining how the peer interaction scaffolded your final solution.
Exercise 1: Numerical Diferentation
Determine the numerical derivative of the function h, represented as \(\left(\frac{dh}{dx}\right)\), via finite difference approximation. Subsequently, contrast this result with the numerical evaluation of the symbolic derivative, derived through analytical differentiation, to assess the precision of the numerical approach
Exercise 2: Numerical Integration
Determine the numerical integration of the function \(h\left(x\right)\), represented as \(\left(\int_{-10}^{10}{h\left(x\right)dx}\right)\), via trapezoidal rule. Subsequently, contrast this result with the numerical evaluation of the symbolic integral, derived through analytical differentiation, to assess the precision of the numerical approach
Exercise 3: Numerical solutions of ordinary differential equations (ODEs)
Solve the ODE \(\frac{dy}{dx} = 2x - 3y\) with initial condition y(0) = 1 using Euler’s Method. With a step 0f 0.1. Suppose that: \(x \in \left[0, 10\right]\) and \(y \in \left[1, 10\right]\)
Exercise 4: Numerical optimization
Minimize the function \(h(t)\) using Gradient Descent.