Ranking
Summary: this tutorial demonstrates how to determine ranks of a collection
Consider a collection of values. The rank of a number is its size relative to other values in a sequence. There are four methods how to handle ties:
let mySequence = [|1.0; -2.0; 0.0; 1.0|]
-
rankFirst
- Each rank occurs exactly once. If ties are present the first occurence gets the low rank.
- ATTENTION: If there are multiple ties (>20) the sorting of Arrays will not preserve the element order correctly!!
ranks = [3,1,2,4]
-
rankMin
- If ties are present all tied elements receive the score of the first occurence (min rank)
ranks = [3,1,2,3]
-
rankMax
- If ties are present all tied elements receive the score of the last occurence (max rank)
ranks = [4,1,2,4]
-
rankAverge
- If ties are present all tied elements receive their average rank.
ranks = [3.5,1,2,3.5]
NaN treatment
If nans are present in the collection, there are several ways to treat them. In general nan <> nan so that each occurence will receive its unique rank.
(for infinity and -infinity the equality check returns true).
- Usually nans are sorted to the beginning of the collection:
nan, -infinity, -100., 0., 100, infinity - By default in FSharp.Stats.Rank, nans are sorted to the end of the sequence (the sorting can be defined as optional parameter)
- Additionally ranks of nan values are set to nan if not specified othwerwise
open FSharp.Stats
let collection = [|2.;-infinity;infinity;infinity;nan;0|]
Rank.RankFirst() collection
// result: [|3.0; 1.0; 4.0; 5.0; nan; 2.0|]
Rank.RankMin() collection
// result: [|3.0; 1.0; 4.0; 4.0; nan; 2.0|]
Rank.RankMax() collection
// result: [|3.0; 1.0; 5.0; 5.0; nan; 2.0|]
Rank.RankAverage() collection
// result: [|3.0; 1.0; 4.5; 4.5; nan; 2.0|]
If you want to preserve the true ranks of nans but sort them to the back you can use:
Rank.RankFirst(RankNanWithNan=false) collection
// result: [|3.0; 1.0; 4.0; 5.0; 6.0; 2.0|]
If you want to preserve the true ranks of nans AND sort them to the beginning you can use:
Rank.RankFirst(NanIsMaximum=false,RankNanWithNan=false) collection
// result: [|4.0; 2.0; 5.0; 6.0; 1.0; 3.0|]
namespace FsMath
namespace Plotly
namespace Plotly.NET
module Defaults
from Plotly.NET
<summary> Contains mutable global default values. Changing these values will apply the default values to all consecutive Chart generations. </summary>
<summary> Contains mutable global default values. Changing these values will apply the default values to all consecutive Chart generations. </summary>
val mutable DefaultDisplayOptions: Plotly.NET.DisplayOptions
Multiple items
type DisplayOptions = inherit DynamicObj new: unit -> DisplayOptions static member addAdditionalHeadTags: additionalHeadTags: XmlNode list -> (DisplayOptions -> DisplayOptions) static member addDescription: description: XmlNode list -> (DisplayOptions -> DisplayOptions) static member combine: first: DisplayOptions -> second: DisplayOptions -> DisplayOptions static member getAdditionalHeadTags: displayOpts: DisplayOptions -> XmlNode list static member getDescription: displayOpts: DisplayOptions -> XmlNode list static member getPlotlyReference: displayOpts: DisplayOptions -> PlotlyJSReference static member init: [<Optional; DefaultParameterValue ((null :> obj))>] ?AdditionalHeadTags: XmlNode list * [<Optional; DefaultParameterValue ((null :> obj))>] ?Description: XmlNode list * [<Optional; DefaultParameterValue ((null :> obj))>] ?PlotlyJSReference: PlotlyJSReference -> DisplayOptions static member initCDNOnly: unit -> DisplayOptions ...
--------------------
new: unit -> Plotly.NET.DisplayOptions
type DisplayOptions = inherit DynamicObj new: unit -> DisplayOptions static member addAdditionalHeadTags: additionalHeadTags: XmlNode list -> (DisplayOptions -> DisplayOptions) static member addDescription: description: XmlNode list -> (DisplayOptions -> DisplayOptions) static member combine: first: DisplayOptions -> second: DisplayOptions -> DisplayOptions static member getAdditionalHeadTags: displayOpts: DisplayOptions -> XmlNode list static member getDescription: displayOpts: DisplayOptions -> XmlNode list static member getPlotlyReference: displayOpts: DisplayOptions -> PlotlyJSReference static member init: [<Optional; DefaultParameterValue ((null :> obj))>] ?AdditionalHeadTags: XmlNode list * [<Optional; DefaultParameterValue ((null :> obj))>] ?Description: XmlNode list * [<Optional; DefaultParameterValue ((null :> obj))>] ?PlotlyJSReference: PlotlyJSReference -> DisplayOptions static member initCDNOnly: unit -> DisplayOptions ...
--------------------
new: unit -> Plotly.NET.DisplayOptions
static member Plotly.NET.DisplayOptions.init: [<System.Runtime.InteropServices.Optional; System.Runtime.InteropServices.DefaultParameterValue ((null :> obj))>] ?AdditionalHeadTags: Giraffe.ViewEngine.HtmlElements.XmlNode list * [<System.Runtime.InteropServices.Optional; System.Runtime.InteropServices.DefaultParameterValue ((null :> obj))>] ?Description: Giraffe.ViewEngine.HtmlElements.XmlNode list * [<System.Runtime.InteropServices.Optional; System.Runtime.InteropServices.DefaultParameterValue ((null :> obj))>] ?PlotlyJSReference: Plotly.NET.PlotlyJSReference -> Plotly.NET.DisplayOptions
type PlotlyJSReference =
| CDN of string
| Full
| Require of string
| NoReference
<summary> Sets how plotly is referenced in the head of html docs. </summary>
<summary> Sets how plotly is referenced in the head of html docs. </summary>
union case Plotly.NET.PlotlyJSReference.NoReference: Plotly.NET.PlotlyJSReference
module StyleParam
from Plotly.NET
namespace Plotly.NET.LayoutObjects
val mySequence: float array
Multiple items
namespace FSharp
--------------------
namespace Microsoft.FSharp
namespace FSharp
--------------------
namespace Microsoft.FSharp
namespace FSharp.Stats
val collection: float array
val infinity: float
val nan: float
Multiple items
type Rank = new: unit -> Rank static member RankAverage: ?NanIsMaximum: bool * ?RankNanWithNan: bool -> ('a array -> float array) (requires equality) static member RankFirst: ?NanIsMaximum: bool * ?RankNanWithNan: bool -> (#IComparable array -> float array) static member RankMax: ?NanIsMaximum: bool * ?RankNanWithNan: bool -> ('a array -> float array) (requires equality) static member RankMin: ?NanIsMaximum: bool * ?RankNanWithNan: bool -> ('a array -> float array) (requires equality)
<summary> The rank of a number is its size relative to other values in a sequence </summary>
--------------------
new: unit -> Rank
type Rank = new: unit -> Rank static member RankAverage: ?NanIsMaximum: bool * ?RankNanWithNan: bool -> ('a array -> float array) (requires equality) static member RankFirst: ?NanIsMaximum: bool * ?RankNanWithNan: bool -> (#IComparable array -> float array) static member RankMax: ?NanIsMaximum: bool * ?RankNanWithNan: bool -> ('a array -> float array) (requires equality) static member RankMin: ?NanIsMaximum: bool * ?RankNanWithNan: bool -> ('a array -> float array) (requires equality)
<summary> The rank of a number is its size relative to other values in a sequence </summary>
--------------------
new: unit -> Rank
static member Rank.RankFirst: ?NanIsMaximum: bool * ?RankNanWithNan: bool -> (#System.IComparable array -> float array)
static member Rank.RankMin: ?NanIsMaximum: bool * ?RankNanWithNan: bool -> ('a array -> float array) (requires equality)
static member Rank.RankMax: ?NanIsMaximum: bool * ?RankNanWithNan: bool -> ('a array -> float array) (requires equality)
static member Rank.RankAverage: ?NanIsMaximum: bool * ?RankNanWithNan: bool -> ('a array -> float array) (requires equality)
FSharp.Stats