Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add function to normalise a set of weight values so that they sum to 1 #44

Closed
Assignees
delphidabbler
Labels
completedIssue completed and committed to develop. To be closed on next releaseenhancementNew feature or request
@delphidabbler

Description

@delphidabbler

The following routine is proposed:

functionNormaliseByWeight(const Weights:arrayof Double):  Types.TDoubleDynArray;var  Weight: Double;  WeightSum: Double;  Idx: Integer;beginif (System.Length(Weights) =0)then    raise SysUtils.EArgumentException.Create('Array of weights is empty');  WeightSum :=0.0;for Weightin Weightsdobeginif Math.Sign(Weight) = Math.NegativeValuethen      raise SysUtils.EArgumentException.Create('Weights must all be >= 0');    WeightSum := WeightSum + Weight;end;if Math.IsZero(WeightSum)then    raise SysUtils.EArgumentException.Create('Sum of weights can''t be zero');  System.SetLength(Result, System.Length(Weights));for Idx :=0to Pred(System.Length(Weights))do    Result[Idx] := Weights[Idx] / WeightSum;end;

Metadata

Metadata

Assignees

Labels

completedIssue completed and committed to develop. To be closed on next releaseenhancementNew feature or request

Projects

Status

Completed

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp