-
Notifications
You must be signed in to change notification settings - Fork 0
Assignment 18.2.3 #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
@mrcinv prosim za pregled |
mrcinv
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Kurtaga Nice solution. The code is well structured. There are no doc strings for functions. To find the error you've compared the results to existing implementation.
Existing implementation might not be available in other similar cases, so it would be better to calculate the error estimate with your code only.
The report is well written and explains nicely the design.
| - Moderate values (2 ≤ x ≤ 5): Gauss–Legendre quadrature (fixed steps). | ||
| - Large $x > 5$: Asymptotic expansion. | ||
|
|
||
| We can also take advantage of the symmetry of the normal distribution: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For values smaller than
| In our case, the weight function is simply $w(t) = 1$, which makes Gauss–Legendre the appropriate choice (other Gaussian quadratures such as Gauss–Hermite or Gauss–Laguerre are used when exponential weight functions appear). | ||
|
|
||
| To ensure constant-time evaluation, we use a fixed rule (10-point Gauss–Legendre), with nodes and weights obtained from published tables and hardcoded into the implementation. Reliable tables can be found online, e.g.: | ||
| [https://pomax.github.io/bezierinfo/legendre-gauss.html](Gaussian Quadrature Weights and Abscissae). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is also a package FastGaussQuadrature for that.
|
|
||
| # Asymptotic Expansion | ||
|
|
||
| For large arguments ($x > 5$), we can use an asymptotic expansion to approximate the standard normal CDF. The idea is to express the CDF in terms of the complementary error function: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The asymptotic expansion is not derived. Where did you find it? Please add the derivation of the expansion or a reference to the source where you found it.
| asymptotic_terms::Int=10) | ||
|
|
||
| if x < 0 | ||
| return 1.0 - my_cdf(-x; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This formula will lead to large relative error for
| nodes, weights = GL_rules[n] | ||
|
|
||
| # symmetry: reduce to positive x | ||
| if x < 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Due to the properties of the function (
Second assignment complete