Movatterモバイル変換


[0]ホーム

URL:


はてラボはてな匿名ダイアリー
ようこそ ゲスト さんログインユーザー登録
< ■ |anond:20250704153911 >

2025-07-05

🍬資本主義平等なのか飴の配布で考えてみよう🍬

pythonimport randomimport numpyasnpimport matplotlib.pyplotas pltfrom collections importdefaultdict# 飴の配布システムシミュレーションclass CandyDistributionSystem:def __init__(self):        """設計意図: このシステム経済における資源分配の不平等性をモデル化しています特に少数の特権層(Aグループ)が富を集中させ、再分配システムからも不均衡に利益を得る構造問題表現しています。        """        # 各グループの人数設定        self.group_a_count = 8        self.group_b_count = 2498        self.group_c_count = 7494        self.total_participants = self.group_a_count + self.group_b_count + self.group_c_count                # 飴の提出数設定        self.contribution_per_a = 624        self.contribution_per_b = 2        self.contribution_per_c = 1                # 各グループの総貢献計算        self.total_a_contribution = self.group_a_count * self.contribution_per_a        self.total_b_contribution = self.group_b_count * self.contribution_per_b        self.total_c_contribution = self.group_c_count * self.contribution_per_c        self.total_contribution = self.total_a_contribution + self.total_b_contribution + self.total_c_contribution                # 配布用と貯金用の飴の区分        self.distribution_limit =10000        self.savings =max(0, self.total_contribution - self.distribution_limit)                # 結果追跡用の辞書        self.results = {            'A':defaultdict(int),            'B':defaultdict(int),            'C':defaultdict(int)        }def distribute_candies(self, method='original'):        """設計意図: 配布方法選択によって、特権固定化格差拡大がどのように進むかを        示します。'original'メソッド意図的にAグループ優遇するよう設計されています。                Parameters:        -----------        method:str            配布方法 ('original', 'lottery', 'first_come', 'new_condition', 'fair')        """        # Aグループへの確定配布        a_distribution = 625 * self.group_a_count        remaining = self.distribution_limit - a_distribution                # 残りの参加者数        remaining_participants = self.total_participants - self.group_a_count                # Aグループの結果記録        for _ in range(self.group_a_count):            self.results['A'][625] += 1                # 各配布方法によって処理が異なる        if method == 'original':            #オリジナル問題設定通りの配布(5000人に1個ずつ、残りは0個)            lucky_count = remaining  # 5000人が当選                        # B+Cグループの混合リスト作成            bc_participants = [(1, 'B')] * self.group_b_count + [(2, 'C')] * self.group_c_count            random.shuffle(bc_participants)                        #当選者に配布            for i in range(len(bc_participants)):                participant_id,group = bc_participants[i]                if i &lt; lucky_count:                    self.results[group][1] += 1                else:                    self.results[group][0] += 1                            elif method == 'lottery':            #抽選方式(BとCグループから無作為に5000人選出)            bc_participants = [(1, 'B')] * self.group_b_count + [(2, 'C')] * self.group_c_count            winners = random.sample(bc_participants, remaining)                        #当選落選カウント            for _,group in winners:                self.results[group][1] += 1                        #落選者のカウント            self.results['B'][0] = self.group_b_count - self.results['B'][1]            self.results['C'][0] = self.group_c_count - self.results['C'][1]                    elif method == 'first_come':            # 先着順方式アクセス速度による先着順を乱数シミュレート)            #設計意図: 先着順は単なる運の要素を超えて、情報格差技術格差も含む制度設計            bc_participants = [(1, 'B')] * self.group_b_count + [(2, 'C')] * self.group_c_count                        #現実では、情報を早く得られる人や高速インターネット接続を持つ人が有利            # これをシミュレートするため、Bグループわずかなアドバンテージを与える            bc_speeds = []            forid,group in bc_participants:                ifgroup == 'B': speed = random.random() + 0.1  # Bグループに小さなアドバンテージ                else: speed = random.random()                bc_speeds.append((id,group, speed))                        # 速度順にソート            bc_speeds.sort(key=lambda x: x[2], reverse=True)                        #当選者決定            for i in range(len(bc_speeds)):                _,group, _ = bc_speeds[i]                if i &lt; remaining:                    self.results[group][1] += 1                else:                    self.results[group][0] += 1                            elif method == 'new_condition':            # 追加条件方式恣意的な条件を設定)            #設計意図: 新たな条件の設定は往々にして既存特権を温存するように設計される            bc_participants = [(i, 'B', random.random()) for i in range(self.group_b_count)] + \                             [(i, 'C', random.random()) for i in range(self.group_c_count)]                        # Bグループに有利な条件を設定(例:特定知識スキルを持つ人のみ)            # この「条件」は表面上は中立的だが、実際には特定グループに有利になるよう設計def meets_condition(participant):                _,group, rand_val = participant                ifgroup == 'B':                    return rand_val&gt; 0.3  # Bグループには70%の確率合格                else:                    return rand_val&gt; 0.7  # Cグループには30%の確率合格                        # 条件に合致する人を抽出            eligible = [p for p in bc_participants if meets_condition(p)]                        # 条件に合致する人が多すぎる場合抽選            iflen(eligible)&gt; remaining:                winners = random.sample(eligible, remaining)            else:                # 条件に合致する人が足りない場合、全員に配布                winners = eligible                        #当選者をカウント            for _,group, _ in winners:                self.results[group][1] += 1                        #落選者のカウント            self.results['B'][0] = self.group_b_count - self.results['B'][1]            self.results['C'][0] = self.group_c_count - self.results['C'][1]                    elif method == 'fair':            # 公平な再分配方式(貢献度に応じた配布)            #設計意図: この方法は「貯金分」も含めた全ての飴を、各グループの貢献度に応じて分配            # これにより構造的不平等を軽減、結果としてより多くの人が少なくとも損をしない状態になる                        # 全飴(貯金分も含む)を使った配布total_to_distribute = self.total_contribution                        # 各グループの貢献比率計算            a_ratio = self.total_a_contribution / self.total_contribution            b_ratio = self.total_b_contribution / self.total_contribution            c_ratio = self.total_c_contribution / self.total_contribution                        # 各グループへの配布数決定            a_share = int(total_to_distribute * a_ratio)            b_share = int(total_to_distribute * b_ratio)            c_share = int(total_to_distribute * c_ratio)                        # 端数調整            remainder =total_to_distribute - (a_share + b_share + c_share)            if remainder&gt; 0:                # 端数は最も人数の多いCグループに                c_share += remainder                        # Aグループの配布(均等配分)            per_a = a_share // self.group_a_count            self.results['A'][per_a] = self.group_a_count                        # Bグループの配布(均等配分)            per_b = b_share // self.group_b_count            b_remainder = b_share % self.group_b_count                        self.results['B'][per_b] = self.group_b_count - b_remainder            if per_b + 1&gt; 0 and b_remainder&gt; 0:                self.results['B'][per_b + 1] = b_remainder                        # Cグループの配布(均等配分)            per_c = c_share // self.group_c_count            c_remainder = c_share % self.group_c_count                        self.results['C'][per_c] = self.group_c_count - c_remainder            if per_c + 1&gt; 0 and c_remainder&gt; 0:                self.results['C'][per_c + 1] = c_remainderdef calculate_net_gain(self):        """設計意図: この関数は各グループ純利益/損失を計算し、資源分配の公平性定量的評価できるようにします。純利益/損失は個人観点から見た経済的公正性の重要指標です。        """net_gains = {}                # Aグループ純利益計算        a_contribution = self.contribution_per_a        a_distribution = list(self.results['A'].keys())[0]  # 全員が同じ数を受け取る前提net_gains['A'] = a_distribution - a_contribution                # BとCグループ純利益計算(加重平均)        forgroup, contribution_per_person in [('B', self.contribution_per_b), ('C', self.contribution_per_c)]:total_gain = 0            for received, count in self.results[group].items():total_gain += (received - contribution_per_person) * countnet_gains[group] =total_gain / (self.group_b_count ifgroup == 'B' else self.group_c_count)                    returnnet_gainsdef analyze_results(self):        """設計意図: この分析関数は、各グループの分配結果を詳細に調査し、制度設計公平性、貢献度と報酬関係、およびシステムの持続可能性を評価します。政策分析においては、こうした多角的検証重要です。        """        # 各グループ純利益/損失net_gains = self.calculate_net_gain()                # 貢献度分析        contribution_percentage = {            'A': (self.total_a_contribution / self.total_contribution) *100,            'B': (self.total_b_contribution / self.total_contribution) *100,            'C': (self.total_c_contribution / self.total_contribution) *100        }                # 飴を受け取った人の割合        received_percentage = {            'A': sum(count for received, count in self.results['A'].items() if received&gt; 0) / self.group_a_count *100,            'B': sum(count for received, count in self.results['B'].items() if received&gt; 0) / self.group_b_count *100,            'C': sum(count for received, count in self.results['C'].items() if received&gt; 0) / self.group_c_count *100        }                #分析結果の表示print("\n===== 飴の配布システム分析 =====")print(f"総飴数: {self.total_contribution}個 (分配用: {self.distribution_limit}個,貯金: {self.savings}個)")print("\n---グループごとの貢献と結果 ---")        forgroup in ['A', 'B', 'C']:group_size =getattr(self, f"group_{group.lower()}_count")            contribution_per_person =getattr(self, f"contribution_per_{group.lower()}")total_contribution =getattr(self, f"total_{group.lower()}_contribution")print(f"\n{group}グループ ({group_size}人):")print(f"  貢献: 1人あたり{contribution_per_person}個 (総計: {total_contribution}個, 全体の{contribution_percentage[group]:.1f}%)")print(f"  受け取り状況:")                        for received, count in sorted(self.results[group].items()):print(f"    {received}個: {count}人 ({count/group_size*100:.1f}%)")print(f"  飴を受け取った割合: {received_percentage[group]:.1f}%")print(f"純利益/損失: 1人あたり平均 {net_gains[group]:.2f}個")print("\n--- 全体的な公平性分析 ---")print(f"最も得したグループ: {max(net_gains,key=net_gains.get)}グループ (+{max(net_gains.values()):.2f}個/人)")print(f"最も損したグループ: {min(net_gains,key=net_gains.get)}グループ ({min(net_gains.values()):.2f}個/人)")                # 全員に飴が配布されたかどうかall_received =all(sum(count for received, count in self.results[group].items() if received&gt; 0) ==getattr(self, f"group_{group.lower()}_count") forgroup in ['A', 'B', 'C'])print(f"\n前提条件「全員に配布」の充足: {'はい' ifall_received else 'いいえ'}")        if notall_received:total_without = sum(self.results['B'][0] + self.results['C'][0])print(f"  飴を受け取れなかった人数: {total_without}人")                returnnet_gains, contribution_percentage, received_percentagedef visualize_results(self):        """設計意図:データ可視化政策効果や不平等性を直感的に理解するために重要です。        このようなグラフィカル表現によって、各グループ間の格差制度設計問題点を        一目で理解できるようになります。        """        #グラフセットアップfig, axes = plt.subplots(2, 2,figsize=(14,10))                # 1. 貢献度のグラフ        contributions = [self.total_a_contribution, self.total_b_contribution, self.total_c_contribution]        axes[0, 0].bar(['Aグループ', 'Bグループ', 'Cグループ'], contributions)        axes[0, 0].set_title('グループごとの総貢献飴数')        axes[0, 0].set_ylabel('飴の数')                # 貢献度の割合アノテーションとして追加total = sum(contributions)        for i, v in enumerate(contributions):            percentage = v /total *100            axes[0, 0].text(i, v +100, f'{percentage:.1f}%', ha='center')                # 2. 1人あたりの貢献度と受け取り数の比較group_names = ['Aグループ', 'Bグループ', 'Cグループ']        contribution_per_person = [self.contribution_per_a, self.contribution_per_b, self.contribution_per_c]                # 各グループの平均受け取り数を計算        received_per_person = []        forgroup, letter inzip(group_names, ['A', 'B', 'C']):total_received = sum(received * count for received, count in self.results[letter].items())group_size =getattr(self, f"group_{letter.lower()}_count")            received_per_person.append(total_received /group_size)                x =np.arange(len(group_names))        width = 0.35                axes[0, 1].bar(x - width/2, contribution_per_person, width, label='提出')        axes[0, 1].bar(x + width/2, received_per_person, width, label='受け取り')                #純利益/損失をアノテーションとして追加        for i in range(len(group_names)):net = received_per_person[i] - contribution_per_person[i]color = 'green' ifnet&gt;= 0 else 'red'            axes[0, 1].text(i,max(received_per_person[i], contribution_per_person[i]) + 5,                         f'{"+" ifnet&gt;= 0 else ""}{net:.1f}', ha='center',color=color)                axes[0, 1].set_title('1人あたりの提出・受け取り飴数比較')        axes[0, 1].set_xticks(x)        axes[0, 1].set_xticklabels(group_names)        axes[0, 1].set_ylabel('飴の数')        axes[0, 1].legend()                # 3. 各グループの受け取り状況の分布        # 各グループの受け取り状況を積み上げ棒グラフ表現group_sizes = [self.group_a_count, self.group_b_count, self.group_c_count]        received_counts = []        not_received_counts = []                for letter, size inzip(['A', 'B', 'C'],group_sizes):            received = sum(count for received, count in self.results[letter].items() if received&gt; 0)            received_counts.append(received)            not_received_counts.append(size - received)                axes[1, 0].bar(group_names, received_counts, label='飴を受け取った人数')        axes[1, 0].bar(group_names, not_received_counts, bottom=received_counts, label='飴を受け取れなかった人数')                #割合アノテーションとして追加        for i in range(len(group_names)):            ifgroup_sizes[i]&gt; 0:                percentage = received_counts[i] /group_sizes[i] *100                axes[1, 0].text(i, received_counts[i] / 2, f'{percentage:.1f}%', ha='center')                axes[1, 0].set_title('グループごとの飴受け取り状況')        axes[1, 0].set_ylabel('人数')        axes[1, 0].legend()                # 4. 貢献度vs報酬の分配公平性        # 貢献度と最終的な飴の配分の比較円グラフ表現total_contribution = self.total_contribution        contribution_shares = [self.total_a_contribution /total_contribution,                             self.total_b_contribution /total_contribution,                             self.total_c_contribution /total_contribution]                # 実際の配分シェア計算        distribution_shares = []        for letter in ['A', 'B', 'C']:total_received = sum(received * count for received, count in self.results[letter].items())            distribution_shares.append(total_received / self.distribution_limit)                # 2つの円グラフを並べて表示        ax4_1 = axes[1, 1].inset_axes([0, 0, 0.45, 1])        ax4_2 = axes[1, 1].inset_axes([0.55, 0, 0.45, 1])                ax4_1.pie(contribution_shares, labels=group_names, autopct='%1.1f%%')        ax4_1.set_title('飴の貢献度割合')                ax4_2.pie(distribution_shares, labels=group_names, autopct='%1.1f%%')        ax4_2.set_title('飴の配分割合')                axes[1, 1].axis('off')                plt.tight_layout()        plt.show()# 飴の配布システムシミュレートcandy_system = CandyDistributionSystem()#オリジナルの配布方法を実行print("\n=====オリジナルの配布方法 =====")candy_system.distribute_candies(method='original')original_results = candy_system.analyze_results()candy_system.visualize_results()# 公平な配布方法実験print("\n\n===== 公平な配布方法シミュレーション =====")fair_system = CandyDistributionSystem()fair_system.distribute_candies(method='fair')fair_results = fair_system.analyze_results()fair_system.visualize_results()# 公平な配布と元の配布の比較print("\n\n===== 配布方法比較 =====")print("オリジナル方式と公平方式純利益/損失差:")net_diff = {}forgroup in ['A', 'B', 'C']:original_net =original_results[0][group]    fair_net = fair_results[0][group]diff = fair_net -original_netnet_diff[group] =diffprint(f"{group}グループ: {'+'  ifdiff&gt; 0 else ''}{diff:.2f}個/人")print("\n結論:")ifnet_diff['A'] &lt; 0 andnet_diff['B']&gt; 0 andnet_diff['C']&gt; 0:print("公平な再分配により、Aグループ特権が減少し、BとCグループの状況が改善されます。")print("これは構造的不平等の緩和に効果的です。")elifnet_diff['A']&gt; 0:print("興味深いことに、公平な再分配ではAグループさえも利益を得られます。")print("これは、現行システム特定グループだけでなく全体の非効率性につながっていることを示唆しています。")

