Skip to content

Commit c9f090b

Browse files
committed
moved BasicStats.std
1 parent 27ee90e commit c9f090b

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

core/api/core.api

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4131,11 +4131,13 @@ public final class org/jetbrains/kotlinx/dataframe/api/SumKt {
41314131
public static synthetic fun sumFor$default (Lorg/jetbrains/kotlinx/dataframe/api/PivotGroupBy;[Lorg/jetbrains/kotlinx/dataframe/columns/ColumnReference;ZZILjava/lang/Object;)Lorg/jetbrains/kotlinx/dataframe/DataFrame;
41324132
public static final synthetic fun sumNumber (Lorg/jetbrains/kotlinx/dataframe/DataColumn;)Ljava/lang/Number;
41334133
public static final fun sumNumber (Lorg/jetbrains/kotlinx/dataframe/DataColumn;Z)Ljava/lang/Number;
4134+
public static final fun sumNumber (Lorg/jetbrains/kotlinx/dataframe/DataFrame;ZLkotlin/jvm/functions/Function2;)Ljava/lang/Number;
4135+
public static final fun sumNumber (Lorg/jetbrains/kotlinx/dataframe/DataFrame;Z[Lkotlin/reflect/KProperty;)Ljava/lang/Number;
4136+
public static final fun sumNumber (Lorg/jetbrains/kotlinx/dataframe/DataFrame;[Lorg/jetbrains/kotlinx/dataframe/columns/ColumnReference;Z)Ljava/lang/Number;
41344137
public static synthetic fun sumNumber$default (Lorg/jetbrains/kotlinx/dataframe/DataColumn;ZILjava/lang/Object;)Ljava/lang/Number;
4135-
public static final fun sumOfByte (Lorg/jetbrains/kotlinx/dataframe/DataColumn;Lkotlin/jvm/functions/Function1;)I
4136-
public static final fun sumOfByte (Lorg/jetbrains/kotlinx/dataframe/DataFrame;Lkotlin/jvm/functions/Function2;)I
4137-
public static final fun sumOfShort (Lorg/jetbrains/kotlinx/dataframe/DataColumn;Lkotlin/jvm/functions/Function1;)I
4138-
public static final fun sumOfShort (Lorg/jetbrains/kotlinx/dataframe/DataFrame;Lkotlin/jvm/functions/Function2;)I
4138+
public static synthetic fun sumNumber$default (Lorg/jetbrains/kotlinx/dataframe/DataFrame;ZLkotlin/jvm/functions/Function2;ILjava/lang/Object;)Ljava/lang/Number;
4139+
public static synthetic fun sumNumber$default (Lorg/jetbrains/kotlinx/dataframe/DataFrame;Z[Lkotlin/reflect/KProperty;ILjava/lang/Object;)Ljava/lang/Number;
4140+
public static synthetic fun sumNumber$default (Lorg/jetbrains/kotlinx/dataframe/DataFrame;[Lorg/jetbrains/kotlinx/dataframe/columns/ColumnReference;ZILjava/lang/Object;)Ljava/lang/Number;
41394141
public static final fun sumShort (Lorg/jetbrains/kotlinx/dataframe/DataColumn;)I
41404142
public static final fun sumShort (Lorg/jetbrains/kotlinx/dataframe/DataFrame;Lkotlin/jvm/functions/Function2;)I
41414143
public static final fun sumShort (Lorg/jetbrains/kotlinx/dataframe/DataFrame;[Lkotlin/reflect/KProperty;)I
@@ -6446,8 +6448,7 @@ public final class org/jetbrains/kotlinx/dataframe/math/PercentileKt {
64466448
}
64476449

64486450
public final class org/jetbrains/kotlinx/dataframe/math/StdKt {
6449-
public static final fun std (Ljava/lang/Iterable;Lkotlin/reflect/KType;ZI)D
6450-
public static synthetic fun std$default (Ljava/lang/Iterable;Lkotlin/reflect/KType;ZIILjava/lang/Object;)D
6451+
public static final fun std (Lkotlin/sequences/Sequence;Lkotlin/reflect/KType;ZI)D
64516452
}
64526453

64536454
public final class org/jetbrains/kotlinx/dataframe/math/SumKt {

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/math/basicStats.kt

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,10 @@
22

33
package org.jetbrains.kotlinx.dataframe.math
44

5-
import org.jetbrains.kotlinx.dataframe.api.ddof_default
65
import org.jetbrains.kotlinx.dataframe.api.skipNaN_default
7-
import kotlin.math.sqrt
86

97
internal data class BasicStats(val count: Int, val mean: Double, val variance: Double)
108

11-
/**
12-
* Calculates the standard deviation from a [BasicStats] with optional delta degrees of freedom.
13-
*
14-
* @param ddof delta degrees of freedom, the bias-correction of std.
15-
* Default is [ddof_default], so `ddof = 1`, the "unbiased sample standard deviation", but alternatively,
16-
* the "population standard deviation", so `ddof = 0`, can be used.
17-
*/
18-
internal fun BasicStats.std(ddof: Int): Double =
19-
if (count <= ddof) {
20-
Double.NaN
21-
} else {
22-
sqrt(variance / (count - ddof))
23-
}
24-
259
/**
2610
* Creates [BasicStats] instance for [this] sequence.
2711
*

core/src/main/kotlin/org/jetbrains/kotlinx/dataframe/math/std.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import org.jetbrains.kotlinx.dataframe.impl.nothingType
88
import org.jetbrains.kotlinx.dataframe.impl.renderType
99
import java.math.BigDecimal
1010
import java.math.BigInteger
11+
import kotlin.math.sqrt
1112
import kotlin.reflect.KType
1213
import kotlin.reflect.typeOf
1314

@@ -67,3 +68,17 @@ internal val stdTypeConversion: CalculateReturnType = { _, _ ->
6768
@JvmName("doubleStd")
6869
internal fun Sequence<Double>.std(skipNaN: Boolean = skipNaN_default, ddof: Int = ddof_default): Double =
6970
calculateBasicStatsOrNull(skipNaN)?.std(ddof) ?: Double.NaN
71+
72+
/**
73+
* Calculates the standard deviation from a [BasicStats] with optional delta degrees of freedom.
74+
*
75+
* @param ddof delta degrees of freedom, the bias-correction of std.
76+
* Default is [ddof_default], so `ddof = 1`, the "unbiased sample standard deviation", but alternatively,
77+
* the "population standard deviation", so `ddof = 0`, can be used.
78+
*/
79+
internal fun BasicStats.std(ddof: Int): Double =
80+
if (count <= ddof) {
81+
Double.NaN
82+
} else {
83+
sqrt(variance / (count - ddof))
84+
}

0 commit comments

Comments
 (0)