python 首选定价模型,测试首选价格的波动。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 首选定价模型,测试首选价格的波动。相关的知识,希望对你有一定的参考价值。

from __future__ import division
import random


# This model attempts to explore the generation of a price, and seeing how such prices are generated.

def make_consumer(demand, personal_supply):
	return (demand, personal_supply)

def make_consumers(max_demand, max_supply, amnt):
	return [make_consumer(random.randint(1, max_demand), random.randint(1, max_supply)) for i in range(amnt)]

def consumer_preferred_price(con):
	return con[0] / con[1]

def avg_pref_price(consumers):
	return sum([consumer_preferred_price(c) for c in consumers]) / len(consumers)

def avg_demand(consumers):
	return sum([c[0] for c in consumers]) / len(consumers)

def avg_supply(consumers):
	return sum([c[1] for c in consumers]) / len(consumers)
"""
Here, the supplys and demands of consumers are randomly generated,
and the fluctuation of their average preferred price is observed
"""
if __name__ == '__main__':
	conbin = make_consumers(30, 20, 10)
	print conbin
	print "avg pref price = " + str(avg_pref_price(conbin))
	print "avg demand = " + str(avg_demand(conbin))
	print "avg supply = " + str(avg_supply(conbin))

以上是关于python 首选定价模型,测试首选价格的波动。的主要内容,如果未能解决你的问题,请参考以下文章

Garch模型

Python 开源项目的正常结构是啥?运行测试的首选方式是啥? [关闭]

如何在 Python 环境中测试目标代码。输入首选测试用例

小白福音!零基础入门软件测试,首选必备课程

小白福音!零基础入门软件测试,首选必备课程

CTA黑色系商品反弹,时间序列表现优异