What's the intuitive explanation for how Gaussian quadrature allows for exact integration of degree 2n-1 polynomials while sampling only n points?

I imagine it has something to do with how the odd-degree terms don't contribute at all to the integral over [-1,1], but I still don't quite grasp how the relevant information for the even terms could be extracted using so few points.

πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/SendGreenAway
πŸ“…︎ Apr 12 2021
🚨︎ report
Gaussian Quadrature, What am I doing wrong?

I am tasked with using 3 and 4 point gaussian quadrature to approximate the integral from -1 to 1 of 1.2x^3 + 7x^2 + 2.7

However, I am running into some calculation issues and I am not sure where the error is.

I have that you can approximate the integral by

c1f(x1) + c2f(x2) + c3f(x3)

and my table of values tells me that

c1 = .555555556

c2 = .888888889

c3 = .555555556

x1 = -.774596669

x2 = 0

x3 = .774596669

So, I set up the problem as

.555555556 * f(1.2(-.774596669^3 ) + 7(-.774596669^2 ) + 2.7)

+ .888888889 * f(1.2(0^3 ) + 7(0^2 ) + 2.7)

+ .555555556 * f(1.2(.774596669^3 ) + 7(.77459669 ^2 ) + 2.7)

But when I multiply all this out I end up getting some really big numbers. Like just the first lines is like 350, the integral is nowhere close to that value when evaluated.

Am I doing something wrong formula wise, or is there just some calculation mistake?

Thanks, in advance!

πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/Nono4271
πŸ“…︎ Oct 17 2020
🚨︎ report
Gaussian Quadrature Problem

Hello, I'm trying to learn how to write a program for numerical integration. I recently wrote several programs for the left, right, and mid point estimations, the Simpson's rule, and the trapezoidal rule. Currently I'm working on a program for 2 point Gaussian quadrature and I'm getting stuck.

Here's what I've got

#include "stdafx.h"
#include <iostream>
#include <cmath>

using namespace std;

double f(double x) //function a = f(x) = 1/(1+x^2)
{
double a = 1 / (1 + x*x);
return a;
}

double twoGauss(double a, double b, int n)
{
int i;
double lower, upper, number, width, leftw, rightw, sum = 0;
lower = a;
upper = b;
number = n;
width = (b - a) / n;
leftw = width*(1 - 1./sqrt(3))/2;
rightw = width*(1 + 1./sqrt(3))/2;


double* xa = new double[n];
double* xb = new double[n];
double* ya = new double[n];
double* yb = new double[n];

for (i = 0; i < number; i++)
{
	xa[i] = lower + (i)*width + leftw;
	xb[i] = lower + (i)*width + rightw;
	ya[i] = f(xa[i]);
	yb[i] = f(xb[i]);
	sum = sum + ya[i] + yb[i];
}
sum = sum*width / 2;

return sum;
}

int main()
{
int n; // n is for the subintervals
double a, b;
cout << "Enter the limits of integration, \nLower limit, a="; // get lower limit of integration
cin >> a;
cout << "Upper limit, b="; // upper limit of integration
cin >> b;
cout << "Number of subintervals, n=";
cin >> n;

cout << "The definite integral using two point Gaussian quadrature is " << twoGauss(a, b, n) << endl;

    system("pause");
return 0;
}

I would like to eventually write a similar function for 3 point, 4 point, and 5 point quadrature, and also later 2 dimensional, 3-d, and 4-d, and also to be written for CUDA so I can use a graphics card to do the computation. But right now I'm just trying to focus on getting a simple 1 dimension, 2 point down. Once I figure that out, I figure the rest should follow straightforwardly. I'd appreciate any help you can give, this is my first foray into coding for anything except for an introductory C++ class in my undergrad.

πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/Stringytheories
πŸ“…︎ Apr 19 2017
🚨︎ report
I would massively appreciate help with a Gaussian Quadrature related problem.
πŸ‘︎ 9
πŸ’¬︎
πŸ‘€︎ u/Rumsey_The_Hobo
πŸ“…︎ Apr 05 2015
🚨︎ report
Function that a Gaussian quadrature fails on?

I'm learning about Gaussian quadratures, and I was wondering if there is an example of a function that this method fails to accurately compute?

πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/Yogurt_Huevos
πŸ“…︎ Jan 05 2016
🚨︎ report
Can someone explain to me what a Gaussian quadrature on a sphere is?

I'm working on solving some complex differential equations and integrals over the surface of a sphere. Part of my algorithm requires processing spherical signals in the Spherical Harmonics domain. I implemented it myself in matlab, but my implementation was a little unstable, so I decide to use (this package)[http://sourceforge.net/projects/libpsht/].

