Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 0 additions & 109 deletions src/FSharp.Stats/Array.fs
Original file line number Diff line number Diff line change
Expand Up @@ -141,115 +141,6 @@ module Array =
let items' = Array.copy items
quickSelectInPlaceWith 0 (items'.Length - 1) k items'



///Old partitionSortInPlace fails with dublicates

///// Arranges the items between the left and right border, that all items left of the pivot element are smaller and bigger on the right.
///// Function works in place and returns the index of the pivote element
//let partitionSortInPlace left right (items:array<'T>) =

// // http://blog.mischel.com/2011/10/25/when-theory-meets-practice/
// // Median of three optimization improves performance in general,
// // and eliminates worst-case behavior for sorted or reverse-sorted data.
// let center = (right + left) / 2
// if (items.[left] > items.[right]) then
// swapInPlace left right items
// if (items.[center] < items.[left]) then
// swapInPlace center left items
// if (items.[center] > items.[right]) then
// swapInPlace center right items
// // // pick the pivot point and save it
// let pivot = items.[center]

// let rec moveRightIndex i j =
// if (pivot < items.[j]) && (i < j) then
// moveRightIndex i (j-1)
// else
// j

// let rec moveLeftIndex i j =
// if (items.[i] <= pivot) && (i < j) then
// moveLeftIndex (i+1) j
// else
// i

// let rec loop i j =
// if (i < j) then
// let j' = moveRightIndex i j
// let i' = moveLeftIndex i j'
// if i'=i && j'=j then // experimental to avoid: nan compare always false
// -1
// else
// if i' < j' then swapInPlace i' j' items
// loop i' j'
// else
// i

// let i = loop left right
// i


///// Finds the kth smallest element in an unordered array
//let inline quickSelect k (items:array<'T>) =
// let zero = LanguagePrimitives.GenericZero< 'T >

// let rec quickSelect' (items:array<'T>) left right k =

// // get pivot position
// let pivot = partitionSortInPlace left right items
// if pivot >= 0 then
// // if pivot is less than k, select from the right part
// if (pivot < k) then
// quickSelect' items (pivot + 1) right k
// // if pivot is greater than k, select from the left side
// elif (pivot > k) then
// quickSelect' items left (pivot - 1) k
// // if equal, return the value
// else
// items.[pivot]
// else
// zero / zero

// let k' = k - 1
// if k' <= 0 then
// Array.min items
// elif k' > items.Length-1 then
// Array.max items
// else
// let items' = Array.copy items
// quickSelect' items' 0 (items'.Length - 1) k'


///// Finds the kth smallest element in an unordered array
///// Works in place and can change the order of the elements in the input array
//let inline quickSelectInPlace k (items:array<'T>) : 'T =
// let zero = LanguagePrimitives.GenericZero< 'T >

// let rec quickSelect' (items:array<'T>) left right k =
// // get pivot position
// let pivot = partitionSortInPlace left right items
// if pivot >= 0 then
// // if pivot is less than k, select from the right part
// if (pivot < k) then
// quickSelect' items (pivot + 1) right k
// // if pivot is greater than k, select from the left side
// elif (pivot > k) then
// quickSelect' items left (pivot - 1) k
// // if equal, return the value
// else
// items.[pivot]
// else
// zero / zero

// let k' = k - 1
// if k' <= 0 then
// Array.min items
// elif k' > items.Length-1 then
// Array.max items
// else
// quickSelect' items 0 (items.Length - 1) k'

/// <summary>Computes the Weighted Mean</summary>
/// <remarks></remarks>
/// <param name="weights"></param>
Expand Down
1 change: 1 addition & 0 deletions src/FSharp.Stats/FSharp.Stats.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<PackageTags>F# FSharp dotnet data-science linear-algebra machine-learning fitting signal-processing statistical-testing</PackageTags>
<RepositoryUrl>https://github.com/fslaborg/FSharp.Stats</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<RepositoryBranch>developer</RepositoryBranch>
<FsDocsLicenseLink>https://github.com/fslaborg/FSharp.Stats/blob/developer/LICENSE</FsDocsLicenseLink>
<FsDocsReleaseNotesLink>https://github.com/fslaborg/FSharp.Stats/blob/developer/RELEASE_NOTES.md</FsDocsReleaseNotesLink>
</PropertyGroup>
Expand Down
Loading