• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 22:09
CEST 04:09
KST 11:09
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
RSL Season 1 - Final Week6[ASL19] Finals Recap: Standing Tall15HomeStory Cup 27 - Info & Preview18Classic wins Code S Season 2 (2025)16Code S RO4 & Finals Preview: herO, Rogue, Classic, GuMiho0
Community News
Esports World Cup 2025 - Brackets Revealed19Weekly Cups (July 7-13): Classic continues to roll8Team TLMC #5 - Submission extension3Firefly given lifetime ban by ESIC following match-fixing investigation17$25,000 Streamerzone StarCraft Pro Series announced7
StarCraft 2
General
Who will win EWC 2025? Geoff 'iNcontroL' Robinson has passed away Program: SC2 / XSplit / OBS Scene Switcher Why doesnt SC2 scene costream tournaments RSL Revival patreon money discussion thread
Tourneys
Sparkling Tuna Cup - Weekly Open Tournament Sea Duckling Open (Global, Bronze-Diamond) FEL Cracov 2025 (July 27) - $8000 live event RSL: Revival, a new crowdfunded tournament series $5,100+ SEL Season 2 Championship (SC: Evo)
Strategy
How did i lose this ZvP, whats the proper response
Custom Maps
External Content
Mutation # 483 Kill Bot Wars Mutation # 482 Wheel of Misfortune Mutation # 481 Fear and Lava Mutation # 480 Moths to the Flame
Brood War
General
Corsair Pursuit Micro? BW General Discussion BGH Auto Balance -> http://bghmmr.eu/ Pro gamer house photos Flash Announces (and Retracts) Hiatus From ASL
Tourneys
BWCL Season 63 Announcement CSL Xiamen International Invitational [Megathread] Daily Proleagues 2025 ACS Season 2 Qualifier
Strategy
Simple Questions, Simple Answers I am doing this better than progamers do.
Other Games
General Games
[MMORPG] Tree of Savior (Successor of Ragnarok) Stormgate/Frost Giant Megathread Path of Exile Nintendo Switch Thread CCLP - Command & Conquer League Project
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread Vanilla Mini Mafia
Community
General
Things Aren’t Peaceful in Palestine US Politics Mega-thread Russo-Ukrainian War Thread The Games Industry And ATVI Stop Killing Games - European Citizens Initiative
Fan Clubs
SKT1 Classic Fan Club! Maru Fan Club
Media & Entertainment
Anime Discussion Thread Movie Discussion! [Manga] One Piece Korean Music Discussion [\m/] Heavy Metal Thread
Sports
2024 - 2025 Football Thread Formula 1 Discussion TeamLiquid Health and Fitness Initiative For 2023 NBA General Discussion
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List
Blogs
Ping To Win? Pings And Their…
TrAiDoS
momentary artworks from des…
tankgirl
from making sc maps to makin…
Husyelt
StarCraft improvement
iopq
Customize Sidebar...

Website Feedback

Closed Threads



Active: 639 users

The Math Thread - Page 19

Forum Index > General Forum
Post a Reply
Prev 1 17 18 19 20 21 32 Next All
enigmaticcam
Profile Blog Joined October 2010
United States280 Posts
Last Edited: 2018-07-16 20:21:35
July 16 2018 18:42 GMT
#361
I've got another probability question. A bit similar to the last one I asked, but I'm still stumped.

The goal is to get to 0. If you are at some other number, you roll to see what number you to go next. Either you stay at your current number or you move up. You continue rolling until you get to 0.

See the chart below. The first number is the number you are at, and the second number is the number you can potentially go to, followed by the chance of getting there. So for example, if you are at 1 you have a 50% chance of rolling to 0 and stopping after 1 roll, and a 50% chance of staying at 1 and trying again.

1 => 0 (50%)
1 => 1 (50%)
2 => 0 (25%)
2 => 1 (50%)
2 => 2 (25%)
3 => 0 (12.5%)
3 => 1 (37.5%)
3 => 2 (37.5%)
3 => 3 (12.5%)

The question is: What is the expected number of rolls to get to 0 for each number? I already have the answers by simulation: 1 = 2, 2 = 2.667, 3 = 3.144. But I'm stumped as to how to actually calculate that.

