Wolfram Language Paclet Repository

Community-contributed installable additions to the Wolfram Language

Primary Navigation

    • Cloud & Deployment
    • Core Language & Structure
    • Data Manipulation & Analysis
    • Engineering Data & Computation
    • External Interfaces & Connections
    • Financial Data & Computation
    • Geographic Data & Computation
    • Geometry
    • Graphs & Networks
    • Higher Mathematical Computation
    • Images
    • Knowledge Representation & Natural Language
    • Machine Learning
    • Notebook Documents & Presentation
    • Scientific and Medical Data & Computation
    • Social, Cultural & Linguistic Data
    • Strings & Text
    • Symbolic & Numeric Computation
    • System Operation & Setup
    • Time-Related Computation
    • User Interface Construction
    • Visualization & Graphics
    • Random Paclet
    • Alphabetical List
  • Using Paclets
    • Get Started
    • Download Definition Notebook
  • Learn More about Wolfram Language

QuantileRegression

Guides

  • Quantile regression

Tech Notes

  • Quantile regression 3D examples
  • Quantile regression over weather time series

Symbols

  • NURBSBasis
  • QuantileEnvelope
  • QuantileEnvelopeRegion
  • QuantileRegressionFit
  • QuantileRegression
Quantile regression 3D examples
Noisy arrow wave
Square sombrero
Pyramid basis
Partial sombrero
In this notebook we develop in detail Quantile Regression (QR) examples over 3D data.
Load the Quantile regression paclet
In[1]:=
Needs["AntonAntonov`QuantileRegression`"]
Set random seed
SeedRandom[9903]
Noisy arrow wave
Generate random, "noisy wave" data
In[99]:=
{b,c}={-6,6};​​data=RandomReal[{b,c},{1200,2}];​​data=Map[Append[#,Sqrt[#〚1〛-b]+Sin[#〚1〛+Abs[#〚2〛]]+RandomVariate[NormalDistribution[0,0.3]]]&,data];​​Dimensions[data]
Out[102]=
{1200,3}
3D list plot of the data
In[103]:=
ListPointPlot3D[data,PlotRangeAll,PlotLabel"Noisy wave data",ImageSizeMedium]
Out[103]=
Data summary
In[104]:=
ResourceFunction["RecordsSummary"][data]
Out[104]=

1 column 1
Min
-5.99502
1st Qu
-2.98911
Mean
0.000101204
Median
0.018686
3rd Qu
2.9009
Max
5.99843
,
2 column 2
Min
-5.98586
1st Qu
-2.93213
Mean
0.022007
Median
0.120005
3rd Qu
2.85962
Max
5.99069
,
3 column 3
Min
-1.10056
1st Qu
1.58444
Mean
2.31921
Median
2.37921
3rd Qu
3.13401
Max
5.02893

NURBS basis
In[105]:=
basis=
NURBSBasis
[data〚All,1;;2〛,{7,4}];​​Length[basis]
Out[106]=
28
Quantile regression of probability 0.5
In[107]:=
AbsoluteTiming​​funcs=
QuantileRegressionFit
[data,Through[Values[basis][x,y]],{x,y},0.5];​​
Out[107]=
{0.3872,Null}
Plot the obtained function and data
In[108]:=
Show[​​ListPointPlot3D[data,PlotStyleRed,PlotRangeAll],​​Plot3D[funcs,{x,b,c},{y,b,c},PlotRangeAll,PlotStyle{Opacity[0.6]},PlotLegends0.5,MeshNone,PerformanceGoal"Quality"],​​BoxRatios{1,1,1/1.5},ImageSizeMedium]
Out[108]=
0.5
Quantile regression of probabilities 0.1 and 0.9
In[109]:=
qs={0.1,0.9};​​AbsoluteTiming​​funcs=AssociationThreadqs,
QuantileRegressionFit
[data,Through[Values[basis][x,y]],{x,y},qs];​​
Out[110]=
{0.62364,Null}
3D list plot of the data
In[111]:=
Show[​​ListPointPlot3D[data,PlotStyleRed,PlotRangeAll],​​Plot3D[Evaluate@Values@funcs,{x,b,c},{y,b,c},PlotRangeAll,PlotStyle{Opacity[0.6]},MeshNone,PerformanceGoal"Quality",PlotLegendsKeys[funcs]],​​BoxRatios{1,1,1/1.5},ImageSizeMedium]
Out[111]=
0.1
0.9
Count the number points under each surface
In[112]:=
sepPoints=Map[Function[{f},Length[Select[data,#〚-1〛<(f/.{x#〚1〛,y#〚2〛})〚1〛&]]],funcs]
Out[112]=
0.1127,0.91086
Here are the corresponding fractions (should correspond to the probabilities)
In[113]:=
sepFractions=N[sepPoints/Length[data]]
Out[113]=
0.10.105833,0.90.905
Pyramid basis
Define pyramid basis function
In[114]:=
Clear[PyramidBasisFunc];​​PyramidBasisFunc[{x0_,y0_},{x_,y_}]:=
(-1+x-x0)(-1+y-y0)
x0≤x&&x≤1+x0&&y0≤y&&y≤1+y0
-((-1+x-x0)(1+y-y0))
x0≤x&&x≤1+x0&&y0≤1+y&&y≤1+y0
0
x≥x0||1+x<x0||y>1+y0||1+y<y0
-((1+x-x0)(-1+y-y0))
x0≤1+x&&x≤1+x0&&y0≤y&&y≤1+y0
(1+x-x0)(1+y-y0)
True
;
Here is a plot of a basis function
Make basis for the sombrero data
Find regression quantiles for probability 0.2
Plot data and regression quantiles together
Square sombrero
Generate random, "square sombrero" data
3D list plot of the data
Data summary
NURBS basis
Quantile regression of probability 0.9
Plot functions and data
Partial sombrero
Generate random, "partial sombrero" data
3D list plot of the data
NURBS basis
Regression quantiles
Plot data and regression quantiles together
The plot above with corresponding exclusion region
Count the number points under each surface
Here are the corresponding fractions (should correspond to the probabilities)

© 2025 Wolfram. All rights reserved.

  • Legal & Privacy Policy
  • Contact Us
  • WolframAlpha.com
  • WolframCloud.com