• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 15:25
CEST 21:25
KST 04:25
  • 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
TL.net Map Contest #21: Voting10[ASL20] Ro4 Preview: Descent11Team TLMC #5: Winners Announced!3[ASL20] Ro8 Preview Pt2: Holding On9Maestros of the Game: Live Finals Preview (RO4)5
Community News
Weekly Cups (Oct 13-19): Clem Goes for Four0BSL Team A vs Koreans - Sat-Sun 16:00 CET6Weekly Cups (Oct 6-12): Four star herO85.0.15 Patch Balance Hotfix (2025-10-8)80Weekly Cups (Sept 29-Oct 5): MaxPax triples up3
StarCraft 2
General
The New Patch Killed Mech! Team Liquid Map Contest #21 - Presented by Monster Energy herO joins T1 Weekly Cups (Oct 13-19): Clem Goes for Four TL.net Map Contest #21: Voting
Tourneys
SC2's Safe House 2 - October 18 & 19 INu's Battles #13 - ByuN vs Zoun Tenacious Turtle Tussle Sparkling Tuna Cup - Weekly Open Tournament $1,200 WardiTV October (Oct 21st-31st)
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 496 Endless Infection Mutation # 495 Rest In Peace Mutation # 494 Unstable Environment Mutation # 493 Quick Killers
Brood War
General
BSL Season 21 BW General Discussion BGH Auto Balance -> http://bghmmr.eu/ BW caster Sayle BSL Team A vs Koreans - Sat-Sun 16:00 CET
Tourneys
Azhi's Colosseum - Anonymous Tournament [ASL20] Semifinal B [Megathread] Daily Proleagues SC4ALL $1,500 Open Bracket LAN
Strategy
[I] TvZ Strategies and Builds Current Meta BW - ajfirecracker Strategy & Training Relatively freeroll strategies
Other Games
General Games
Nintendo Switch Thread Path of Exile Stormgate/Frost Giant Megathread Dawn of War IV ZeroSpace Megathread
Dota 2
Official 'what is Dota anymore' discussion LiquidDota to reintegrate into TL.net
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread SPIRED by.ASL Mafia {211640}
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread Men's Fashion Thread Sex and weight loss
Fan Clubs
The herO Fan Club!
Media & Entertainment
Series you have seen recently... Anime Discussion Thread [Manga] One Piece Movie Discussion!
Sports
Formula 1 Discussion 2024 - 2026 Football Thread MLB/Baseball 2023 NBA General Discussion TeamLiquid Health and Fitness Initiative For 2023
World Cup 2022
Tech Support
SC2 Client Relocalization [Change SC2 Language] Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List Recent Gifted Posts
Blogs
The Heroism of Pepe the Fro…
Peanutsc
Rocket League: Traits, Abili…
TrAiDoS
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1534 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
Germany11594 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 States44917 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
Spain18093 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
Spain18093 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
Monday Night Weeklies
16:00
#27
WardiTV1561
TKL 515
IndyStarCraft 332
BRAT_OK 147
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
TKL 515
IndyStarCraft 332
BRAT_OK 147
UpATreeSC 119
Codebar 59
MindelVK 27
JuggernautJason14
StarCraft: Brood War
Britney 16203
Calm 3543
Mini 556
EffOrt 269
Larva 175
Soulkey 123
Dewaltoss 120
Hyun 64
Aegong 30
Movie 13
[ Show more ]
HiyA 10
SilentControl 9
NaDa 7
Shine 4
Dota 2
Dendi1488
BananaSlamJamma355
Counter-Strike
pashabiceps694
Stewie2K88
Heroes of the Storm
Liquid`Hasu318
Khaldor222
Other Games
FrodaN2576
Grubby2015
ScreaM1600
fl0m1415
Beastyqt704
mouzStarbuck276
ToD242
Mlord194
C9.Mang0161
Skadoodle158
KnowMe118
ArmadaUGS113
Trikslyr52
Mew2King51
Organizations
Counter-Strike
PGL548
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 16 non-featured ]
StarCraft 2
• kabyraGe 164
• Adnapsc2 12
• Reevou 5
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• C_a_k_e 2029
Other Games
• imaqtpie1445
• Shiphtur281
Upcoming Events
Replay Cast
3h 35m
Wardi Open
15h 35m
Wardi Open
19h 5m
PiGosaur Monday
1d 4h
Replay Cast
1d 14h
Tenacious Turtle Tussle
2 days
The PondCast
2 days
OSC
2 days
WardiTV Invitational
3 days
Online Event
3 days
[ Show More ]
RSL Revival
4 days
RSL Revival
4 days
WardiTV Invitational
4 days
Afreeca Starleague
5 days
Snow vs Soma
Sparkling Tuna Cup
5 days
WardiTV Invitational
5 days
CrankTV Team League
5 days
RSL Revival
5 days
Wardi Open
6 days
CrankTV Team League
6 days
Liquipedia Results

Completed

Acropolis #4 - TS2
WardiTV TLMC #15
HCC Europe

Ongoing

BSL 21 Points
ASL Season 20
CSL 2025 AUTUMN (S18)
C-Race Season 1
IPSL Winter 2025-26
EC S1
Thunderpick World Champ.
CS Asia Championships 2025
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

Upcoming

SC4ALL: Brood War
BSL Season 21
BSL 21 Team A
BSL 21 Non-Korean Championship
RSL Offline Finals
RSL Revival: Season 3
Stellar Fest
SC4ALL: StarCraft II
CranK Gathers Season 2: SC II Pro Teams
eXTREMESLAND 2025
ESL Impact League Season 8
SL Budapest Major 2025
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 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.