Calculating at 1 is easy. Without even having to do any calculations, you can easily see that if you have a 50% chance of winning, you will win on average 2 times.

Calculating 2 is trickier. You have a 25% chance of rolling 0, therefore ending in 1 roll. You have a 50% chance of rolling to 1. Since I already know the expected value at 1 is 2 rolls, that means at 2 you have a 50% chance of winning after 3 rolls. But what is the value if you roll from 2 to 2? There's a convergence there that I'm not sure how to calculate. Any help would be appreciated. Thanks!
Kleinmuuhg
Profile Blog Joined September 2010
Vanuatu4091 Posts
Last Edited: 2018-07-16 19:32:25
July 16 2018 19:24 GMT
#362
Edit: Okay Im not typing this, sorry.
Hope you can read my scribbling Not sure why our results are different for 3.
If you have any questions, please ask and I can elaborate more if needed.
[image loading]

This is our town, scrub
enigmaticcam
Profile Blog Joined October 2010
United States280 Posts
July 16 2018 20:22 GMT
#363
Whoops, that should've been 3.14 for 3, not 4.14. Thanks, let me see if I can figure out your hand written notes :D
Mafe
Profile Joined February 2011
Germany5966 Posts
Last Edited: 2018-07-16 20:55:52
July 16 2018 20:51 GMT
#364
Sounds like a typical get-a-hypothesis-by-juggling-with-numbers-into-proof-by-induction exercise: Basically:
E[W_n]= 1/(n+1)* (E[W_n]+...+E[W_1]+E[W_0]), which means you can calculate E[W_n] if you know all "lower" expected values.

However, now that I read your numbers again, it seems that not every number has the same probability? You should definitely explain what the number of rolling x is when you can roll numbers up to n. Do you mean to say you can only roll 0 or 1 and then subtract the result from n? In any case, you should be able to modify the recursive formula to get get proof by induction/recursion.

Edit: Ok my formula is wrong, take the one from the screenshot it the post above. The idea should still stand.
Edit: Also, 22/7 would round to 3,142 or 3,143 but never 3,144. Is that just a typo?
enigmaticcam
Profile Blog Joined October 2010
United States280 Posts
Last Edited: 2018-07-16 21:38:38
July 16 2018 21:12 GMT
#365
On July 17 2018 05:51 Mafe wrote:You should definitely explain what the number of rolling x is when you can roll numbers up to n.
The context is that I'm trying to solve the problem here: https://projecteuler.net/problem=323.

I'm looking at a smaller example, a 4-bit number instead of 32-bit. Take a number from 0 to 2^4-1 and convert it to binary. If in binary a number has one 0 and three 1's, what is the probability that a bit-wise OR against another 4-bit number will yield a number with all four 1's (15)? It's 50%. The chart I provided earlier is the probability of going from a 4-bit number with x 0's to a 4-bit number with y 0's. Since it's a bitwise OR operation, you will never lose 1's.

I'm sure there are better approaches to the problem, but this is the direction I'm trying to solve it from. In fact, it's looking like I should probably try a different approach, as it's quite complicated to determine those probabilities.

Edit: Also, 22/7 would round to 3,142 or 3,143 but never 3,144. Is that just a typo?
It was just a guess from the results of my simulation. You're correct mathematically, but my simulated results would vary further than just a rounding error.
Simberto
Profile Blog Joined July 2010
Germany11504 Posts
July 16 2018 21:57 GMT
#366
Aren't the bits completely unrelated in that situation? Meaning you can take the problem as 32 copies of the 1 bit problem and then recombine them later on?

Possible idea for a approach not completely thought through
+ Show Spoiler +
A single bit has a probability of P0(n) = 1/2^(n+1) to NOT be a 1 after n operations. And P1(n) is thus 1-(1/2^(n+1))

32 such bits thus have a probability of at least one of them not being a one of 1-(P1(n))^32. Maybe it is possible to somehow get an expected value out of this.


