# Announcing \`PolyChaos.jl\`

**URL:** https://discourse.julialang.org/t/announcing-polychaos-jl/21069
**Category:** Package Announcements
**Created:** [February 22, 2019, 8:28am UTC](https://discourse.julialang.org/t/announcing-polychaos-jl/21069 "2019-02-22T08:28:57Z")
**Posts on this page:** 13
**Page:** 1

<div class="post-metadata">

### Author: ![timueh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/timueh/32/12379_2.png) [@timueh](https://discourse.julialang.org/u/timueh)
#### Post date: [February 22, 2019, 8:28am UTC](https://discourse.julialang.org/t/announcing-polychaos-jl/21069/1 "2019-02-22T08:28:57Z")

</div>

I am happy to announce [`PolyChaos.jl`](https://github.com/timueh/PolyChaos.jl), a collection of functions for [orthogonal polynomials](https://en.wikipedia.org/wiki/Orthogonal_polynomials), [quadrature rules](https://en.wikipedia.org/wiki/Numerical_integration), and [polynomial chaos expansions](https://en.wikipedia.org/wiki/Polynomial_chaos).

What’s the idea?

Let’s say you have some non-negative function w: \Omega \longrightarrow \mathbb{R} and you would like to find the polynomals that are orthogonal relative to w. That’s the core functionality of `PolyChaos.jl`.

Why is that useful? Once you know the orthogonal polynomials, you can compute quadrature rules such aus [Gauss](http://mathworld.wolfram.com/GaussianQuadrature.html), [Gauss-Radau](http://mathworld.wolfram.com/RadauQuadrature.html), [Gauss-Lobatto](http://mathworld.wolfram.com/LobattoQuadrature.html). These quadrature rules allow you to solve integrals

\int\_\Omega f(x) w(x) \mathrm{d} x \approx \sum\_{i=1}^N \omega\_i f(\tau\_i).

The numbers (\omega\_i, \tau\_i) for i = 1, \dots, N _are_ the quadrature rule that `PolyChaos.jl` computes.

Finally, orthgonal polynomials are intricately linked to random variables. For example, Hermite polynomials (more specifically, [probabilists’ Hermite polynomials](https://en.wikipedia.org/wiki/Hermite_polynomials#Definition)) happen to be the orthogonal polynomials relative to the probability distribution of a standard Gaussian random variable, the well-known density w(x) = \exp(-x^2/2)/\sqrt{2 \pi}. The mathematical method that investigates the relation between orthogonal polynomials and random variables is called [polynomial chaos expansion](https://en.wikipedia.org/wiki/Polynomial_chaos), dating back to the infamous Norbert Wiener. Polynomial chaos is to random variables what Fourier series is to periodic signals – it allows you to represent some complicated mathematical object by a few deterministic numbers. Too abstract? Think of a Gaussian random variable – everything you need to know about it are its mean and variance. `PolyChaos.jl` let’s you compute polynomial chaos expansions of random variables.

I am fully aware that there are several great packages for quadrature out there such as [`QuadGK`](https://juliamath.github.io/QuadGK.jl/latest/), [`FastGaussQuadrature.jl`](https://github.com/ajt60gaibb/FastGaussQuadrature.jl) or [`ApproxFun.jl`](https://github.com/JuliaApproximation/ApproxFun.jl). As I see it, `PolyChaos.jl` is a complement, and by no means a replacement for those excellent packages. If you are interested in _how_ these quadrature rules come about, then perhaps `PolyChaos.jl` can provide insight(s).

The idea for the package was born out of the need to have a Julia package for polynomial chaos expansions (there was also a poster at [JuliaCon 2018](https://juliacon.org/2018/schedule)). There is still a _lot_ that can be added (and I will create issues for that) so any form of contribution is welcome!

This being my first software project I am sure there will be unexpected stuff to happen. Regardless, it has been a great experience so far and I am actively using the package for my research. Let’s see what happens!

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [February 22, 2019, 9:21am UTC](https://discourse.julialang.org/t/announcing-polychaos-jl/21069/2 "2019-02-22T09:21:31Z")

</div>

Nice! This’ll be a good starting place for SPDE expansions!

---

<div class="post-metadata">

### Author: ![timueh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/timueh/32/12379_2.png) [@timueh](https://discourse.julialang.org/u/timueh)
#### Post date: [February 22, 2019, 10:35am UTC](https://discourse.julialang.org/t/announcing-polychaos-jl/21069/3 "2019-02-22T10:35:17Z")

</div>

Yes!

A similar to-do is [this](https://github.com/timueh/PolyChaos.jl/issues/8): auto-generate Galerkin projections of ODEs. In the documentation of PolyChaos I did it by hand for a [scalar linear ODE](https://timueh.github.io/PolyChaos.jl/stable/random_ode/).

---

<div class="post-metadata">

### Author: ![DrPapa](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/drpapa/32/6835_2.png) [@DrPapa](https://discourse.julialang.org/u/DrPapa)
#### Post date: [February 22, 2019, 1:26pm UTC](https://discourse.julialang.org/t/announcing-polychaos-jl/21069/4 "2019-02-22T13:26:17Z")

</div>

Awesome stuff and great tutorials too. I’ve never used these types of approaches but I’ve looked into them in the past. Your documentation gives one of the most approachable introductions to the topic that I’ve seen.

---

<div class="post-metadata">

### Author: ![timueh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/timueh/32/12379_2.png) [@timueh](https://discourse.julialang.org/u/timueh)
#### Post date: [February 27, 2019, 9:45am UTC](https://discourse.julialang.org/t/announcing-polychaos-jl/21069/5 "2019-02-27T09:45:00Z")

</div>

Good news: [PolyChaos.jl v0.1.1](https://github.com/timueh/PolyChaos.jl/releases/tag/v0.1.1) is out. The improvements as summarized in [NEWS.md](https://github.com/timueh/PolyChaos.jl/blob/master/NEWS.md):

- improved performance of recurrence coefficients, quadrature rules, evaluation of orthogonal polynomials
- added considerable number of tests for recurrence coefficients and quadrature rules
- added code coverage
- added GNU General Public License v3.0
- removed dependency on `IterTools`

---

<div class="post-metadata">

### Author: ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)
#### Post date: [February 28, 2019, 12:53am UTC](https://discourse.julialang.org/t/announcing-polychaos-jl/21069/6 "2019-02-28T00:53:01Z")

</div>

Is there any particular reason you chose GPL? In the Julia community it is more usual to use MIT.

---

<div class="post-metadata">

### Author: ![billmclean](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/billmclean/32/3790_2.png) [@billmclean](https://discourse.julialang.org/u/billmclean)
#### Post date: [March 3, 2019, 11:42pm UTC](https://discourse.julialang.org/t/announcing-polychaos-jl/21069/7 "2019-03-03T23:42:50Z")

</div>

The [GaussQuadrature.jl](https://github.com/billmclean/GaussQuadrature.jl) package can generate all of the classical Gauss rules in multiple precision (as `BigFloat` arrays), and also rules for a log weight function.

---

<div class="post-metadata">

### Author: ![timueh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/timueh/32/12379_2.png) [@timueh](https://discourse.julialang.org/u/timueh)
#### Post date: [March 4, 2019, 8:03am UTC](https://discourse.julialang.org/t/announcing-polychaos-jl/21069/8 "2019-03-04T08:03:13Z")

</div>

It’s mostly because my bosses said so (great reason, I know…). I am aware of the [discussions](https://discourse.julialang.org/search?q=why%20choose%20this%20license) about the licenses and I am doing by best to persuade them. 🙂

---

<div class="post-metadata">

### Author: ![timueh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/timueh/32/12379_2.png) [@timueh](https://discourse.julialang.org/u/timueh)
#### Post date: [March 4, 2019, 8:11am UTC](https://discourse.julialang.org/t/announcing-polychaos-jl/21069/9 "2019-03-04T08:11:38Z")

</div>

This is great, thanks! I have to admit that our focus was not so much on arbitrary precision of quadrature rules, but having a workflow from _weight_ → _recursion coefficients_ → _quadrature rule_ → _polynomial chaos_. It just so happened that quadrature rules became an important part. `PolyChaos` also has support for Lobatto and Radau quadrature.

There is a difference though: I saw that you implemented the Chebyshev and modified Chebyshev algorithms. In `PolyChaos` I chose to go with Stieltjes and Lanczos procedures. The reason being that the Chebyshev algorithm can lead to ill-conditioned problems. There is also an implementation of Gautschi’s multiple discretization procedure which allows you do to [this](https://timueh.github.io/PolyChaos.jl/stable/multiple_discretization/) for example.  
Having said all that, we should perhaps get in touch and chat! There is interesting overlap.

---

<div class="post-metadata">

### Author: ![swissr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/swissr/32/208_2.png) [@swissr](https://discourse.julialang.org/u/swissr)
#### Post date: [March 4, 2019, 9:24am UTC](https://discourse.julialang.org/t/announcing-polychaos-jl/21069/10 "2019-03-04T09:24:07Z")

</div>

(offtopic) Another [discussion](https://discourse.julialang.org/t/in-development-bitcoin-jl-a-julia-bitcoin-library/17944) about licenses: Bitcoin.jl released as GPL, later switched to MIT.

---

<div class="post-metadata">

### Author: ![billmclean](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/billmclean/32/3790_2.png) [@billmclean](https://discourse.julialang.org/u/billmclean)
#### Post date: [March 4, 2019, 9:47am UTC](https://discourse.julialang.org/t/announcing-polychaos-jl/21069/11 "2019-03-04T09:47:31Z")

</div>

My GaussQuadrature.jl package is mostly a re-write of a Fortran 95 code descended from the original implementation [gaussq.f](https://www.netlib.org/cgi-bin/netlibfiles.pl?filename=/go/gaussq.f) of the Golub-Welsch algorithm.

---

<div class="post-metadata">

### Author: ![timueh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/timueh/32/12379_2.png) [@timueh](https://discourse.julialang.org/u/timueh)
#### Post date: [March 4, 2019, 9:58am UTC](https://discourse.julialang.org/t/announcing-polychaos-jl/21069/12 "2019-03-04T09:58:29Z")

</div>

It would be interesting the replace the current `golubwelsch()` with your `special_eigenproblem!()`.

---

<div class="post-metadata">

### Author: ![timueh](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/timueh/32/12379_2.png) [@timueh](https://discourse.julialang.org/u/timueh)
#### Post date: [September 8, 2019, 11:41am UTC](https://discourse.julialang.org/t/announcing-polychaos-jl/21069/13 "2019-09-08T11:41:10Z")

</div>

I am pleased to announce that [`PolyChaos.jl`](https://github.com/timueh/PolyChaos.jl) is now available in version 0.2.0. The major difference to the 0.1.x versions is a [cleaner type hierarchy](https://timueh.github.io/PolyChaos.jl/stable/type_hierarchy/), building on top of `AbstractMeasure`, `AbstractOrthoPoly`, `AbstractQuad`, and `AbstractTensor`. Check out the [docs](https://timueh.github.io/PolyChaos.jl/stable/) for details.

There are also new examples: orthogonal bases for Gaussian mixture models, and polynomial chaos for optimal power flow problems. [Other power flow problems are implemented here.](https://github.com/timueh/PowerFlowUnderUncertainty)
