本文整理汇总了C#中DoubleMatrix.Col方法的典型用法代码示例。如果您正苦于以下问题:C# DoubleMatrix.Col方法的具体用法?C# DoubleMatrix.Col怎么用?C# DoubleMatrix.Col使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DoubleMatrix
的用法示例。
在下文中一共展示了DoubleMatrix.Col方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Update
/// <summary>
/// Updates the given chart with the specified linear regression.
/// </summary>
/// <param name="chart">A chart.</param>
/// <param name="lr">Linear Regression.</param>
/// <param name="predictorIndex">The predictor (independent) variable to plot on the x-axis.</param>
/// <exception cref="InvalidArgumentException">
/// Thrown if the given predictorIndex is outside the range of columns in lr.PredictorMatrix.
/// </exception>
/// <remarks>
/// The multidimensional linear regression fit is plotted projected onto the plane of the specified
/// predictor variable.
/// <br/>
/// Titles are added only if chart does not currently contain any titles.
/// <br/>
/// The first two data series are replaced, or added if necessary.
/// </remarks>
public static void Update( ref ChartControl chart, LinearRegression lr, int predictorIndex )
{
if( predictorIndex < 0 || predictorIndex > lr.PredictorMatrix.Cols )
{
throw new Core.IndexOutOfRangeException( predictorIndex );
}
List<string> titles = new List<string>()
{
"LinearRegression",
};
string xTitle = "Independent Variable " + predictorIndex;
string yTitle = "Dependent Variable";
// create version of predictor matrix with all other columns zeroed out
DoubleMatrix projection = new DoubleMatrix( lr.PredictorMatrix.Rows, lr.PredictorMatrix.Cols );
projection[Slice.All, predictorIndex] = lr.PredictorMatrix.Col( predictorIndex );
DoubleMatrix data = new DoubleMatrix( lr.NumberOfObservations, 3 );
data[Slice.All, 0] = lr.PredictorMatrix.Col( predictorIndex ); // x
data[Slice.All, 1] = lr.Observations; // y
data[Slice.All, 2] = lr.PredictedObservations( projection ); // y predicted
data = NMathFunctions.SortByColumn( data, 0 );
List<ChartSeries> series = new List<ChartSeries>()
{
BindXY( data.Col(0), data.Col(1), ChartSeriesType.Scatter, DefaultMarker ),
// only necessary to plot endpoints of line
BindXY( data.Col(0)[new Slice(0, 2, data.Rows - 1)], data.Col(2)[new Slice(0, 2, data.Rows - 1)], ChartSeriesType.Line, ChartSymbolShape.None )
};
series[0].Text = "Observed";
series[1].Text = "Predicted";
Update( ref chart, series, titles, xTitle, yTitle );
}