Though i am slightly confused by the "rounded to 10 digits after the decimal point" thingy. That implies some sort of numerical or simulationary approach in my opinion, because why would you want 10 digits if either the result could be described as an exact number in some way (fraction, roots or whatever) or the point is just a mathematical approach.
Kleinmuuhg
Profile Blog Joined September 2010
Vanuatu4091 Posts
July 16 2018 22:12 GMT
#367
On July 17 2018 06:57 Simberto wrote:
Aren't the bits completely unrelated in that situation? Meaning you can take the problem as 32 copies of the 1 bit problem and then recombine them later on?



yes , at first sight it looks like you could model this problem with i.d.d. random variables , then regard the 1-dim case and multiply your way up from there
This is our town, scrub
enigmaticcam
Profile Blog Joined October 2010
United States280 Posts
July 16 2018 22:26 GMT
#368
Yeah I'm pretty sure there are better ways to solve it. This just kinda how I started it, so I wanted to see how far I can get. You guys helped me out, I got exactly what I needed. Thanks!
Kleinmuuhg
Profile Blog Joined September 2010
Vanuatu4091 Posts
July 16 2018 22:58 GMT
#369
good luck
This is our town, scrub
enigmaticcam
Profile Blog Joined October 2010
United States280 Posts
July 17 2018 02:57 GMT
#370
Solved it! [image loading]

Thank you all for your help
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
September 07 2018 02:13 GMT
#371
been a while and I am expected to know the answer to these combinatorics problems. I have a couple im pretty unsure about.

#1.) There are 5 circles, 8 squares, 2 triangles, and 7 lines. 4 shapes are chosen at once.

how many ways can we get at most 2 circles?

my answer: count the ways to get 0 circles, 1 circle, and 2 circles

0 = (17 choose 4)
1 = (5 choose 1)*(16 choose 3)
2 = (5 choose 2)*(15 choose 2)

then add those up. is this right?



2.) given a binary string of length 15, 4 of the positions are set to 1 (at random). the rest are zero. how many strings can be made that have no ones next to each other?

-wtf, I have no idea how to do this :/


3.) similar to #2. We have 4 As, 3 Bs, 2 Cs, 1 D, 1 E. We use all the letters to form a word at random (all letters must be used).
How many words contain no Bs next to each other?

i also have no idea how to do this one, it seems very similar.
DarkPlasmaBall
Profile Blog Joined March 2010
United States44259 Posts
September 07 2018 04:00 GMT
#372
For #1, why is it 16 and 15 instead of 17s?
"There is nothing more satisfying than looking at a crowd of people and helping them get what I love." ~Day[9] Daily #100
The_Templar
Profile Blog Joined January 2011
your Country52797 Posts
September 07 2018 04:40 GMT
#373
I know how to do #1 and maybe #2. #3 I thought I had but some smaller examples have convinced me otherwise. I suspect I will be able to get it more easily in the morning - a bit rusty at this.

For #1 I think you're supposed to assume that all similar shapes are the same, so choosing circle #1 results in the same outcome as if you chose circle #2, for example. In that case, you should set up some kind of linear equation that satisfies the condition (picking exactly 4 shapes from 4 types of shapes), include restrictions on the number of circles and triangles you have, and figure out the number of solutions to that equation.

For #2, I think I solved it correctly by assuming that every 1 is either the first digit in the string or preceded by a 0. Therefore, you can break up the problem into 2 cases — one where the first digit is 1, and one where the first digit is 0 — and figure out the number of ways in each case to rearrange the appropriate number of 0s and "01"s. For example, in the first case, the first digit must be 1, after which point you have three "01"s and 8 other 0s.
Moderatorshe/her
TL+ Member
Acrofales
Profile Joined August 2010
Spain17979 Posts
Last Edited: 2018-09-07 16:50:54
September 07 2018 07:17 GMT
#374
On September 07 2018 13:00 DarkPlasmaBall wrote:
For #1, why is it 16 and 15 instead of 17s?

This. Also a bit rusty, but shouldn't you multiply the second line by 4, and the third line by 6, because the order in which that happens doesn't matter?

For #2, seems like you can solve that with dynamic programming. The chance of having 2 1s next to one another is:

Let c1 be the chance the first digit is 1, and c2 be the chance the 2nd digit is 1, given that the first digit is 1.

