6 ms·
Statistical Physics with R: Ising Model with Monte Carlo
- northlondoner 1y agoR ecosystem provides amazing reproducible research ecosystem, even for statistical physics.
- Qem 1y agoI wonder how close R was to also take over the scientific computing/machine learning space, instead of Python's numpy/scipy ecosystem.
- mamami 1y agoIt was never close. Its synthax is unintuitive and painful to learn as a science undergrad. If it hadn't been python it would have been another language.
- physicsguy 1y agoPython's rapid adoption really came out of NumPy, SciPy, Matplotlib copying the interfaces from MATLAB, which was very widely used before but obviously had a cost associated.
- UpsideDownRide 1y agoThis is obviously a personal thing but tidyverse syntax is great and lends itself very well to clear and concise data operations.
- kjkjadksj 1y agoI found base R even easier than tidyverse. Geom?? Puke. Just call the plot function you want from the standard library. Everything is just function(arg1=x, arg2=y). Easy.
- mhog_hn 1y agoOne general purpose web framework away
- rjdj377dhabsn 1y agoI disagree. R is just not a very nice language. It has some really great statistical and data science packages that were well ahead of the competition 10-15 years ago. The web frameworks were good enough for dashboards and what most people were using R for. But if you wanted to write fast and elegant nom-vectorized code, R is really lacking. I left it for Julia for that reason.
- mvieira38 1y agoHow is Julia in terms of data science dev experience? Nothing ever felt as good as the R+tidyverse combo to me, at least in Python.
- rjdj377dhabsn 1y agoJulia is pretty good at basic data science. Working with dataframes is comparable to R's data.tables with the benefit that I don't need to switch languages if I want to run a fast loop over some data as part of a calculation or use a custom data structure. I'm not a fan of pandas, so I'd say Julia and R beat python at basic dataframe manipulation. Nothing beats kdb+/q at dataframes though imo.
- mvieira38 1y agoHave you tried Polars in Python? When you get going it's pretty similar to tidyverse, except you're chaining methods instead of piping, and it's lazily evaluated + parallel because of the underlying Rust engine. IME it's tidyverse > polars > pandas > data.table in terms of ergonomics
- mhogers 1y agoI agree somewhat with you - nonetheless a FastAPI + Alembic + SQLAlchemy alternative in R would make it possible to use it as a general purpose language
- larrydag 1y agoVery close. In fact you could still say that it still is competing with Python for users. There is still an active community of developers.
- teruakohatu 1y agoI love and use R, but it never became the dominant ML in part because it has three (or more) different object systems and many libraries sort of use their own style. This makes it seem a bit disjointed, in a way that other languages don’t. The R community should have anointed one object system and made tidyverse a core part of R. All that said, R is fantastic and the depth of libraries is extensive. Libs are often written by the original researchers that develop the method. At some academic institutions an R package is counted as a paper.
- mvieira38 1y agoAgree 100% on tidyverse becoming part of the standard library. Some of the language's greatest libraries (like Hyndman's forecasting stuff) basically assume you're using tidyverse already
- kjkjadksj 1y agoScrew that. I do everything that tidyverse does with the standard library already. No clue why the wheel had to be reinvented just to make a plot.
- tylermw 1y agoThe developing S7 object system (https://github.com/RConsortium/S7 https://github.com/RConsortium/S7) is looking fairly promising in that it combines many of the nice properties of S3 and S4 (validation, multiple dispatch, sane constructors) while still being fairly simple and straightforward to use.
- northlondoner 1y agoExcellent news. Quite promising, but R's power is its been actually functional natively. Even binary operations are functions, `+`(x,y) would work as in x+y
- paddleon 1y ago> The R community should have anointed one object system > and made tidyverse a core part of R. Not a tidyverse fan. It doesn't scale well. Learn data.table, which has a much more R-like interface and is fast fast fast even for large data sizes. More powerful and more expressive than pandas, and again, faster See https://cran.r-project.org/web/packages/data.table/vignettes/datatable-intro.html https://cran.r-project.org/web/packages/data.table/vignettes...
- 3abiton 1y agoR is really not for production deployment. It lacks a lot of what made python popular, and its target users were radically different.
- shoo 1y agoR was developed for and by statisticians, for better and worse. I used R a little bit 15-20 years ago, what I remember was that quite a few libraries and function interfaces seemed to be designed to be convenient for interactive use, but if you tried to use them in an automated script, e.g. some analysis you wanted to scale up and repeat 10,000 times while bootstrap sampling or hyperparameter sweeping or what have you, those same library and interface design choices involved bizarre edge cases where functions would sometimes do something completely different (perhaps changing the return type) when invoked with slightly different arguments. All these automation hostile edge causes were annoying to discover and then work around. None of this was forced by R the language, it was purely a library design thing by the folks writing the libraries. Whereas in contrast, you simply wouldn't and didn't get such library design in mainstream general purpose programming languages (e.g. in C++, java some of this stuff wouldn't even type check) and similarly in python, even though python being dynamic was fertile ground for people to develop completely bonkers and unautomatable numeric and scientific libraries, the customs for how libraries should work were different This is maybe just a reflection that R and R's libraries were being designed for interactive use by humans doing exploratory data analysis, model fitting etc, unlike other programming languages which are used to automate things or build software products that can be shipped.
- kjkjadksj 1y agoI think what people miss about R is that if you go on with an object oriented for loop way of writing code like a lot of python devs tend to do, you are going to have a bad time. You write functional code and make use of various apply functions instead of loops, it’s going to be very performant. A lot of it is wrapping C.
- dkga 1y agoCompletely disagree. I work at a central bank, helping people make some of the most important economic decisions in my country and plenty of analyses are done purely with R.
- shiandow 1y agoIn statistical physics they still use C a lot, as far as I know.
- northlondoner 1y agoGood observation. IsingLenzMC indeed core is written in C. R provides great C interfacing facilities.
- cactusfrog 1y agoThe issue with R is that there is too much dsl. This is great for one-off analysis but makes building a cohesive large code base really difficult.
- UpsideDownRide 1y agoYeah that's def part of it. As fun as it is there is just too much of it and people jump for it too readily, tidyverse included.
- analog31 1y agoI think that early on, people started using Python because they liked the language, before they used it for numerical computation. Many people were satisfied with an installation of Matlab, C, or whatever, on their desks. But they started using Python as a scripting language, before asking: Wouldn't it be nice if we could use Python for everything? For instance in my own case, my first use of Python was outside of mainstream scientific computing. I needed something to install on lab computers, for data acquisition and automation. And it needed to be free because my employer was under a spending freeze after the 2008 financial meltdown. Oh, and I also wanted something for hobby projects, that would be equally at home on Windows or Linux. So I think the quality of the language came first.
- evanb 1y agoIf you're interested in HMC, we showed how to apply it to the Ising model in https://arxiv.org/abs/1912.03278 https://arxiv.org/abs/1912.03278 with code available in https://github.com/HISKP-LQCD/ising_hmc https://github.com/HISKP-LQCD/ising_hmc
- nakamoto_damacy 1y agoDoes the use of "Statistical Physics" as opposed to "Statistical Mechanics" indicates a European author or a broader scope?
- whyever 1y agoThey are synonyms.
- nakamoto_damacy 1y agoPhysics and Mechanics are not synonyms. The latter is a small subset of the former.
- whyever 1y agoYes, but this relation does but apply to statistical mechanics and statistical physics, they mean the same: https://en.wikipedia.org/wiki/Statistical_mechanics https://en.wikipedia.org/wiki/Statistical_mechanics What is included in "statistical physics" that is not included in "statistical mechanics"?
- northlondoner 1y agoThere is a distinction. Usually statistical mechanics means the ensemble theory and partition functions that connects microscopic systems to macroscopic ones from material point of views. However, statistical physics is a bit more generic, for example complex networks may not use ensemble theory or partition functions and could use only statistics on the network, such as average neighbourhood or similar.
- kgwgk 1y agoPeople have also used “statistical physics” to refer to the former concept since forever. For example Landau. “Statistical mechanics” is also used in a broad sense, just like “quantum mechanics” is often used for anything “quantum”.
- DrNosferatu 1y agoAnyone can recommend a good and straightforward to understand -- general -- tutorial or book in Monte Carlo methods, for beginners?
- oersted 1y agoThe "Monte Carlo" term is deceivingly fancy, most algorithms with that label simply involve randomly picking from a set of possibilities (search space), as opposed to trying all cases or exploring in some other systematic way. When you try do that for real problems, it can sometimes be difficult to sample from complex probability distributions/models efficiently in a way that is representative. There are lots of tricks around that, like most topics it's a black-hole of details. But it still boils down to randomly testing options. Look at the source code, even in C it's really short and simple: https://github.com/msuzen/isingLenzMC/blob/master/src/isingLib.c https://github.com/msuzen/isingLenzMC/blob/master/src/isingL... Statisticians like to do this kind of intellectual inflation, there are many such scary terms with simple meanings: "Markov Chain" is a process who's next state depends only on the current state, "stochastic" is a straight-up synonym for "random"... Illegitimi non carborundum!
- dynm 1y agoI think there is a "correct" answer to this question! The best book on Monte Carlo methods is this one: https://artowen.su.domains/mc/ https://artowen.su.domains/mc/ It's not published yet, but already a classic. (Might be more intermediate than beginner, though.) For something a bit more gentle, I also recommend chapter 29 of this book: https://www.inference.org.uk/mackay/itila/book.html https://www.inference.org.uk/mackay/itila/book.html
- quag 1y agoI recommend starting here: https://youtu.be/nKCT-Cdk0xY https://youtu.be/nKCT-Cdk0xY Once you understand and use this approach, you can figure out most other approaches you need to use.
- the-mitr 1y agothis might be elementary but is a good introduction https://archive.org/details/TheMonte-carloMethodlittleMathematicsLibrary https://archive.org/details/TheMonte-carloMethodlittleMathem...
- frustratedSpin 1y agoWhy is this worth posting? Simulating a 1D Ising model is a homework exercise for undergrads.
- emil-lp 1y agoLucky 10,000.
- northlondoner 1y agoSee above comment regarding ergodicity.
- deleted 1y ago[deleted]
- epistasis 1y agoDoes anybody have a reason this particular repo might be of special interest today? It appears to be the methods from something published a decade ago, and has had a handful of commits since then, including yesterday. There's not a ton of stars on the github, but certainly more stars than most scientific methods get.
- random3 1y agoNo idea. But curious- why would something that was published a decad or longer ago not be of interest today?
- randmeerkat 1y ago> No idea. But curious- why would something that was published a decad or longer ago not be of interest today? Because if it isn’t in the “hype” it’s worthless, obsolete, trash… Welcome to the new world of tech, that warms its hands by burning the old world. Enjoy the vibes…
- oersted 1y agoJust wanted to stop by and say: cool writing. I don't quite agree, rather melodramatic, but it really paints a picture.
- epistasis 1y agoThe commit yesterday, on a very quiet repo, made me think there might be something more going on, that might be obvious to those who study the topic but not so obvious to a broader audience. Also, older papers can be of interest but don't usually make it to the front page of a general audience news site unless there's something bigger going on that gave it renewed general interest.
- northlondoner 1y agoGreat point. Hope the following add a context that was missing: Apart from intellectual appeal, (1) there was a new paper from Google about quantum ergodicity, see https://doi.org/10.48550/arXiv.2506.10191 https://doi.org/10.48550/arXiv.2506.10191 . So in general tech community can benefit a lot from understanding ergodicity via this package and see hands on how it is implemented, see Vignette as well, https://cran.r-project.org/web/packages/isingLenzMC/vignettes/isingLenzMC.pdf https://cran.r-project.org/web/packages/isingLenzMC/vignette... (2) The repo is part of ergodicity research that is now revisited from classical point of view. actually new commits are significant, a new dataset is generated. See, https://zenodo.org/records/17151290 https://zenodo.org/records/17151290 , so reproducibility is amazing even after so many years.
- candseven 1y ago[dead]
- techlatest_net 1y ago[dead]
- revanwjy 1y ago[flagged]
- chistev 1y agoPiggybacking off this to ask how to make my Monte Carlo simulations run faster? They are so frustratingly slow that the app is basically unusable.