« first day (2021 days earlier)      last day (2460 days later) » 

3:09 AM
I can use CityData[{Large, "California", "United States"}] to get all the large cities in CA. How can I see how Large is defined, so that I can substitute my own kinds of entity properties into the CityData invocation?
 
3:22 AM
@JohnFeminella The CityData documentation says, under "Details", that "large cities are typically defined as having populations above 100,000."
 
4:18 AM
@C.E. I understand that "large" means something roughly like EntityProperty["City", "Population" ⇒ 100000]. How do I see Mathematica's symbolic definition of Large? I'd like to make my own criterion (e.g., cities with population between 500k and 1M, or cities with an area of at least 10 square miles, etc.).
Basically I'm hoping to use the Large definition as a starting point because that'll probably be the easiest to modify to get what I want. Failing that, I'd settle for just being able to tell Mathematica directly via an EntityProperty.
 
I'm attempting to draw from a six-dimensional probability distribution (namely, the Boltzmann distribution over three dimensions each of position and momentum) using RandomVariate, and I'm getting the error "Sampling from the probability distribution […] is not implemented".
I've read through mathematica.stackexchange.com/questions/2635/…, and am wondering whether there are any newer workarounds available for newer versions (10 or 11) of Mathematica, as this would get extremely tedious when applied to > 2 dimensions.
(I would also be open, of course, to other methods besides those given by Sasha in the linked answer)
 
 
1 hour later…
5:26 AM
@JohnFeminella That's an interesting enough problem to ask on the main site.
@JulianWolf RandomVariate[] still has poor support for custom multivariate distributions, so you may well have to roll your own algorithm.
 
 
2 hours later…
7:49 AM
@Kuba @b3m2a1 and anyone else playing with paclets: you should be aware that the PacletManager` context will not be in the $ContextPath when the notebook's default context is set to "Unique to this Notebook". This when giving instructions to people on how to install something with PacletInstall, it is best to tell then to start with Needs["PacletManager`"].
 
8:06 AM
@Szabolcs that is good to know. Is that because it's just loaded by the Autoload system?
 
8:24 AM
@b3m2a1 I don't know how these "unique to notebook" contexts work. They cause some system variables (which are in the System context) to also be unique to the notebook. Examples are $Line and $ContextPath. As far as I can tell, the only effect here is that in that notebook the PacletManager context is not in the $ContextPath. But the package is still properly loaded (and loaded only once).
 
8:43 AM
@Szabolcs I meant more like, since it's loaded via a non-core mechanism it's not included on the standard $ContextPath. But it looks like the $ContextPath is even more bare-bones than I had expected. It's just the notebook context and "System`"
@JohnFeminella it's set at the level of DataPaclets`CityDataDump`ComputeFunction. See this for more info on what that means. You can set that at the EntityStore level.
Also this is the actual definition that computes Large:
Select[DataPaclets`CityDataDump`CountryCities[
  DataPaclets`CityDataDump`CanonCountry[
   DataPaclets`CityDataDump`country]],
 CityData[#1, "Population"] >= 100000 &]
 
 
1 hour later…
10:00 AM
@JohnFeminella The documentation suggests doing such queries using implicit entities, f.e. all large cities in the United States would be:
largeCities = EntityList@Entity[
    "City", {
     EntityProperty["City", "Country"] -> Entity["Country", "UnitedStates"],
     EntityProperty["City", "Population"] -> Between[{Quantity[100000, "People"], Quantity[Infinity, "People"]}]
     }];
This works for me. In the same way, the number of large cities in California would be:
largeCities = EntityList@Entity[
    "City", {
     EntityProperty["City", "AdministrativeDivision"] -> Entity["AdministrativeDivision", {"California", "UnitedStates"}],
     EntityProperty["City", "Population"] -> Between[{Quantity[100000, "People"], Quantity[Infinity, "People"]}]
     }];
This timed out for me, but in principle should work.
 
10:21 AM
1
Q: Is there any not bad way to mention something I did not on / for Stack Exchange?

b3m2a1Sometimes I write / do things that I think the community might be interested in, but I don't want to spam the community with junk and don't want to be / people think I'm self-promoting. And I'm wondering if there's any good, unobtrusive way to mention such things here. This came to mind because ...

 
 
4 hours later…
2:29 PM
In[1]:= {stuff, {stuff}, <|stuff -> bar|>} /. stuff -> foo
Out[1]= {foo, {foo}, <|stuff -> bar|>}
How do I get {foo, {foo}, <|foo -> bar|>} instead?
 
2:49 PM
@hftf You don't. At least not like this. Associations are atomic which means your questions is basically, why {1, 2, 1.2} /. 2->foo doesn't give {1, foo, 1.foo}.
 
No, that is not my question.
 
But you understand what atomic means, yes?
 
Yes, and that's not helping me solve the task.
 
But then you know what to do, not? You need to restructure your Association manually since a simple replace doesn't work
rule = stuff -> foo;

{stuff, {stuff}, <|stuff -> bar|>} /. {rule, a_Association :> KeyMap[# /. rule &, a]}
 
I have this but it's not general enough (only maps over a list, other things besides Association could be atomic and not get replaced)
StuffReplace1[expr_, replacements_] :=
 If[AssociationQ[#],
    Association[Normal[#] /. replacements],
    # /. replacements
    ] & /@ expr
 
3:00 PM
@hftf Yes. The problem is that there is no general way of accessing atomic structures (that don't look atomic). Let's say you replace the number 2 with a 3 and your list contains an image, then you need a completely different way of accessing the pixel structure.
Because with your simple replacement, pixels with the value 2 won't be replaced either.
 
Hm, I now see what you're getting at
 
And in version 11 there are quite a lot atomic structures, like Graphs and stuff. So the best you can do is to make a general replace function that handles you corner cases.
 
Damn, KeyMap and Normal both only apply one level deep
 
@hftf But this can be fixed.
 
What about ClearAttributes[Association,Atomic] or something :-|
Alright I'm fine with what I've got for now
 
4:04 PM
@hftf the atomiticity(?) of it is set by something like this: mathematica.stackexchange.com/a/139974/38205
Which leads to interesting stuff like this: Hold[Association[1 -> 2]] not formatting and this being possible: Hold[Association[1 -> 2]] /. (1 -> 2) -> 3
But this doesn't work: Hold[Evaluate@Association[1 -> 2]] /. (1 -> 2) -> 3
On that Evaluate call the expression itself is pegged as atomic
Effectively Association is a constructor for an Association instance. And all the nice stuff we do is defined for instances, not expressions containing the constructor.
 
4:39 PM
@J.M., thanks. I'm not experienced with rolling my own RNGs, are there any resources you would recommend reading up on, or any third-party utilities worth considering?
 
 
7 hours later…
11:58 PM
0
Q: What is up with questions at 3:00 AM?

b3m2a1So I sunk a few hours yesterday into looking at how questions score as a function of when they were asked. You can read the primary report of what I found here. Probably the most interesting part is this graph: That's a break down of average score for a question as a function of when in the d...

 

« first day (2021 days earlier)      last day (2460 days later) »