double1(total, 1s) = c1 *(c2 + (1-c2)*double1(total -2, 1s -1) + (1 - c1)*double1(total -1, 1s)

double1(_, 0) = 0
double1(1, _) = 0

For any total and 1s, c1 = 1s/total and c2 = (1s -1)/(total - 1)

Your answer is 1 - double1(15, 4).

#3 is identical to 2. Bs are 1s and all other letters are 0s.
Kleinmuuhg
Profile Blog Joined September 2010
Vanuatu4091 Posts
September 07 2018 13:37 GMT
#375
Concerning #1: I am guessing we do not distinguish the circles, etc. from one another? That'd make for a whole lot more possibilities.

#2: the way these problems are usually handled are that you imagine the 11 zeros side by side and the 4 ones as 'partitioners' which you can place at any of the 12 positions in between the zeros or to either side. Think of it as 11 blue cars parked in a row. You now want to park your 4 red cars. The first one you can put in between two blues (10 spaces) or in front of all or in the back of all, makes a total of 12 possibilities. For the next car you have one less possibility, etc.
If all the red cars were different you would have 12*11*10*9 possibilities. But you cannot distinguish between two red cars so you have to account for that. This leads to 12 over 4 as your end result. (drawing without putting back, without caring for oder, binom coefficient)
This is our town, scrub
Acrofales
Profile Joined August 2010
Spain17979 Posts
Last Edited: 2018-09-07 17:33:00
September 07 2018 17:15 GMT
#376
I wrote it in Python. For my dynamic programming solution, I get:

1 - 0.6373626373626374 = ~36%

Using Kleinmuuhg's method, the probability is (12 over 4)/12⁴ = 0.02387152777

What am I doing wrong?

E: I also just saw that the question is not about the probabilities, but the actual combinations. Either way, there is something wrong somewhere :D

E2: checking it for strings of length 3 and 2 1s, I think it's clear that both kleinmuuhg and my method work, but I fucked up on the total number of possiblities. It isn't 12⁴, it's 15 choose 4. And then it all works.
BByte
Profile Joined August 2011
Finland49 Posts
Last Edited: 2018-09-07 17:27:01
September 07 2018 17:25 GMT
#377
A simple recursive Python solution for #2 that seems to produce reasonable results:

def get_count(zeros, ones):
if ones == 0: # Nothing, or only 0s left
return 1
if ones == 1: # A single 1 can be placed in multiple positions
return zeros + 1
if zeros == 0: # All other combinations require 0s to work
return 0

# The remaining string starts with either 0 or 10
return get_count(zeros - 1, ones) + get_count(zeros - 1, ones - 1)

get_count(11, 4)


Not sure it's correct, but this gives a result of 495.
enigmaticcam
Profile Blog Joined October 2010
United States280 Posts
Last Edited: 2018-09-07 18:58:28
September 07 2018 17:45 GMT
#378
For #1:

+ Show Spoiler +
((17/22)*(16/21)*(15/20)*(14/19))
+ ((5/22)*(17/21)*(16/20)*(15/19))
+ ((5/22)*(4/21)*(17/20)*(16/19))
= 0.472544999


Out of 175560 total combinations, that comes to 82960/175560.


For #2:

+ Show Spoiler +
This can be solved by means of simple dynamic programming. Basically, the number of ways of selecting x number of 1's from a binary string of length y is the sum of the number of ways of selecting x - 1 number of 1's from a binary string of length y - 2 for all of x. Here's my c# code:

private int Solve(int maxSize, int maxCount) {
int[,] data = new int[maxSize + 1, maxCount + 1];
for (int spot = 1; spot <= maxSize; spot++) {
data[spot, 1] = 1 + data[spot - 1, 1];
for (int count = 2; count <= maxCount; count++) {
for (int position = spot; position - 2 >= 1; position--) {
data[spot, count] += data[position - 2, count - 1];
}
}
}
return data[maxSize, maxCount];
}


And the results:

Solve(15, 4) = 495


Edit: #2 isn't the same as #3, my bad
BByte
Profile Joined August 2011
Finland49 Posts
September 07 2018 18:43 GMT
#379
#3 can't be trivially reduced to #2 since "abc" and "cba" are still distinct words even if the only "b" is always second.

The solution should be pretty straightforward with combinatorics. Anyhow, in Python (combined with the solution for #2):

def get_word_count(letter_counts):
if sum(letter_counts.values()) == 1:
return 1 # Only one letter left

def sub_count(letter):
if letter_counts.get(letter) == 0:
return 0 # Invalid letter to continue with
else:
return get_word_count({k: (v - 1 if k == letter else v) for k, v in letter_counts.items()})

return sum([sub_count(letter) for letter in letter_counts.keys()])

get_count(8, 3) # Distinct positions of b
get_word_count({'a': 4, 'c': 2, 'd': 1, 'e': 1}) # Different words "around" b:s


For a result of 70560.
enigmaticcam
Profile Blog Joined October 2010
United States280 Posts
Last Edited: 2018-09-07 19:11:04
September 07 2018 18:56 GMT
#380
On September 08 2018 03:43 BByte wrote:
#3 can't be trivially reduced to #2 since "abc" and "cba" are still distinct words even if the only "b" is always second.

You are correct! I was a little too excited and glossed over that fact.

Curious though, do we know if the problem is asking for how many distinct words? Since my solution finds all the distinct ways of arranging B's so they're never next to each other, then it's just a couple quick calculations based on whether or not the problem is asking for only distinct solutions. Your number is likely right since it's divisible by 84 :D
Prev 1 17 18 19 20 21 32 Next All
Please log in or register to reply.
Live Events Refresh
Next event in 1d 7h
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Nina 169
Livibee 124
ProTech66
StarCraft: Brood War
Sharp 21
Noble 10
Icarus 7
Dota 2
monkeys_forever1022
NeuroSwarm116
League of Legends
JimRising 798
Counter-Strike
Fnx 930
Super Smash Bros
hungrybox656
AZ_Axe159
Other Games
tarik_tv37935
summit1g17699
gofns14054
shahzam726
Maynarde192
ViBE88
Organizations
Other Games
gamesdonequick2058
BasetradeTV43
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 17 non-featured ]
StarCraft 2
• Berry_CruncH204
• Hupsaiya 96
• davetesta71
• Sammyuel 43
• Kozan
• Migwel
• AfreecaTV YouTube
• sooper7s
• intothetv
• IndyKCrew
• LaughNgamezSOOP
StarCraft: Brood War
• STPLYoutube
• ZZZeroYoutube
• BSLYoutube
Dota 2
• masondota2988
League of Legends
• Rush1192
• Stunt293
Upcoming Events
Esports World Cup
1d 7h
ByuN vs Astrea
Lambo vs HeRoMaRinE
Clem vs TBD
Solar vs Zoun
SHIN vs Reynor
Maru vs TriGGeR
herO vs Lancer
Cure vs ShoWTimE
Esports World Cup
2 days
Esports World Cup
3 days
Esports World Cup
4 days
CranKy Ducklings
5 days
BSL20 Non-Korean Champi…
5 days
BSL20 Non-Korean Champi…
5 days
Bonyth vs Sziky
Dewalt vs Hawk
Hawk vs QiaoGege
Sziky vs Dewalt
Mihu vs Bonyth
Zhanhun vs QiaoGege
QiaoGege vs Fengzi
FEL
6 days
BSL20 Non-Korean Champi…
6 days
BSL20 Non-Korean Champi…
6 days
Bonyth vs Zhanhun
Dewalt vs Mihu
Hawk vs Sziky
Sziky vs QiaoGege
Mihu vs Hawk
Zhanhun vs Dewalt
Fengzi vs Bonyth
Liquipedia Results

Completed

CSL Xiamen Invitational
Championship of Russia 2025
Murky Cup #2

Ongoing

Copa Latinoamericana 4
Jiahua Invitational
BSL20 Non-Korean Championship
CC Div. A S7
Underdog Cup #2
FISSURE Playground #1
BLAST.tv Austin Major 2025
ESL Impact League Season 7
IEM Dallas 2025
PGL Astana 2025
Asian Champions League '25

Upcoming

CSLPRO Last Chance 2025
CSLPRO Chat StarLAN 3
BSL Season 21
RSL Revival: Season 2
SEL Season 2 Championship
uThermal 2v2 Main Event
FEL Cracov 2025
Esports World Cup 2025
HCC Europe
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2025 TLnet. All Rights Reserved.