My only hiccup at this point is that the package supports spherical discretizations in 3 ways: HEALPix, Equirectangular Cylindrical Projections, or Gaussian Quadrature, and I'm not sure exactly what that means in terms of mapping latitude and longitude to a grid. I'm pretty sure I want ECP or Gaussian, but I really and truely don't understand the difference, and reading the wiki article on Gaussian Quadrature seemed to only make it more confusing.

Can anyone help with this?

πŸ‘︎ 6
πŸ’¬︎
πŸ‘€︎ u/Steve132
πŸ“…︎ Sep 08 2011
🚨︎ report
πŸ‘︎ 8
πŸ’¬︎
πŸ‘€︎ u/austingwalters
πŸ“…︎ May 13 2014
🚨︎ report
Gaussian Quadrature Thrm. Trouble

My question is here: http://math.stackexchange.com/questions/732830/gaussian-quadrature-deriving-a-formula

Basically, I just don't know how to do this exercise and it would be great if someone could show me to go through this problem. Through that, I think I will be able to get a better understanding of how to use theorem.

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/Ozera
πŸ“…︎ Mar 30 2014
🚨︎ report
Help on Gaussian Quadrature

Okay so i need the general gist of how to even work there out. Lets give a random function to integrate like f (x^(2)*ln(x)) from 1 to 1.5. When n = 2 and n=3 how do i approximate this? Could someone help, I kinda get when n=2 but could someone show full working? Thankyou in advanced

πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/naalie
πŸ“…︎ Oct 29 2014
🚨︎ report
Numerical Analysis

I’m looking for someone who is very knowledgeable in Numerical Analysis topics. I also need a person who has access to mathematical software such as Maple lite or MATLAB. The software is used to facilite the process of these problems. These topics include interpolation and polynomial approximation, Neville’s method, divided differences, hermite interpolation, numerical differentiation, Gaussian quadrature, and norms of vectors and matrices. Please don’t contact me if you’re aren’t knowledgeable. I will be checking ofc. Don’t waste my time.

πŸ‘︎ 2
πŸ’¬︎
πŸ“…︎ Dec 12 2021
🚨︎ report
Principle Maximum Entropy. Better way to add Kurtosis to a Gaussian?

I hope this is cool/interesting. If you make it to the end, I could some help.

The principle of maximum entropy states that the probability distribution which represents the current state of knowledge about a system is the one with the largest entropy, subject to the appropriate constraints. If your constraints are a mean and a standard deviation, the principle of maximum entropy gives you a Gaussian. If your constraints are a mean and that the distribution is non-negative, the principle of maximum entropy gives you an Exponential distribution.

This gif https://gfycat.com/selfishcreativefeline shows a lower bound being added to a Gaussian. The bound starts at -6, and the distribution is very close to a Gaussian. The distribution changes as the bound changes until at -1, the distribution is basically an exponential distribution. It’s bounded by -1, not 0, but close enough.

The algorithm fails for a lower bound between -1 and 0. I’ll explain briefly. The mean and standard deviations can be expressed as Lagrange multipliers. With some work, you can show that the distribution is of the form: p(x) = C e^(lambda1 * x + lambda2*x^2). It can be solved numerically. The problem is that the algorithm doesn’t know that lambda2 must be a negative number. If lambda2 is positive, the distribution has infinite area. Since numerically solving it requires a finite quadrature, the algorithm still finds a solution.

Adding skew seems to work. https://gfycat.com/zealousdefiantboar At least for the skew values I typically deal with.

Changing Kurtosis works for values between 1 and 3. https://gfycat.com/giganticearlyindusriverdolphin Kurtosis >= 1 + skew*skew. A Gaussian has a Kurtosis of 3. So I can reduce Kurtosis.

When there is sufficient skew, I can increase Kurtosis a bit. https://gfycat.com/unripebestdunlin However when skew=0. I can’t raise it above 3. The distribution is of the form: p(x) = C e^(lambda1 * x + lambda2*x^2 + lambda3*x^3 + lambda4*x^4). When I increase the Kurtosis, lambda4 > 0. The algorithm finds a solution.

I’ve searched the literature I can find. There is a uniqueness theorem, and the algorithm does give a result. The problem is that it only works because the quadrature in the numerical integral is finite.

Anyone have an idea of what to do? It would

... keep reading on reddit ➑

πŸ‘︎ 17
πŸ’¬︎
πŸ‘€︎ u/dBobMalamute
πŸ“…︎ Jul 27 2021
🚨︎ report
Blind Girl Here. Give Me Your Best Blind Jokes!

Do your worst!

