本文整理汇总了C#中Vector.Min方法的典型用法代码示例。如果您正苦于以下问题:C# Vector.Min方法的具体用法?C# Vector.Min怎么用?C# Vector.Min使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector
的用法示例。
在下文中一共展示了Vector.Min方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PrepareMultilevel
/// <summary>
/// Compute indices of boxes at all levels for each basis function
/// </summary>
/// <param name="rcx">x-coordinates of basis functions centers</param>
/// <param name="rcy">y-coordinates of basis functions centers</param>
/// <param name="rcz">z-coordinates of basis functions centers</param>
/// <param name="N">Number of basis functions (length of rcx, rcy, and rcz)</param>
/// <param name="finest_level_size">size of finest level in multilevel subdivision</param>
/// <returns>
/// Matrix with one column per level in multilevel subdivision
/// Columns contain the box index in which a basis function is located Row index is the basis function index
/// </returns>
public static BasicFuncBoxes PrepareMultilevel(Vector rcx, Vector rcy, Vector rcz, int N, double finest_level_size)
{
double xmax = rcx.Max(); double xmin = rcx.Min();
double ymax = rcy.Max(); double ymin = rcy.Min();
double zmax = rcz.Max(); double zmin = rcz.Min();
int Lx = (int)Math.Ceiling(Math.Log((xmax - xmin) / (finest_level_size)) / Math.Log(2));
int Ly = (int)Math.Ceiling(Math.Log((ymax - ymin) / (finest_level_size)) / Math.Log(2));
int Lz = (int)Math.Ceiling(Math.Log((zmax - zmin) / (finest_level_size)) / Math.Log(2));
int L = (int)Math.Max(Lx, Math.Max(Ly, Lz));
double box_size_x = (xmax - xmin) * (1 + 1e-3);
double box_size_y = (ymax - ymin) * (1 + 1e-3);
double box_size_z = (zmax - zmin) * (1 + 1e-3);
double box_size = Math.Max(box_size_x, Math.Max(box_size_y, box_size_z));
BasicFuncBoxes basicFuncBoxes = new BasicFuncBoxes(N, L);
for (int i = 0; i < L; i++)
{
box_size = box_size / 2;
Vector tempVx = new DenseVector(rcx.Count);
for (int j = 0; j < rcx.Count; j++)
{
tempVx[j] = Math.Floor((rcx[j] - xmin) / box_size);
}
Vector tempVy = new DenseVector(rcy.Count);
for (int j = 0; j < rcy.Count; j++)
{
tempVy[j] = Math.Floor((rcy[j] - ymin) / box_size);
}
Vector tempVz = new DenseVector(rcz.Count);
for (int j = 0; j < rcz.Count; j++)
{
tempVz[j] = Math.Floor((rcz[j] - zmin) / box_size);
}
basicFuncBoxes.X.SetColumn(i, tempVx);
basicFuncBoxes.Y.SetColumn(i, tempVy);
basicFuncBoxes.Z.SetColumn(i, tempVz);
}
return basicFuncBoxes;
}
示例2: CalculateConditional
internal double CalculateConditional(Vector y, Vector x)
{
if (x == null && y == null)
throw new InvalidOperationException("x and y do not exist!");
var values = x.Distinct();
var valueCount = values.Count();
double result = 0;
// binary split
if (Width == 2)
{
// do binary split based on mean
var mean = x.Mean();
var ltSlice = y.Slice(x.Indices(d => d < mean));
var gtSlice = y.Slice(x.Indices(d => d >= mean));
var lh = Calculate(ltSlice);
var rh = Calculate(gtSlice);
result = (0.5 * lh) + (0.5 * rh);
SplitValues = new double[] { x.Min(), mean, x.Max() + 1 };
}
// if valueCount has more values than
// width allows, segment out data to
// fit width
else if (valueCount > Width)
{
double p = 0;
double h = 0;
// create segmentation
// should really consider
// some kind of distribution
// for doing segmentation..
SplitValues = x.Segment(Width);
// for convenience ;)
SplitValues[SplitValues.Length - 1] += 1;
for (int i = 1; i < SplitValues.Length; i++)
{
// get slice
var s = x.Indices(d => d >= SplitValues[i - 1] && d < SplitValues[i]);
// probability of slice
p = s.Count() / (double)x.Length;
// Impurity (y | x_i)
h = Calculate(y.Slice(s));
// sum up
result += p * h;
}
}
// otherwise perform regular counting
// exercises to find cond entropy
else
{
double p = 0;
double h = 0;
// says there is no width
// since deterministic
// slice values
_width = 0;
SplitValues = new double[valueCount];
int k = -1;
// each disting x value
foreach (var i in values)
{
SplitValues[++k] = i;
// get slice
var s = x.Indices(d => d == i);
// probability of x_i
p = s.Count() / (double)x.Length;
// Impurity (y | x_i)
h = Calculate(y.Slice(s));
// sum up
result += p * h;
}
}
return result;
}
示例3: ShowResults
private void ShowResults()
{
if (rbBestNetwork.Checked)
{
mSelectedActivationNetwork = mBestActivationNetwork;
}
if (rbBestTestNetwork.Checked)
{
mSelectedActivationNetwork = mBestTestActivationNetwork;
}
if (rbGenetic.Checked)
{
mSelectedActivationNetwork = mBestGeneticActivationNetwork;
}
try
{
TVec dy = null;
TVec dx = null;
fittedChart.Series.Clear();
fittedChart.Series.Add(new Steema.TeeChart.Styles.FastLine());
fittedChart.Series.Add(new Steema.TeeChart.Styles.FastLine());
fittedChart.Series[0].Title = "наблюдения";
fittedChart.Series[1].Title = "прогнози";
fittedChart.Axes.Left.Title.Text = "Y";
fittedChart.Axes.Bottom.Title.Text = "";
fittedChart.Axes.Left.Automatic = true;
Vector timeseries = new Vector((TestEnd-ExtractBegin) + 1);
Vector abs = new Vector((TestEnd - ExtractBegin) + 1);
int? dependent_variable_id = 0;
foreach (int? dep in this.DependentVariables.Keys)
{
dependent_variable_id = dep;
}
MainDataSetTableAdapters.VARIABLESTableAdapter adptVariables = new Plig.TimeSeries.Client.MainDataSetTableAdapters.VARIABLESTableAdapter();
mindep = adptVariables.MinObservationValue(ExtractBegin, TestEnd, dependent_variable_id.Value).Value;
factordep = 1.7 / (adptVariables.MaxObservationValue(ExtractBegin, TestEnd, dependent_variable_id.Value).Value - adptVariables.MinObservationValue(ExtractBegin, TestEnd, dependent_variable_id.Value).Value);
int cnt = ExtractBegin;
foreach (KeyValuePair<int, double?> d in this.VariableObservations(dependent_variable_id.Value))
{
if (d.Key >= ExtractBegin && d.Key <= TestEnd)
{
try
{
timeseries.Values[cnt - ExtractBegin] = d.Value.Value;
}
catch
{
timeseries.Values[cnt - ExtractBegin] = 0.0;
}
abs.Values[cnt - ExtractBegin] = cnt;
cnt++;
}
}
dy = timeseries;
dx = abs;
Dew.Math.Tee.TeeChart.DrawValues(dx, dy, fittedChart.Series[0], false);
// Извличаме стойностите на независимите променливи
TVec dy1 = null;
Vector timeseries1 = new Vector(TestEnd - ExtractBegin + 1);
int independent_vars = this.IndependentVariables.Count;
double[] tuple = new double[independent_vars];
for (int i = ExtractBegin; i <= TestEnd; i++)
{
int cnt1 = 0;
foreach (int variable_id in this.IndependentVariables.Keys)
{
double factor = 1.7 / ( (this.SeriesInfo[variable_id]).Max - (this.SeriesInfo[variable_id]).Min);
tuple[cnt1] = (this.SeriesInfo[variable_id].Values[i].Value - (this.SeriesInfo[variable_id]).Min) * factor - 0.85;
cnt1++;
}
double value = (mSelectedActivationNetwork.Compute(tuple)[0] + 0.85) / factordep + mindep;
timeseries1.Values[i - ExtractBegin] = value;
}
dy1 = timeseries1;
Dew.Math.Tee.TeeChart.DrawValues(dx, dy1, fittedChart.Series[1], false);
residuals = new TVec();
residuals.Length = timeseries1.Length;
for (int i = 0; i < residuals.Length; i++)
{
residuals.Values[i] = timeseries1.Values[i] - timeseries.Values[i];
}
Vector Bins = new Vector(0);
Vector Freq = new Vector(0);
chartResiduals.Series[0].Title = "остатъци";
chartResiduals.Series[1].Title = "Нормално разпределение";
chartResiduals.Axes.Left.Title.Text = "Y";
chartResiduals.Axes.Bottom.Title.Text = "";
//.........这里部分代码省略.........
示例4: InitPlotter
private void InitPlotter(Vector.FxVectorF vec, PlotType plotType, Color color)
{
// init the lists
listPlotsGeometry = new List<PlotGeometry>();
// set the position and the size of the element
this.Position = new Vector.FxVector2f(0);
this.Size = new Vector.FxVector2f(750, 500);
// add the vector to the list
PlotGeometry plot = new PlotGeometry();
plot.OrigVectorY = vec;
plot.Color = color.ToColor4();
plot.Type = plotType;
plot.StepType = XStepType.ZeroToMax;
// add the plot to the list
listPlotsGeometry.Add(plot);
// set the origin position
{
float max = vec.Max();
float min = vec.Min();
float orig_y = Size.Y / 2;
if(max >0 && min<0)
{
orig_y = Size.Y * (min / (max - min));
}
if(max >0 && min >= 0)
{
orig_y = -min;
}
if(max <=0 && min <0)
{
orig_y = Size.Y + max;
}
OriginPosition = new Vector.FxVector2f(5, orig_y);
}
// allocate scale
_scale = new Vector.FxVector2f(1.0f);
// fit the plots to the view
FitPlots();
// set the x_step base on the size of vec and the width
X_Space = this.Size.x / vec.Size;
// init format
_TextFormat = new TextElementFormat();
_TextFormat.familyName = "Calibri";
_TextFormat.weight = SharpDX.DirectWrite.FontWeight.Black;
_TextFormat.fontStyle = SharpDX.DirectWrite.FontStyle.Normal;
_TextFormat.fontStretch = SharpDX.DirectWrite.FontStretch.Normal;
_TextFormat.fontSize = 8.0f;
// init toolstrip
InitToolStrips();
}