From: Vesely K. <ive...@fi...> - 2014-03-25 16:03:39
|
Hi Feiteng, thanks for noticing, it's fixed now, yes there should be used (vec-mean) everywhere. I added another auxiliary vector, as needed to avoid restricting the skewness to positive values. Surprisingly the variance values did not change, but after writing down the formulas, it has become clear why this should be the correct case. E((x-mu)^2) = E(x^2 -2*x*mu + mu^2) = E(x^2) -2*mu*E(x) +mu^2 = E(x^2) - 2*mu^2 +mu^2 = E((x-mu)*x) Karel. On 03/24/2014 04:29 PM, Daniel Povey wrote: > I think you are right, because "vec" does not have the mean subtracted. > This is Karel's code, so he'll decide the best way to proceed. It may > be easiest for him to fix it himself. > Thanks for noticing! > > Dan > > > > On Sun, Mar 23, 2014 at 5:11 AM, 李飞腾 <fei...@yo... > <mailto:fei...@yo...>> wrote: > > Hi: > I think the way to computer variance in MomentStatistics() is not > right. > variance-wiki http://en.wikipedia.org/wiki/Variance > usingApplyPow() to replace vec_aux.MulElements(vec); > std::string MomentStatistics(const Vector<Real> &vec) { > // we use an auxiliary vector for the higher order powers > Vector<Real> vec_aux(vec); > // mean > Real mean = vec.Sum() / vec.Dim(); > // variance > vec_aux.Add(-mean); > vec_aux.ApplyPow(2.0); //vec_aux.MulElements(vec); // (vec-mean)^2 > Real variance = vec_aux.Sum() / vec.Dim(); > vec_aux.ApplyPow(3.0/2.0); //vec_aux.MulElements(vec); // (vec-mean)^3 > Real skewness = vec_aux.Sum() / pow(variance, 3.0/2.0) / vec.Dim(); > vec_aux.ApplyPow(4.0/3.0); //vec_aux.MulElements(vec); // (vec-mean)^4 > Real kurtosis = vec_aux.Sum() / (variance * variance) / vec.Dim() > - 3.0; > // send the statistics to stream, > std::ostringstream ostr; > ostr << " ( min " << vec.Min() << ", max " << vec.Max() > << ", mean " << mean > << ", variance " << variance > << ", skewness " << skewness > << ", kurtosis " << kurtosis > << " ) "; > return ostr.str(); > } > Am I right? > What is the easiest way to contribute to kaldi? > Best! > feiteng li > > ------------------------------------------------------------------------------ > Learn Graph Databases - Download FREE O'Reilly Book > "Graph Databases" is the definitive new guide to graph databases > and their > applications. Written by three acclaimed leaders in the field, > this first edition is now available. Download your free book today! > http://p.sf.net/sfu/13534_NeoTech > _______________________________________________ > Kaldi-developers mailing list > Kal...@li... > <mailto:Kal...@li...> > https://lists.sourceforge.net/lists/listinfo/kaldi-developers > > |