πŸ‘︎ 5k
πŸ’¬︎
πŸ‘€︎ u/Leckzsluthor
πŸ“…︎ Jan 02 2022
🚨︎ report
What starts with a W and ends with a T

It really does, I swear!

πŸ‘︎ 6k
πŸ’¬︎
πŸ‘€︎ u/PsychedeIic_Sheep
πŸ“…︎ Jan 13 2022
🚨︎ report
Dropped my best ever dad joke & no one was around to hear it

For context I'm a Refuse Driver (Garbage man) & today I was on food waste. After I'd tipped I was checking the wagon for any defects when I spotted a lone pea balanced on the lifts.

I said "hey look, an escaPEA"

No one near me but it didn't half make me laugh for a good hour or so!

Edit: I can't believe how much this has blown up. Thank you everyone I've had a blast reading through the replies πŸ˜‚

πŸ‘︎ 19k
πŸ’¬︎
πŸ‘€︎ u/Vegetable-Acadia
πŸ“…︎ Jan 11 2022
🚨︎ report
What is a a bisexual person doing when they’re not dating anybody?

They’re on standbi

πŸ‘︎ 11k
πŸ’¬︎
πŸ‘€︎ u/Toby-the-Cactus
πŸ“…︎ Jan 12 2022
🚨︎ report
What do you call quesadillas you eat in the morning?

Buenosdillas

πŸ‘︎ 11k
πŸ’¬︎
πŸ‘€︎ u/FarronKeepSucks
πŸ“…︎ Jan 14 2022
🚨︎ report
Geddit? No? Only me?
πŸ‘︎ 6k
πŸ’¬︎
πŸ‘€︎ u/shampy311
πŸ“…︎ Dec 28 2021
🚨︎ report
I wanna hear your best airplane puns.

Pilot on me!!

πŸ‘︎ 3k
πŸ’¬︎
πŸ‘€︎ u/Paulie_Felice
πŸ“…︎ Jan 07 2022
🚨︎ report
E or ß?
πŸ‘︎ 9k
πŸ’¬︎
πŸ‘€︎ u/Amazekam
πŸ“…︎ Jan 03 2022
🚨︎ report
No spoilers
πŸ‘︎ 9k
πŸ’¬︎
πŸ‘€︎ u/Onfour
πŸ“…︎ Jan 06 2022
🚨︎ report
Covid problems
πŸ‘︎ 7k
πŸ’¬︎
πŸ‘€︎ u/theincrediblebou
πŸ“…︎ Jan 12 2022
🚨︎ report
These aren't dad jokes...

Dad jokes are supposed to be jokes you can tell a kid and they will understand it and find it funny.

This sub is mostly just NSFW puns now.

If it needs a NSFW tag it's not a dad joke. There should just be a NSFW puns subreddit for that.

Edit* I'm not replying any longer and turning off notifications but to all those that say "no one cares", there sure are a lot of you arguing about it. Maybe I'm wrong but you people don't need to be rude about it. If you really don't care, don't comment.

πŸ‘︎ 12k
πŸ’¬︎
πŸ‘€︎ u/Lance986
πŸ“…︎ Dec 15 2021
🚨︎ report
Interpreting Interactions in glmer() Output: What is it comparing?

Hello r/AskStatistics,

I'm having some trouble interpreting my the results of my glmm. Everything makes sense until I get to the interactions. So I have "lang" a factor with 3 levels (EP, BP, EN) and collType, a factor with 4 levels (baseline, EO, CC, FC). When I interact these with EN and baseline as the reference levels, how do I interpret it? What is the comparison being made here? Is it comparing with lang or collType? Or both? And what happened to the rest of the interactions, e.g., langEN:collTypecc? I'm so confused!

I'd be really grateful if someone could explain or at least point me to some resources that could help me read these results.

here's my output:

Generalized linear mixed model fit by maximum likelihood (Adaptive Gauss-Hermite Quadrature, nAGQ = 0) ['glmerMod']

Family: inverse.gaussian ( identity )

Formula: RT ~ lang * collType + (1 | item) + (1 | ID) + (1 + collType | ID) + (1 + lang | item)

Data: analysis

Control: glmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e+05))

AIC BIC logLik deviance df.resid

348111.0 348361.8 -174024.5 348049.0 24094

Scaled residuals:

Min 1Q Median 3Q Max

-1.8198 -0.5953 -0.2195 0.3635 9.4057

Random effects:

Groups Name Variance Std.Dev. Corr

ID (Intercept) 1.830e+04 1.353e+02

collTypecc 2.425e+04 1.557e+02 -0.88

collTypeeo 2.839e+04 1.685e+02 -0.74 0.69

collTypefc 2.742e+04 1.656e+02 -0.98 0.79 0.70

