# Undersampled least squares solution in FunctionalChaosAlgorithm

**URL:** <https://openturns.discourse.group/t/undersampled-least-squares-solution-in-functionalchaosalgorithm/79>\
**Category:** Methodology\
**Tags:** polynomial-chaos\
**Created:** [December 27, 2020, 9:24am UTC](https://openturns.discourse.group/t/undersampled-least-squares-solution-in-functionalchaosalgorithm/79 "2020-12-27T09:24:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dlouk](https://yyz2.discourse-cdn.com/free1/user_avatar/openturns.discourse.group/dlouk/32/85_2.png) [@dlouk](https://openturns.discourse.group/u/dlouk)\
**Post date:** [December 27, 2020, 9:24am UTC](https://openturns.discourse.group/t/undersampled-least-squares-solution-in-functionalchaosalgorithm/79/1 "2020-12-27T09:24:20Z")

</div>

Greetings,

I construct a PCE model using  
`algo = ot.FunctionalChaosAlgorithm(train_in, train_out, jpdf, adaptiveStrategy, projectionStrategy)`,  
with  
`projectionStrategy = ot.LeastSquaresStrategy()`  
`adaptiveStrategy = ot.FixedStrategy(multivariateBasis, enumerateFunction.getStrataCumulatedCardinal(p))`.

Having 9 input parameters and `p=3`, the PCE basis consists of 220 polynomials. For a training data set of size 100 or 200, I get a solution (an inaccurate one, but still a solution), which should not be the case if the standard normal equations or QR decomposition solution methods are used for the least squares minimization, since the least squares system is underdetermined.

So, my question is, what kind of algorithm is used “under the hood” to compute the least squares solution? Is it some kind of optimization algorithm? If yes, which one?

Best,  
Dimitris

---

<div class="post-metadata">

**Author:** ![regislebrun](https://yyz2.discourse-cdn.com/free1/user_avatar/openturns.discourse.group/regislebrun/32/154_2.png) [@regislebrun](https://openturns.discourse.group/u/regislebrun)\
**Post date:** [December 27, 2020, 2:30pm UTC](https://openturns.discourse.group/t/undersampled-least-squares-solution-in-functionalchaosalgorithm/79/2 "2020-12-27T14:30:17Z")

</div>

Hi Dimitris,

In the under determinate case, the least-squares solution is the solution of minimal norm among all the possible solutions, in the sense of the dgelsy LAPACK routine ([https://linux.die.net/man/l/dgelsy](https://linux.die.net/man/l/dgelsy). It makes sense here as we are using an orthogonal basis.

You can monitor which algorithm is used by adding `ot.Log.Show(ot.Log.INFO)`. You will get these two lines in the log flow:

```auto
INF - Run the approximation algorithm
INF - In PenalizedLeastSquaresAlgorithm::run(), use QR decomposition

```

Cheers  
Régis
