메이플스토리 인벤 자유게시판

전체보기

모바일 상단 메뉴

본문 페이지

[수다] 확률 코드 ?

아이콘 렌버
조회: 270
추천: 1
2025-09-21 12:04:52
import randomimport collectionsdef monty_hall_10_doors(num_trials=10000): results = collections.Counter() for _ in range(num_trials): # Step 1: Setup doors = list(range(1, 11)) # Doors 1-10 prize_door = random.choice(doors) player_door = random.choice(doors) # Simulate player pick # Step 2: Host determines doors to open other_doors = [d for d in doors if d != player_door] if prize_door == player_door: # Open 7 random goats out of 9 goats = other_doors[:] # All others are goats open_doors = random.sample(goats, 7) else: # Open 7 random goats out of 8 (avoid prize) goats = [d for d in other_doors if d != prize_door] open_doors = random.sample(goats, 7) # Remaining 3 doors remaining_doors = [d for d in doors if d not in open_doors] # Verify prize is in remaining 3 assert prize_door in remaining_doors # Simulate player decisions for stats if prize_door == player_door: results['stick_win'] += 1 # If switch to one random other door other_remaining = [d for d in remaining_doors if d != player_door] switch_choice = random.choice(other_remaining) if switch_choice == prize_door: results['switch_win'] += 1 # Probabilities stick_prob = results['stick_win'] / num_trials switch_prob = results['switch_win'] / num_trials return stick_prob, switch_prob# Run simulationstick, switch = monty_hall_10_doors()print(f"Stick win probability: {stick:.3f} (expected ~0.100)")print(f"Random switch win probability: {switch:.3f} (expected ~0.450)")



모바일 게시판 하단버튼

댓글

새로고침
새로고침

모바일 게시판 하단버튼

지금 뜨는 인벤

더보기+

모바일 게시판 리스트

모바일 게시판 하단버튼

글쓰기

모바일 게시판 페이징

최근 HOT한 콘텐츠

  • 메이플
  • 게임
  • IT
  • 유머
  • 연예
AD