ID.1 (Intercept) 1.624e+04 1.274e+02

item (Intercept) 0.000e+00 0.000e+00

langBP 4.334e+03 6.583e+01 NaN

langEP 4.339e+03 6.587e+01 NaN 0.78

item.1 (Intercept) 3.417e+03 5.846e+01

Residual 9.603e-05 9.799e-03

Number of obs: 24125, groups: ID, 329; item, 90

Fixed effects:

Estimate Std. Error t value Pr(>|z|)

(Intercept) 1257.64 22.50 55.892 < 2e-16 ***

langBP 207.83 29.77 6.982 2.92e-12 ***

langEP 185.22 30.45 6.083 1.18e-09 ***

collTypecc -176.83 26.70 -6.624 3.50e-11 ***

collTypeeo -138.12 27.87 -4.956 7.20e-07 ***

collTypefc -246.22 27.03 -9.108 < 2e-16 ***

langBP:collTypecc -185.44 33.80 -5.486 4.11e-08 ***

langEP:collTypecc -142.59 3

... keep reading on reddit ➑

πŸ‘︎ 5
πŸ’¬︎
πŸ‘€︎ u/psydelle
πŸ“…︎ Jul 16 2021
🚨︎ report
Spi__
πŸ‘︎ 6k
πŸ’¬︎
πŸ‘€︎ u/Fast_Echidna_8520
πŸ“…︎ Jan 11 2022
🚨︎ report
What did 0 say to 8 ?

What did 0 say to 8 ?

" Nice Belt "

So What did 3 say to 8 ?

" Hey, you two stop making out "

πŸ‘︎ 9k
πŸ’¬︎
πŸ‘€︎ u/designjeevan
πŸ“…︎ Jan 03 2022
🚨︎ report
I had a vasectomy because I didn’t want any kids.

When I got home, they were still there.

πŸ‘︎ 10k
πŸ’¬︎
πŸ‘€︎ u/demotrek
πŸ“…︎ Jan 13 2022
🚨︎ report
I dislike karma whores who make posts that imply it's their cake day, simply for upvotes.

I won't be doing that today!

πŸ‘︎ 15k
πŸ’¬︎
πŸ‘€︎ u/djcarves
πŸ“…︎ Dec 27 2021
🚨︎ report
The Ancient Romans II
πŸ‘︎ 6k
πŸ’¬︎
πŸ‘€︎ u/mordrathe
πŸ“…︎ Dec 29 2021
🚨︎ report
How do you stop Canadian bacon from curling in your frying pan?

You take away their little brooms

πŸ‘︎ 6k
πŸ’¬︎
πŸ‘€︎ u/Majorpain2006
πŸ“…︎ Jan 09 2022
🚨︎ report
School Was Clothed
πŸ‘︎ 5k
πŸ’¬︎
πŸ‘€︎ u/Kennydoe
πŸ“…︎ Jan 08 2022
🚨︎ report
I did it, I finally did it. After 4 years and 92 days I went from being a father, to a dad.

This morning, my 4 year old daughter.

Daughter: I'm hungry

Me: nerves building, smile widening

Me: Hi hungry, I'm dad.

She had no idea what was going on but I finally did it.

Thank you all for listening.

πŸ‘︎ 17k
πŸ’¬︎
πŸ‘€︎ u/Sk2ec
πŸ“…︎ Jan 01 2022
🚨︎ report
It this sub dead?

There hasn't been a post all year!

πŸ‘︎ 13k
πŸ’¬︎
πŸ‘€︎ u/TheTreelo
πŸ“…︎ Jan 01 2022
🚨︎ report
Couch potato
πŸ‘︎ 8k
πŸ’¬︎
πŸ“…︎ Dec 31 2021
🚨︎ report
Baka!
πŸ‘︎ 5k
πŸ’¬︎
πŸ‘€︎ u/ridi86
πŸ“…︎ Jan 09 2022
🚨︎ report
Letting loose with these puns
πŸ‘︎ 6k
πŸ’¬︎
πŸ“…︎ Jan 13 2022
🚨︎ report
concrete πŸ—Ώ
πŸ‘︎ 5k
πŸ’¬︎
πŸ‘€︎ u/Fast_Echidna_8520
πŸ“…︎ Jan 07 2022
🚨︎ report
My name is ABCDEFGHIJKMNOPQRSTUVWXYZ

It’s pronounced β€œNoel.”

πŸ‘︎ 14k
πŸ’¬︎
πŸ‘€︎ u/beef_fried_rice
πŸ“…︎ Dec 25 2021
🚨︎ report

Please note that this site uses cookies to personalise content and adverts, to provide social media features, and to analyse web traffic. Click here for more information.