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
Pyramid basis
Square sombrero
Partial sombrero
In this notebook we develop in detail Quantile Regression (QR) examples over 3D data.
Load the Quantile regression paclet
In[259]:=
Needs["AntonAntonov`QuantileRegression`"]
Set random seed
In[260]:=
SeedRandom[9903]
Out[260]=
RandomGeneratorState
Method: ExtendedCA
State hash: 4817281099379168455

Define plot function
In[261]:=
QRPlot[data_List,funcs_Association,opts___]:=​​Show[​​ListPointPlot3D[data,PlotStyleRed,PlotRangeAll],​​Plot3D[Evaluate@Values@funcs,{x,Min[data〚All,1〛],Max[data〚All,1〛]},{y,Min[data〚All,2〛],Max[data〚All,2〛]},​​opts,​​PlotRangeAll,PlotStyle{Opacity[0.7]},MeshTrue,PlotTheme"LightMesh",PerformanceGoal"Quality",PlotLegendsKeys[funcs]],​​BoxRatios{1,1,1/2},ImageSizeMedium];
Noisy arrow wave
Generate random, "noisy wave" data
In[262]:=
{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[265]=
{1200,3}
3D list plot of the data
In[266]:=
ListPointPlot3D[data,PlotRangeAll,PlotLabel"Noisy wave data",BoxRatios{1,1,1/2},ImageSizeMedium]
Out[266]=
Data summary
In[267]:=
ResourceFunction["RecordsSummary"][data]
Out[267]=

1 column 1
Min
-5.97766
1st Qu
-2.90678
Median
-0.0115437
Mean
0.0790118
3rd Qu
3.2109
Max
5.99364
,
2 column 2
Min
-5.99067
1st Qu
-3.10103
Median
-0.0858424
Mean
-0.0158792
3rd Qu
3.04382
Max
5.99541
,
3 column 3
Min
-1.13656
1st Qu
1.51994
Mean
2.28272
Median
2.32303
3rd Qu
3.13985
Max
4.94725

NURBS basis
In[268]:=
basis=
NURBSBasis
[data〚All,1;;2〛,{7,4}];​​Length[basis]
Out[269]=
28
Quantile regression of probability 0.5
In[270]:=
AbsoluteTiming​​funcs=
QuantileRegressionFit
[data,Through[Values[basis][x,y]],{x,y},0.5];​​
Out[270]=
{0.351396,Null}
Plot the obtained function and data
In[271]:=
QRPlot[data,0.5First[funcs]]
Out[271]=
0.5
Quantile regression of probabilities 0.1 and 0.9
In[272]:=
probs={0.1,0.9};​​AbsoluteTiming​​funcs=AssociationThreadprobs,
QuantileRegressionFit
[data,Through[Values[basis][x,y]],{x,y},probs];​​
Out[273]=
{0.612908,Null}
3D list plot of the data
In[274]:=
QRPlot[data,funcs]
Out[274]=
Count the number points under each surface
In[275]:=
sepPoints=Map[Function[{f},Length[Select[data,#〚-1〛<(f/.{x#〚1〛,y#〚2〛})〚1〛&]]],funcs]
Out[275]=
0.1119,0.91080
Show the corresponding fractions (should correspond to the probabilities)
In[276]:=
sepFractions=N[sepPoints/Length[data]]
Out[276]=
0.10.0991667,0.90.9
Square sombrero
Generate random, "square sombrero" data
In[277]:=
{b,c}={-6,6};​​data=RandomReal[{b,c},{1200,2}];​​data=Map[Append[#,Exp[-#.#/(c-b)/2](Sin[Abs[#〚1〛]+Abs[#〚2〛]]+RandomVariate[NormalDistribution[0,0.2]])]&,data];​​Dimensions[data]
3D list plot of the data
Data summary
NURBS basis
Quantile regression of probability 0.9
Plot functions and data
Pyramid basis
Define a pyramid basis function
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
Partial sombrero
Generate random, "partial sombrero" data
3D list plot of the data
NURBS basis
Regression quantiles
Plot data and regression quantiles together
Create a region object for the convex hull of the data points
The plot data and regression quantiles over the region above
Count the number points under each surface
Show the corresponding fractions (should correspond to the probabilities)

© 2025 Wolfram. All rights reserved.

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