<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">I would argue that you should treat this like a bug and just fix it.  The definitions are very standard and this violates the rule of least surprise (it also conflicts with numpy usage).  This will break some existing scripts but, speaking from painful experience, it is better to correct obvious mistakes earlier rather than later…</div><div class=""><br class=""></div><div class="">Cheers,</div><div class="">Greg</div><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 3, 2017, at 5:52 PM, Nathan Goldbaum <<a href="mailto:nathan12343@gmail.com" class="">nathan12343@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Ah, I see why you mean. Changing the name here would change the public-facing API, so I'm not sure there is a quick, easy fix here.</div><div class=""><br class=""></div><div class="">If you'd like, feel free to open an issue about this so we don't lose track:</div><div class=""><br class=""></div><div class=""><a href="https://bitbucket.org/yt_analysis/yt/issues/new" class="">https://bitbucket.org/yt_analysis/yt/issues/new</a><br class=""></div><div class=""><br class=""><div class="gmail_quote"><div class="">On Tue, Jan 3, 2017 at 4:43 PM Andrew Cunningham <<a href="mailto:ajcunn@gmail.com" class="">ajcunn@gmail.com</a>> wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Nathan,<br class="gmail_msg"><br class=""><br class="gmail_msg"><br class="">Thanks for pointing where to look for the variance computation.  I see in<br class="gmail_msg"><br class="">the profiles.py you linked to, line 192 in "_finalize_storage"<br class="gmail_msg"><br class=""><br class="gmail_msg"><br class="">       all_var = np.sqrt(all_var)<br class="gmail_msg"><br class=""><br class="gmail_msg"><br class="">which later is used to construct "self.variance".  So, after this line,<br class="gmail_msg"><br class="">"all_var" is really a standard deviation.<br class="gmail_msg"><br class=""><br class="gmail_msg"><br class="">Consequently, the example in the cookbook is correct.  The variance member<br class="gmail_msg"><br class="">of the profiles object is really the standard deviation.  There is no<br class="gmail_msg"><br class="">"bug" in the cookbook example.  Rather, this particular data member in the<br class="gmail_msg"><br class="">profile object is just misleadingly named.<br class="gmail_msg"><br class=""><br class="gmail_msg"><br class="">I don't currently have a dev version of yt setup.  I'm more of a humble<br class="gmail_msg"><br class="">user than agile developer into the yt innards.  I'd be happy to set that<br class="gmail_msg"><br class="">up and submit a pull request if that would be helpful, but I'm not sure<br class="gmail_msg"><br class="">what the "right" way to fix this is.<br class="gmail_msg"><br class=""><br class="gmail_msg"><br class="">One could remove the line:<br class="gmail_msg"><br class=""><br class="gmail_msg"><br class="">all_var = np.sqrt(all_var)<br class="gmail_msg"><br class=""><br class="gmail_msg"><br class="">so that the variance member is really the variance and update the cookbook<br class="gmail_msg"><br class="">example to take the square root inline when making the plot of mean and st<br class="gmail_msg"><br class="">dev.  Though, that would break user scripts already out in the wild that<br class="gmail_msg"><br class="">rely on "variance" really being the standard deviation.<br class="gmail_msg"><br class=""><br class="gmail_msg"><br class=""><br class="gmail_msg"><br class=""><br class="gmail_msg"><br class=""><br class="gmail_msg"><br class="">> Hi Andrew,<br class="gmail_msg"><br class="">><br class="gmail_msg"><br class="">> I think the code is simply using the terms "variance" and "standard<br class="gmail_msg"><br class="">> deviation" interchangeably here.<br class="gmail_msg"><br class="">><br class="gmail_msg"><br class="">> You can see how the `variance` array attached to the profile object is<br class="gmail_msg"><br class="">> calculated here:<br class="gmail_msg"><br class="">><br class="gmail_msg"><br class="">> <a href="https://bitbucket.org/yt_analysis/yt/src/09f0ef297d7068078a021fc8290d9e3519baf82d/yt/data_objects/profiles.py?at=yt&fileviewer=file-view-default#profiles.py-183" rel="noreferrer" class="gmail_msg" target="_blank">https://bitbucket.org/yt_analysis/yt/src/09f0ef297d7068078a021fc8290d9e3519baf82d/yt/data_objects/profiles.py?at=yt&fileviewer=file-view-default#profiles.py-183</a><br class="gmail_msg"><br class="">><br class="gmail_msg"><br class="">> I haven't looked up the mathematical definitions in detail, but I believe<br class="gmail_msg"><br class="">> that this is the sample variance at each profile bin (*not* the standard<br class="gmail_msg"><br class="">> deviation of the mean).<br class="gmail_msg"><br class="">><br class="gmail_msg"><br class="">> If you'd like, please feel free to send a pull request to update that<br class="gmail_msg"><br class="">> cookbook recipe to label the variance with "variance" instead of<br class="gmail_msg"><br class="">> "standard deviation". The code for the cookbook recipe is located here<br class="gmail_msg"><br class="">> in the repository:<br class="gmail_msg"><br class="">><br class="gmail_msg"><br class="">> <a href="https://bitbucket.org/yt_analysis/yt/src/09f0ef297d7068078a021fc8290d9e3519baf82d/doc/source/cookbook/profile_with_variance.py?at=yt&fileviewer=file-view-default" rel="noreferrer" class="gmail_msg" target="_blank">https://bitbucket.org/yt_analysis/yt/src/09f0ef297d7068078a021fc8290d9e3519baf82d/doc/source/cookbook/profile_with_variance.py?at=yt&fileviewer=file-view-default</a><br class="gmail_msg"><br class=""><br class="gmail_msg"><br class=""><br class="gmail_msg"><br class=""><br class="gmail_msg"><br class=""><br class="gmail_msg"><br class=""><br class="gmail_msg"><br class="">On Sat, 31 Dec 2016, Andrew Cunningham wrote:<br class="gmail_msg"><br class=""><br class="gmail_msg"><br class="">> In the following cookbook example:<br class="gmail_msg"><br class="">><br class="gmail_msg"><br class="">> <a href="http://yt-project.org/doc/cookbook/simple_plots.html#profiles-with-variance" rel="noreferrer" class="gmail_msg" target="_blank">http://yt-project.org/doc/cookbook/simple_plots.html#profiles-with-variance</a><br class="gmail_msg"><br class="">> -values<br class="gmail_msg"><br class="">><br class="gmail_msg"><br class="">> the variance along the profile is extracted:<br class="gmail_msg"><br class="">><br class="gmail_msg"><br class="">> variance = prof.variance['gas', 'velocity_magnitude'].value<br class="gmail_msg"><br class="">><br class="gmail_msg"><br class="">> but is then labelled as the standard deviation when the plot is created:<br class="gmail_msg"><br class="">><br class="gmail_msg"><br class="">> plt.loglog(radius, variance, label='Standard Deviation')<br class="gmail_msg"><br class="">><br class="gmail_msg"><br class="">> So, does "prof.variance" return the standard deviation and not the<br class="gmail_msg"><br class="">> variance?  Or, is the plot mislabelled?  Should the plot instead be:<br class="gmail_msg"><br class="">><br class="gmail_msg"><br class="">> plt.loglog(radius, np.sqrt(variance), label='Standard Deviation')<br class="gmail_msg"><br class="">><br class="gmail_msg"><br class="">><br class="gmail_msg"><br class="">>_______________________________________________<br class="gmail_msg"><br class="">yt-users mailing list<br class="gmail_msg"><br class=""><a href="mailto:yt-users@lists.spacepope.org" class="gmail_msg" target="_blank">yt-users@lists.spacepope.org</a><br class="gmail_msg"><br class=""><a href="http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org" rel="noreferrer" class="gmail_msg" target="_blank">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org</a><br class="gmail_msg"><br class=""></blockquote></div></div>
_______________________________________________<br class="">yt-users mailing list<br class=""><a href="mailto:yt-users@lists.spacepope.org" class="">yt-users@lists.spacepope.org</a><br class="">http://lists.spacepope.org/listinfo.cgi/yt-users-spacepope.org<br class=""></div></blockquote></div><br class=""></body></html>