FOR 100 PEOPLE, EVERYONE OWNS 100 YUAN. EVERYONE GIVES ANOTHER RANDOM PERSON 1 YUAN EVERY MINUTE.

FOR 100 PEOPLE, EVERYONE OWNS 100 YUAN. EVERYONE GIVES ANOTHER RANDOM PERSON 1 YUAN EVERY MINUTE. 

THEN WHAT HAPPENS.

Try to simulate this with matplotlib in Python.

----2017.7.16


I learned how to use matplotlib and numpy in the past two days. It's not going very well. I find that it's really hard for me to learning these things with only official docs. There are too many items to read and I don't know where to find what I want.

Anyway, after 'wasting' a lot of time,  I wrote a little program simulate the problem I mentioned, though very lame. I saw this problem inzhihu, where there are many answers. It seems that this problem does't with our speculation with probability knowledge. I thought this way in the beginning, too. But after I simulated and thought about it, I find something tricky.

After like 1 million loops in this simulation, the richest one may have several hundred yuan or even a thousand, and the poorest may have nothing left. Or if we allow debts, the poorest may have several hundred yuan debt at last. Most people would be surprised at this result, for we often think people's money should be almost the same. People say it is counter-intuitive.

Here is the tricky part. There is a "trap" in this problem----everyone has to give 1 one to another person in every loop. After a million loops, everyone has paid a million yuan. By contrast, the differences between their wealth are only about a thousand. That means, everyone pays a million yuan, and some of them earned hundreds of yuan, some of them lose hundreds of yuan. It's almost the same, isn't it?

So, the fact is, I think, that our feelings of the differences between people's wealth are magnified by the limited property----100 yuan each.


----2017.7.18

This is my awful code below. I really need to learn more. I don't know how to use FuncAnumation now.

import random
import numpy as np
import matplotlib.pyplot as plt

zeros = []
money = np.ones(100)*100

for i in range(100000):
    for j in range(100):
        if i in zeros:
            continue
        r = random.randint(0, 99)
        while r == i:
          r = random.randint(0,99)
        money[r] += 1
        money[i] -= 1
        if r in zeros:
            zeros.remove(r)
        if money[i] == 0:
            zeros.append(i)

plt.bar(np.arange(100), money, 1, color='g', edgecolor='k')
plt.show()


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
这个错误是因为您正在尝试删除拥有模式(schema)的数据库主体(database principal)。在 SQL Server 中,模式是一种逻辑容器,可以用来组织和管理数据库对象,如表、视图、存储过程等。每个数据库主体都可以拥有一个或多个模式。如果您尝试删除一个拥有模式的数据库主体,将会收到如上所述的错误消息。 要解决这个问题,您需要按照以下步骤操作: 1. 首先,使用以下语句查找拥有模式的数据库主体的名称和模式的名称: ``` USE [database_name]; SELECT s.name AS schema_name, dp.name AS principal_name FROM sys.schemas s INNER JOIN sys.database_principals dp ON dp.principal_id = s.principal_id WHERE dp.name = 'principal_name'; ``` 请将 "database_name" 替换为您的数据库名称,将 "principal_name" 替换为您要删除的数据库主体名称。 2. 然后,将该数据库主体从其模式中移除。例如,以下语句将名为 "principal_name" 的数据库主体从名为 "schema_name" 的模式中移除: ``` USE [database_name]; ALTER AUTHORIZATION ON SCHEMA::[schema_name] TO dbo; ``` 请将 "database_name" 替换为您的数据库名称,将 "schema_name" 替换为上一步中找到的模式名称。 3. 最后,您可以使用 DROP USER 或 DROP LOGIN 语句删除该数据库主体。例如,以下语句将名为 "principal_name" 的数据库主体删除: ``` USE [database_name]; DROP USER [principal_name]; ``` 请将 "database_name" 替换为您的数据库名称,将 "principal_name" 替换为要删除的数据库主体名称。 请注意,在执行任何删除操作之前,请务必备份您的数据库以防止数据丢失。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值