结构式(Structural Form)与简化式(Reduced Form)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了结构式(Structural Form)与简化式(Reduced Form)相关的知识,希望对你有一定的参考价值。

参考技术A 简化式一般是通过结构式变型得到的。

对简化式方程,方程的左边全都是内生变量,方程的右边全都是前定变量(包括外生变量,以及滞后内生变量)。

In econometrics, the reduced form of a system of equations is the product of solving that system for its endogenous variables. In other words, the reduced form of an econometric model is one that has been rearranged algebraically so that each endogenous variable is on the left side of one equation and only predetermined variables (like exogenous variables and lagged endogenous variables) are on the right side.

内生变量 v.s. 外生变量

内生变量是由模型内部决定的变量,而外生变量是由模型外因素决定的变量。

In any model, there will be variables that are created or impacted by the model and others that remain unchanged by the model. Those that are changed by the model are considered endogenous or dependent variables, whereas those that remained unchanged are the exogenous variables. Exogenous variables are assumed to be determined by factors outside of the model and are therefore the autonomous or independent variables.

结构式 v.s.简化式

我们在基于经济学理论构建模型的时候,构建的一般都是结构式,是把一些感兴趣的因变量、解释变量通过方程关联在一起。结构式体现了各个变量之间的关系。

但在计算的时候,我们习惯用简化式。简化式,是通过结构式变型得到的。通过将内生变量放在方程左边,把前定变量放在方程右边,得到简化式。这样可能就失去了变量之间关系上的含义。

即使是简化式,常常只能以函数的形式表示参数,一般难以得到显式解。

编程思想设计模式结构模式Structural门面模式/外观模式Facade

Python版

 

https://github.com/faif/python-patterns/blob/master/structural/facade.py

技术分享图片
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
*What is this pattern about?
The Facade pattern is a way to provide a simpler unified interface to
a more complex system. It provides an easier way to access functions
of the underlying system by providing a single entry point.
This kind of abstraction is seen in many real life situations. For
example, we can turn on a computer by just pressing a button, but in
fact there are many procedures and operations done when that happens
(e.g., loading programs from disk to memory). In this case, the button
serves as an unified interface to all the underlying procedures to
turn on a computer.

*What does this example do?
The code defines three classes (TC1, TC2, TC3) that represent complex
parts to be tested. Instead of testing each class separately, the
TestRunner class acts as the facade to run all tests with only one
call to the method runAll. By doing that, the client part only needs
to instantiate the class TestRunner and call the runAll method.
As seen in the example, the interface provided by the Facade pattern
is independent from the underlying implementation. Since the client
just calls the runAll method, we can modify the classes TC1, TC2 or
TC3 without impact on the way the client uses the system.

*Where is the pattern used practically?
This pattern can be seen in the Python standard library when we use
the isdir function. Although a user simply uses this function to know
whether a path refers to a directory, the system makes a few
operations and calls other modules (e.g., os.stat) to give the result.

*References:
https://sourcemaking.com/design_patterns/facade
https://fkromer.github.io/python-pattern-references/design/#facade
http://python-3-patterns-idioms-test.readthedocs.io/en/latest/ChangeInterface.html#facade

*TL;DR80
Provides a simpler unified interface to a complex system.
"""

from __future__ import print_function
import time

SLEEP = 0.1


# Complex Parts
class TC1:

    def run(self):
        print(u"###### In Test 1 ######")
        time.sleep(SLEEP)
        print(u"Setting up")
        time.sleep(SLEEP)
        print(u"Running test")
        time.sleep(SLEEP)
        print(u"Tearing down")
        time.sleep(SLEEP)
        print(u"Test Finished\n")


class TC2:

    def run(self):
        print(u"###### In Test 2 ######")
        time.sleep(SLEEP)
        print(u"Setting up")
        time.sleep(SLEEP)
        print(u"Running test")
        time.sleep(SLEEP)
        print(u"Tearing down")
        time.sleep(SLEEP)
        print(u"Test Finished\n")


class TC3:

    def run(self):
        print(u"###### In Test 3 ######")
        time.sleep(SLEEP)
        print(u"Setting up")
        time.sleep(SLEEP)
        print(u"Running test")
        time.sleep(SLEEP)
        print(u"Tearing down")
        time.sleep(SLEEP)
        print(u"Test Finished\n")


# Facade
class TestRunner:

    def __init__(self):
        self.tc1 = TC1()
        self.tc2 = TC2()
        self.tc3 = TC3()
        self.tests = [self.tc1, self.tc2, self.tc3]

    def runAll(self):
        [i.run() for i in self.tests]


# Client
if __name__ == __main__:
    testrunner = TestRunner()
    testrunner.runAll()

### OUTPUT ###
# ###### In Test 1 ######
# Setting up
# Running test
# Tearing down
# Test Finished
#
# ###### In Test 2 ######
# Setting up
# Running test
# Tearing down
# Test Finished
#
# ###### In Test 3 ######
# Setting up
# Running test
# Tearing down
# Test Finished
#
Python转载版

 

以上是关于结构式(Structural Form)与简化式(Reduced Form)的主要内容,如果未能解决你的问题,请参考以下文章

Atitit.变量的定义 获取 储存 物理结构 基本类型简化 隐式转换 类型推导 与底层原理 attilaxDSL

设计模式初识结构型模式(Structural Pattern)

结构型设计模式 Structural Patterns :适配器 Adapter(C++ 实现)

结构型设计模式 Structural Patterns :适配器 Adapter(Python 实现)

Android Studio Structural搜索代码中的所有Toast语句

编程思想设计模式结构模式Structural代理模式Proxy