在Julia中:查找缺少值的数组的均值

时间:2018-09-07 05:53:21

标签: julia missing-data

如果缺少<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <!--in this view, horizontal and vertical both dialog has scrollable List and other view looks static--> <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="5"> <!--place your all top content here--> </LinearLayout> <!--weight 1 is giving List view the available space. --> <ListView android:id="@+id/listView" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="5"/> <Button android:id="@+id/button" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/app_name"/> </LinearLayout> 的任何元素,则统计信息包mean将返回missing

array

如何获取非缺失值的平均值?

1 个答案:

答案 0 :(得分:4)

skipmissing函数将仅将不丢失的元素发送到mean函数:

julia> using Statistics
julia> mean([1 2 3 4 5] )
3.0https://docs.julialang.org/en/stable/manual/missing/#Skipping-Missing-Values-1
julia> mean([1 2 missing 4 5] )  # Note missing value
missing
# Here is the answer:
julia> mean(skipmissing([1 2 missing 4 missing] ))
2.3333333333333335

正如@Milan Bouchet-Valat在对该问题的评论中指出的那样,missing上的文档为here。它们是一个很好的快速入门,首先阅读Julia对缺失值的处理。