In this unit here, we'll have fun.
Somehow in the last couple of days on Facebook,
a discussion brought out what Sebastian's weight is.
And I decided rather than telling people how much I weigh I turned this into statistics.
And upfront I want you to put everything together what we've done so far
using programming and since programming has been optional in this class
consider this unit optional but it'd be great if you had a chance to try it.
It's not that hard and at the end of the day you'll know something about me
that I rarely discuss in public.
Through a comment I made in class on Facebook a discussion erupted in our
Facebook STATS 101 discussion group what my actual weight is.
And here is the form that I posted.
They were asked to submit their best estimate how much I weight in kilograms,
and also to submit how much they thought I weighed a year ago.
And within a few hours, there was a good number of guesses
including this one over here that's about as much as the planet Pluto weighs
and also some negative guesses.
These are both the negative weight of Pluto each.
But other than that, there were lots of really good guesses.
And you can see in kilograms, some people think I weigh 80 or 65, others think I weigh 250.
I took the good guesses and added them into a large list called weight.
That's just below 100 of those and now I want to do a statistics on those.
The very first thing I did is I printed the mean estimate and it turns out to be negative.
It's -2.10x10²⁰, and it's a typical situation in statistics.
When you look at those numbers, most of them are actually pretty good guesses.
But these extreme guesses of 10²² or -10²² over here completely affect
and screw up the actual statistics.
Now, you've learned how to deal with this. You know everything about statistics.
What I want you to do is to now code a piece of software called calculate_weight
that has 3 things, and I think you can do all three of them yourself.
First, I want you to remove the outliers by only extracting data
between the lower and upper quartile.
It turns out the number of data points make it well defined
what the lower and upper quartile is.
And all test cases we run through have a well-defined number of data points.
And all the test cases we'll be using will have the property
that the lower and upper quartile are well-defined elements.
Then, I want you to fit a Gaussian using the maximum likelihood estimator.
And from there, I want you to compute the value x that corresponds
to the standard score z, so I'll be giving you not just the weight statistics or the weight data
but also where my extra weight is.
If you plug in the standard score of -2, which is two standard deviations below the mean
of the data that we will estimate, you'll find out my extra weight that I took this morning.
It's amazingly accurate.
But definitely, the data that you guys provided for this was overestimating my weight
and I'm happy to report by two standard deviations.
All these formulas are known,
and I think you have all the coding skills necessary from the past to fill these gaps.
Obviously, the first step is the hardest.
And when you're done with it, this command over here will give you the correct answer.
En esta unidad de aquí, vamos a divertirnos
De alguna manera en los últimos días en Facebook,
Se llevo a cabo una discusión de cual es el peso de Sebastian
Y decidí en lugar de decirle a las personas cuanto peso, lo convertí esto en estadística
Y por adelantado quiero que pongas todo lo que hemos hecho hasta ahora
Usando programación y como la programación ha sido opcional para la case
Considera esta unidad opcional, pero va a ser bueno si tienes la oportunidad de probarlo
No es tan complicado y al final del día, vas a saber algo sobre mí
Que raramente discuto en público
A través de un comentario que hice en clase para Facebook, una discusión hizo erupción en nuestro
grupo de discusión de Facebook STATS 101, de cual es mi verdadero peso
Y esta es la forma que publiqué
Se les pidió que mandaran su mejor estimación de cuanto peso en kilogramos
Y también que mandaran cuanto piensan que pesaba un año antes
Y en cuestión de unas horas, había un gran número de suposiciones
Incluida esta de aquí, que es lo mismo que pesa el planeta Plutón
Y algunas suposiciones negativas
Estas son ambas el peso negativo de Plutón
Pero aparte de esas, hubo varias que fueron muy buenas suposiciones
Y puedes ver en kilogramos, algunas personas pensaban que pesaba 80 o 65, otros pensaban que pesaba 250
Tomé las mejores suposiciones y las agregué en una lista larga llamada peso
Son un poco menos de 100 de esas y quiero hacer estadística de esas
La primera cosa que hice fue imprimir la media estimada y resultó ser que era negativa,
Es -2.10x10²⁰ y esta es una situación típica en estadística
Cuando observas estos números, la mayoría de ellos son realmente buenas suposiciones
Pero estas suposiciones extremas de 10²² o - 10²² de aquí, afectan completamente
Y arruinan las estadísticas actuales
Ahora haz aprendido como lidiar con esto, sabemos todo sobre estadística
Lo que quiero que hagas ahora es codificar un pedazo de software, llamado calculate_weight
Que tenga 3 cosa y pienso que puedes hacer las tres por ti solo
Primero quiero que remuevas los outliers, sólo al extraer datos
Entre el cuartil superior e inferior
Resulta ser que el número de puntos está bien definido
De cual es el cuartil superior e inferior
Y para todos los casos lo corremos a través, de un buen número de puntos bien definidos
Y para todos los casos de las pruebas, vamos a usar esa propiedad
De que el cuartil superior e inferior son elementos bien definidos
Ahora quiero que lo ajusten a un Gaussiano, usando el estimador de máxima verosimilitud
Y de aquí, quiero que calcules el valor de x que corresponde
Al valor estándar de z, entonces no sólo te voy a dar las estadísticas de los pesos o los datos de los pesos
Pero también donde está mi peso extra
Si lo conectas en el puntaje estándar de -2, que es dos desviaciones estándar por debajo de la media
De los datos que vamos a estimar, vas a encontrar mi peso extra que tomé en la mañana
Es increíblemente preciso
Pero definitivamente los datos que estos amigos dieron, sobre estimaron mi peso
Y soy feliz de reportar que por dos desviaciones estándar.
Todas estas fórmulas son conocidas
Y pienso que con todas las habilidades de programación necesarias del pasado, se pueden llenar estos espacios
Obviamente, el primer paso es el más complicado
Cuando termines, este comando de aquí te va a dar la respuesta correcta.
今日のレッスンは楽しいです
どういうわけかここ数日間のFacebookで
セバスチャンの体重という議論が起こりました
そこで私は体重を明かすのではなく
統計の問題にしてみました
まず最初に今まで学んできたことを
プログラミングでまとめてみましょう
このクラスではプログラミングは任意で
このレッスンも任意ですがぜひやってみてください
それほど難しくはありませんし終えた頃には
私の秘密も少し分かるかもしれません
以前このクラスでコメントしたことを発端に
101のディスカッショングループで
私の体重について議論がありました
そこでこのようなフォームを投稿しました
私の体重の推測値をキログラムで入力してもらい
さらに1年前の私の体重の推測値を質問しました
すると数時間の間に多くの推測値が集まりました
中にはこのようなデータもありました
冥王星の重さとほぼ同じですね
マイナスの推測値もありました
これらはどれも冥王星のマイナスの重さです
それ以外は妥当な数値が集まりました
これを見ると私の体重を80キロ、65キロ、
250キロだと推測している人もいますね
そこで私はこれらの推測値を基に
weightと名付けた長いリストを作りました
全部で100件弱ありますが
これらを基に統計を取るとします
まず最初に平均の推測値を入力すると
マイナスの値が出ました
-2.10✕10²⁰となっていますが
これは統計ではよくあることです
数値を見ると多くは妥当な推測値ですが
これらの10²²や
-10²²といった極端な値が影響して
実際の統計量を台無しにしています
このような場合の処理法は学びましたね
統計量に関してはすべて知っているはずです
それではこれからcalculate_weightという
プログラムを作成してみましょう
3つの要素で構成されますが
3つとも自分でできると思います
まずは外れ値を取り除くため
第1四分位数と第3四分位数の間の数値のみ抽出です
データを明確に定義するのです
第1と第3の四分位数を決め
テストケースでの一連のデータを明確にします
今後使用するすべてのテストケースでも
第1四分位数と第3四分位数が
明確なデータということになります
次に最尤推定量を使って
正規分布にフィッティングさせます
そしてそこから
偏差値zに対応するx値を計算します
そのために体重の統計量、体重データだけでなく
体重の増加分も提示します
ここではz=-2を代入しますがこれは
平均推測値を標準偏差2だけ下回るということです
すると今朝計った私の体重が分かりますが
これは驚くほど正確です
結果的に皆さんの推測値は
私の体重よりも多めでした
2つの標準偏差で
これを報告できることをうれしく思います
これらの公式は既出のものですし
ここに入力するコードの書き方も
すべてこれまでに学んだものです
当然最初のステップが最も難しいですが
これを完成させてコマンドを実行したら
正解が出るはずです