A First Look at PyScript: Python in the Web Browser – Real Python
https://realpython.com/pyscript-python-in-browser/
Discussions: https://discu.eu/q/https://realpython.com/pyscript-python-in-browser/
Ah, gotcha.
Quick question: how do you consider the effect that you only have 4 suits for every card?
Alright, so I couldn't help myself and ran the optimization problem in AMPL 😅 .
Before I get to my results, I want to make one more observation I made. Since we are dividing all the combinations by 52!, the solutions follow a multivariate hypergeometric distribution:
\(\frac{\prod_{i \in \{1,\dots,13\}}(\text{4 nCr} a_i)}{(\text{52 nCr }\vec{a}^T\textbf{1})}\)
Now, when I ran the optimization algorithm through AMPL, I got a total of 41,846 solutions of the form \(\vec{a}=[a_1,a_2,a_3,a_4,a_5,a_6,a_7,a_8,a_9,a_{10},a_{11},a_{12},a_{13}]^T\). I ported over my answers into a csv file so that I can do the combination/probability calculations in Python. Just for my own verification, I checked to see if all of the solutions had a sum of 52 and were all unique combinations (my trust in getting the right settings in AMPL is not high 😅 ), which thankfully they were. Then, I calculated the probabilities by the number of combinations divided by 52! and by the multivariate hypergeometric distribution method. Then, the sum of each of these probabilities resulted in the total probability.
So, the answer I got was...
40.9%!
This number seems very high compared to everyone else's simulations, so if anyone wants to see my code, please let me know, and I will post it to GitHub. I have attached a screenshot of my Python results that includes the total number of combinations and the probabilities. With that said, I really enjoyed this problem and had a lot of fun solving it!
@christianp Since the deck is shuffled you can transpose the "look at the next card" and "remove the required number of cards" steps. This means it's equivalent to drawing cards from the top until they either sum to 52 (success) or higher (failure).
This doesn't really give a full answer, only simplifies the problem a little.
@christianp That's single player blackjack with 52 instead of 21, innit?
Playing with the pack of cards on my desk, something just happened that I didn't expect!
Look at the deck with the cards face-up. Here's a rule: look at the top card. Draw that many cards from the deck. Repeat until the deck is empty.
I did this, and dealt out exactly the right number of cards (at the end, I had 3 cards left and the top card was a 3).
What's the probability of this happening?
So I've been thinking about the problem almost like a knapsack problem. Let \(\vec{c}=[1,2,3,4,5,6,7,8,9,10,11,12,13]^T\), which is the vector of card values, and \(\vec{a}=[a_1,a_2,a_3,a_4,a_5,a_6,a_7,a_8,a_9,a_{10},a_{11},a_{12},a_{13}]^T\) where \(\forall_{i \in \{1,\dots,13\}} a_i \in \{0,\dots,4\}\), which are the number of individual cards (e.g., 4 aces, 1 twos, etc.). Then, solutions to the puzzle could be written as the following:
\(\min (\vec{c}^T\vec{a}-52)^2\)
s.t.
\(\vec{a}^T\textbf{1} \leq 52\)
Thus, any solution found by this minimization problem would have \(\vec{c}^T\vec{a}=52\). Then, given a solution, the number of combinations for the solution is as follows:
\((\vec{a}^T\textbf{1})! \times (52-\vec{a}^T\textbf{1})! \times \prod_{i \in \{1,\dots,13\}}(4 nCr a_i)\)
The total number of combinations is the sum of all of these values.
Of course, solving the minimization problem is difficult, but I would assume just like the linear knapsack problem, dynamic programming, as @narain mentioned before, would do the trick. Please let me know if I have made any mistakes.
@rastinza @tripu @ImperfectIdea
I'd clarify a little more: science uses inductive reasoning while mathematics uses deductive reasoning. I wouldn't entirely classify mathematics as philosophy due to mathematics' rigor, but yes, I would not clarify mathematics as a science.
@ImperfectIdea @tripu @rastinza
"An infant science of human well being" 😆
Tell me you don't understand moral philosophy without telling me you don't understand moral philosophy...
@tripu
Btw, I would not classify mathematics as science.
It's much more a branch of philosophy, definitely doesn't follow the scientific method.
@sojournTime @ImperfectIdea
@tripu @rastinza @ImperfectIdea
I don't know about banks, nuclear safety agencies, or public transport regulators, but I do know that public health most definitely uses moral philosophy and ethics to resolve resource allocation. This was very acutely applied during the pandemic:
https://qz.com/1821843/ethicists-agree-on-who-should-get-treated-first-for-coronavirus/
@tripu @rastinza @ImperfectIdea
Alright, let's start with a simple example where scientific reasoning fails (I'll assume that mathematical reasoning falls under this discipline). Suppose I proposed a choice: I give you $100 dollars guaranteed, or I flip a fair coin and if it lands on heads, I give you $200. Decision theory tells me that the expected value for both choices are $100 (1*$100=$100 vs. 0.5*$200=$100). So, there's no reason for me to choose either choice: they are both equally valued.
Now, suppose I changed the values to $1,000,000 and $2,000,000 respectively. Decision theory still tells me that both decisions are equally valued, but I would assume most people would choose the $1,000,000. Nothing in decision theory would have told me to make that choice. Yet it's pretty obvious why: $1,000,000 is life changing and risking a coin flip to get $2,000,000 is not worth the additional $1,000,000. Sure, maybe behavioral economics might be able to provide a better explanation, but it is definitely difficult to give a quantitative answer.
Now, let's change the prompt a little bit. Suppose instead there is a sinking ship, and a life boat has a maximum capacity of 100. If 200 people board the life boat, there is a 50% chance it will sink before it gets to safety. What decision should be made for the people on the ship? Again, decision theory states that both decisions are equivalent, but philosophically, they are not equivalent. I would argue no additional measurements or quantities would help make a more informed decision. This clearly falls into the realm of moral philosophy, not science.
@tripu @rastinza @ImperfectIdea
According to Wikipedia ( https://en.m.wikipedia.org/wiki/Science ):
"Science is a systematic enterprise that builds and organizes knowledge in the form of testable explanations and predictions about the universe."
For engineering ( https://en.m.wikipedia.org/wiki/Engineering ):
"Engineering is the use of scientific principles to design and build machines, structures, and other items, including bridges, tunnels, roads, vehicles, and buildings. The discipline of engineering encompasses a broad range of more specialized fields of engineering, each with a more specific emphasis on particular areas of applied mathematics, applied science, and types of application."
I will admit that not all applications of science are engineering, but in general they are.
The examples you provide are applications of scientific knowledge. The physicist example falls under policy, not science (i.e., the physicist is not testing any hypothesis or expanding the field), and the psychologist example is actually closer to psychiatry (practioners of psychology, i.e., doctors).
Science has a very clear definition, and saying that its "common-sense" meaning is different is not helpful.
@tripu @rastinza @ImperfectIdea
*Engineer sitting in the corner*: Am I a joke to you?
Reminded me of this joke as well:
https://www.neatorama.com/images/2008-12/mad-scientist-mad-engineers.jpg
All silliness aside, scientists can (and sometimes should) work on solutions for specific real world problems, but their work is no longer the textbook definition of science; that falls under engineering.
Your example of cake cutting problems falls under mathematical optimization, which although has a lot of real world applications, can be studied on its own.
@tripu @rastinza @ImperfectIdea a couple of other notes:
1) Chaos theory would not be a good tool for analysing these types of problems. Discrete simulations would be better, or even stochastic differential equations. Chaos theory deals with deterministic nonlinear differential equations with sensitive initial conditions.
2) Despite the name, computer science is not a science, and literature is most definitely not.
3) Your question "What else do you need to work on this problem and come to a solution, other than #science?" shows that you do not know the purpose of science which is to understand nature, not come up with solutions.
Honestly, this toot illustrates a native understanding of science and reeks of scientism.
@tripu
Philosophy
@ImperfectIdea
Data Science PhD Student
Likes math, stats, space, and board games (especially Dominion: https://dominion.games/).
⬛️⬛️⬛️⬛️⬛️✨⬛️⬛️⬛️⬛️⬛️⬛️
⬛️✨⬛️⬛️⬛️⬛️⬛️⬛️⬛️⬛️✨⬛️
⬛️⬛️⬛️⬛️🛰️⬛️⬛️⬛️✨⬛️⬛️⬛️
⬛️⬛️⬛️⬛️⬛️🌎⬛️⬛️⬛️⬛️⬛️⬛️
⬛️⬛️🌒⬛️⬛️⬛️⬛️⬛️⬛️✨⬛️⬛️
⬛️⬛️⬛️⬛️⬛️⬛️✨⬛️⬛️⬛️⬛️⬛️