anond:20250705100755anond:20250705112807

Permalink |記事への反応(1) | 10:24

このエントリーをはてなブックマークに追加ツイートシェア

記事への反応 -
  • 最近、アンチグローバルを謳う極右が増えたわけだが、 グローバリズムを否定すると貧しくなるだけだと思うよね。 生産コストがさらに上がり物価が上がるわけだし。 適材適所を無視...

    • 状況設定 グループ分けと提出数 Aグループ(8人):1人あたり624個の飴を提出。 Bグループ(2,498人):1人あたり2個の飴を提出。 Cグループ(7,494人):1人あたり1個の飴を提出...

      • 読んでないけど分配で考えてる時点で資本主義じゃないな 個々人が飴を増やせるのが資本主義だ

    • ⭕️ 資本主義によって世界の格差は縮まった ← ピケティほか様々なデータで確認できている事実 🔺 効率化を進めると豊かになり貧しくなくなる ←AIの存在しない世界線の人かな? ...

      • 資本主義が平等と言った覚えはないが。 格差が生まれるのは資本主義なのだから当然よ。 で、格差をなくそうと、資本主義を部分的にでも否定すると、逆により貧しくなると主張してい...

記事への反応(ブックマークコメント)

全てのコメントを見る

人気エントリ

注目エントリ

ログインユーザー登録
ようこそ ゲスト さん
Copyright (C) 2001-2025 hatena. All Rights Reserved.

[8]ページ先頭

©2009-2025 Movatter.jp