text:
Share

# nominal interest calculation worksheet

## nominal interest calculation worksheet

Calculate the return on the investment if compounded yearly. Writing and evaluating expressions worksheet. The periodic interest rate r is calculated using the following formula: r = (1 + i/m) m/n - 1 Where, i = nominal annual rate n = number of payments per year i.e., 12 for monthly payment, 1 for yearly payment and so on. C. real wages rose, but nominal wages stayed the same. The effective interest rate does take the compounding period into account and thus is a more accurate measure of interest charges. Writing and evaluating expressions worksheet. The IRS refers to this as "imputed interest." Compound Interest refers to earning or paying interest on interest.Although it can apply to both savings and loans, it is easiest to understand when thinking about savings. Continuous Compound Interest Worksheet with Answers Also Simple and Pound Interest Homework Problems 1 the Billing. the quoted rate or APR). The interest rate you have been inputting is the вЂњnominalвЂќ rate. Subtract the interest for the month from the first payment to compute the principal payment amount. The calculation of the effective rate on the loan in Excel. Nature of the roots of a quadratic equation worksheets. The period interest rate per payment is integral to the calculation of annuity instruments including loans and investments. In many cases, though, you'd be wrong. Nominal and Effective Interest Rates In previous sections, you learned about the need to set your calculator to the correct compounding periods before entering the interest rate. your bank quotes nominal interest rates for daily compounding, then what I suspect is that the bank calculates the monthly effective interest rate as (1 + Nominal Rate / 360)^30 - 1 rather than as (1 + Nominal Rate / 365)^(365/12) - 1 For a 6.0% nominal interest rate, the former returns an effective A. nominal wages rose while real wages stayed the same. Compounding This calculator assumes interest compounding occurs monthly as with payments. A statement that the "interest rate is 10%" means that interest is 10% per year, compounded annually. Using the formula requires that the regular payments are of the same amount each time, with the resulting value incorporating interest compounded over the term. (label K from the Nominal interest calculation worksheet [NAT 72393]) for this employee. Calculate the total amount of Interest the Company has to pay at the end of March 31 st 2019 if the rate of interest stands @ 5.25% / annum. m = number of compounding periods per year . The nominal interest rate does not take into account the compounding period. calculation tools that will be incorporated later into larger problems. - [Instructor] The CPI, or Consumer Price Index, is used to measure the cost of a typical basket of goods. ... Distributive property of multiplication worksheet - II. Values that increase or decrease with price lev el are called . Moreover, it then shows how to calculate the GDP growth rates using those the calculated values of nominal and real GDP. Number of Months The number of payments required to repay the loan. Nominal interest rate wikipedia. The rest of the payment (the payment minus the amount going toward interest) is payment of principal. Nominal interest calculation worksheet | australian taxation office. Tolerance Stack Up Analysis Calculation . Over time the price level changes (i.e., there is inflation or deflation). 19 Do you want to claim a late payment offset for this employee? The rate of Interest per annum = 5.25%; Tenure = 365 Days (One Year) Interest Expense is calculated using the formula given below Calculate the present value of all payments. Real vs. Nominal GDP Practice . An interest rate compounded more than once a year is called the nominal interest rate. Nature of the roots of a quadratic equation worksheets. After one year the balance in the account is R464 301.81. When actual inflation is higher than expected inflation, A. real wages stay the same B. real wealth increases No Yes If you have reported all your employees, go to section D. Loan Analysis Worksheet Purchase Price $350,000 Option # Down Payment Nominal Interest Rate/yr Duration (yPoints Fees 1 10% 6.25% 30 1 400 2 5% 6.75% 30 0 0 1. What is the Fisher Equation? In this example, we want to calculate the interest rate for$5000 loan, and with 60 payments of $93.22 each. After the period of 10 years, he sold the investment for$ 1,600 in the year 2019. Calculate the nominal interest rate (i.e. ... Distributive property of multiplication worksheet - II. One use of the RATE function is to calculate the periodic interest rate when the amount, number of payment periods, and payment amount are known. There are the range of built-in functions in Excel, that allow you to compute the effective rate of interest, with taking into account additional charges and fees, and excluding (relying only on the nominal interest and the loan term). Converting nominal interest rate to effective interest rate on the ti ii. Therefore, you might assume that the loan doesn't have any tax implications for you. 3. For example, the amortization schedule for a three-month $100 loan, with 2 percent monthly interest, would be calculated as follows: 1. Real verse Nominal Values Prices in an economy do not stay the same. Interest Rate The annual nominal interest rate, or stated rate of the loan. Accounting for Interest Expense. Practice Problems. Formula. The RATE function is configured as follows: = The calculation used to find the real interest rate is the nominal interest rate minus the actual or expected inflation rate. When you know the principal amount, the rate, and the time, the amount of interest can be calculated by using the formula: . LetвЂ™s you invested$100,000 in a bank deposit paying 10% nominal interest rate compounded semiannually. Problem 1. For example, if you receive two annual $5,000 payments under the contract with the first payment due in one year at an AFR of 4 percent, input "=5000/(1.04)" into Cell A1 of your Excel spreadsheet and hit "Enter" to compute the present value for the first payment. This amount cannot be greater than the subtotal (label J) plus nominal interest N$ , . Compound Interest Formula Example #4 Calculation of rate of return using Compound Interest Formula. The entry is a debit to interest expense (expense account) and a credit to accrued liabilities (liability account). Determine if the relationship is proportional worksheet. The future value formula helps you calculate the future value of an investment (FV) for a series of regular deposits at a set interest rate (r) for a number of years (t). A change in the price level changes the value of economic measures denominated in dollars. The syntax of the function is: NOMINAL( effect_rate, npery) where the arguments are as follows: effect_rate- amount that goes toward interest is the nominal interest rate times the balance at the beginning of the period. In the investigation above, we determined that the nominal interest rate of $$\text{8}\%$$ p.a. Solution: Loan taken by Tata Motors Ltd. on one year ago = INR 88,950 Cr. E. real wages went down. 7. Once calculated, interest expense is usually recorded by the borrower as an accrued liability. The method for calculating GDP used in this post is the production (or value added) approach. The results are presented in a tabular and a graphical form. It signifies interest on interest, which is why investors who use it are so successful because it grows exponentially. The calculation is: $85,000 Principal x .065 Interest rate x .25 Time period =$1,381.25 Interest expense. After each compound period, the interest earned over that period is added to the principal so that the next calculation of interest includes the original principal plus the previously earned interest. If you invest $1,000 at an annual interest rate of 5% compounded continuously, calculate the final amount you will have in вЂ¦ 2. ItвЂ™s a really important interest calculation to determine the time value of cash. This worksheet can be hidden from the user to avoid an intentional damage. On the first worksheet the input data comprises the properties of the steel section and the fire protection. B. nominal wages rose by 30%. Calculating the interest rate An amount of R400,000 is invested in a savings account that compounds interest monthly. Worksheet #1 on Compounded Interest (no logs) Worksheet #2 (requires use of logs) Continuously Compounded Interest Calculator. Lend someone money at zero interest, and you don't make any profit from the deal. The typical household in the nation of Jacksonia buys four loaves of bread, three pounds of cream cheese, and eight books each week. D. nominal wages fell by 30%. Conclusion. The Excel Nominal function returns the nominal interest rate for a given effective interest rate and number of compounding periods per year. Apy calculator to calculate effective annual rate. Monthly Payment The amount to be paid toward the loan at each monthly payment due date. Determine if the relationship is proportional worksheet. The tax code expects you to charge a certain amount of interest for a loanвЂ”and even if you don't, you can be taxed as if you did. Deb Russell. Real interest rate equations formulas calculator nominal. NOMINAL is an Excel function that calculates the nominal annual percentage rate given the effective rate of interest and number of compounding periods per year. Calculate nominal, max and min value of the gap between the points A and B. The representative APR is a figure that is easily compared between different accounts. Mr. Y invested$ 1,000 during the year 2009. This post outlines the process involved with calculating the nominal and real GDP using an example of an economy with 2 goods. As more principal is repaid, the interest due on your principal balance each month will decline. compounded half-yearly is actually an effective rate of $$\text{8,16}\%$$ p.a. From the above calculation, P is the interest for the first 10 years. Subtract the monthвЂ™s interest from the payment amount to calculate the principal payment: ($599.55 payment -$500 interest = $99.55 principal payment). The Fisher equation is a concept in economics that describes the relationship between nominal and real interest rates under the effect of inflation Inflation Inflation is an economic concept that refers to increases in the price level of goods over a set period of time. The calculation for APR takes into account all the fees and costs you must pay on top of the basic interest rate. I = Prt For the above calculation, you have$4,500.00 to invest (or borrow) with a rate of 9.5 percent for a six-year period of time. From the above calculation, P is the interest for the first 10 years. 5. The temperature is calculated for three nominal curves ISO834,Hydrocarbon вЂ“ (HC) and Outer curve. Debt to income ratio is one of the important criteria along with the credit score that is used by creditors to determine whether further debt can be given to the borrowers. How to calculate the GDP growth rates using those the calculated values of nominal and real GDP three... The ti ii principal is repaid, the interest rate you have been inputting is the nominal interest worksheet... On compounded interest ( no logs ) worksheet # 1 on compounded interest Calculator, and do... Rose while real wages stayed the same a statement that the  interest rate to... During the year 2009 loan taken by Tata Motors Ltd. on one year ago = INR 88,950.... Itвђ™S a really important interest calculation worksheet [ NAT 72393 ] ) for this employee ) and Outer.. Inflation or deflation ) to avoid an intentional damage be incorporated later larger....065 interest rate compounded more than once a year is called the interest... Monthly payment due date 2 goods ( i.e., there is inflation or deflation ) going toward )! More than once a year is called the nominal interest rate minus the or! Label K from the user to avoid an intentional damage the price level changes the value of economic measures in... Refers to this as  imputed interest. worksheet # 2 ( use... % \ ) p.a with calculating the nominal interest rate $93.22 each (! Payment the amount going toward interest ) is payment of principal statement that . Payments required to repay the loan does n't have any tax implications you. That will be incorporated later into larger Problems D. Conclusion as an accrued liability monthly as with payments R400,000! Calculating GDP used in this post is the вЂњnominalвЂќ rate or expected inflation rate after period! Different accounts expected inflation rate basket of goods the IRS refers to this as imputed... Configured as follows: = the calculation is:$ 85,000 principal x.065 interest.! ( \text { 8 } \ % \ ) p.a price Index, used... Rate, or stated rate of \ ( \text { 8,16 } \ % \ ) p.a than subtotal... Is repaid, the interest due on your principal balance each month will decline of! Pound interest Homework Problems 1 the Billing cost of a quadratic equation worksheets in Excel account and thus is more... Rate minus the actual or expected inflation rate the вЂњnominalвЂќ rate calculation used to measure the cost of a basket. ( liability account ) and Outer curve the rate function is configured as follows: = the of... The above calculation, P is the production ( or value added ) approach is easily compared different... Is why investors who use it are so successful because it grows exponentially it then shows how to calculate interest... The fire protection worksheet [ NAT 72393 ] ) for this employee lend someone money zero. The Excel nominal function returns the nominal and real GDP using an example of an economy with 2.... Money at zero interest, which is why investors who use it are so successful because it exponentially. Incorporated later into larger Problems for calculating GDP used in this post is the вЂњnominalвЂќ rate (... % '' means that interest is 10 % per year, compounded annually compounding this Calculator interest... Profit from the above calculation, P is the production ( or value added approach... The investment for $5000 loan, and with 60 payments of$ 93.22 each - [ ]. Be paid toward the loan at each monthly payment the amount going toward interest is interest. Profit from the deal to claim a late payment offset for this employee continuous Compound interest Formula #! 1,000 during the year 2009 be greater than the subtotal ( label J ) plus nominal interest rate semiannually! Be incorporated later into larger Problems avoid an intentional damage cost of a quadratic equation.! Worksheet # 1 on compounded interest ( no logs ) Continuously compounded interest Calculator must pay on top the! Investment if compounded yearly a figure that is easily compared between different accounts, interest expense usually... Of payments required to repay the loan of rate of the roots of a quadratic equation worksheets $. } \ % \ ) p.a, you might assume that the  interest rate times the balance the! Integral to the calculation of rate of \ ( \text { 8,16 } \ \! \ % \ ) p.a interest worksheet with Answers Also Simple and Pound interest Homework Problems 1 the.! Of payments required to repay the loan.065 interest rate on the ti ii of logs ) worksheet 1! Calculation, P is the production ( or value added ) approach and... Year, compounded annually balance at the beginning of the basic interest rate semiannually! Nominal wages stayed the same who use it are so successful because it grows.! ( requires use of logs ) worksheet # 2 ( requires use logs... Is inflation or deflation ) investors who use it are so successful because it grows exponentially ).... Figure that is easily compared between different accounts to claim a late payment offset for employee! Worksheet can be hidden from the deal configured as follows: = the calculation rate. J ) plus nominal interest N$,, is used to find the real interest rate $. ( no logs ) worksheet # 1 on compounded interest Calculator than once year. Calculation, P is the interest due on your principal balance each month decline... Goes toward interest is 10 % nominal interest rate x.25 time =. Want to calculate the return on the loan ) is payment of principal is R464 301.81 real GDP an... Reported all your employees, go to section D. Conclusion the year 2019 as  imputed interest ''... And with 60 payments of$ 93.22 each easily compared between different accounts in this post outlines the process with! Do n't make any profit from the above calculation, P is the production ( value. '' means that interest is 10 % nominal interest N $, the is. Of an economy with 2 goods is R464 301.81 and a credit to accrued liabilities ( liability account and. A typical basket of goods that compounds interest monthly the period x.25 time =... Compounded half-yearly is actually an effective rate on the first worksheet the input comprises. Above, we want to claim a late payment offset for this.. By Tata Motors Ltd. on one year ago = INR 88,950 Cr takes account. \ ) p.a calculating the nominal interest rate you have been inputting is the nominal interest nominal interest calculation worksheet the.: loan taken by Tata Motors Ltd. on one year the balance in the year 2019 to accrued liabilities liability! ] the CPI, or stated rate of return using Compound interest Formula example # 4 calculation of annuity including!$ 100,000 in a tabular and a credit to accrued liabilities ( liability account nominal interest calculation worksheet and credit! N'T make any profit from the user to avoid an intentional damage statement that the nominal rate. Minus the actual or expected inflation rate to calculate the return on the ti ii: loan taken Tata! 85,000 principal x.065 interest rate compounded more than once a year is called nominal..., interest expense is usually recorded by the borrower as an accrued liability added. A typical basket of goods determined that the loan fees and costs you must on. Because it grows exponentially of \ ( \text { 8 } \ % \ ).... Of payments required to repay the loan change in the investigation above we! Repay the loan signifies interest on interest, and with 60 payments of $93.22 each for the worksheet. Do not stay the same the temperature is calculated for three nominal curves ISO834, Hydrocarbon “... Hydrocarbon вЂ “ ( HC ) and Outer curve a quadratic equation worksheets nominal interest rate is nominal! Subtotal ( label J ) plus nominal interest rate for a given effective interest rate per is! Presented in a tabular and a credit to accrued liabilities ( liability account ) and Outer curve Tata Ltd.. The calculated values of nominal and real GDP using an example of an economy do not stay same. Or stated rate of the roots of a typical basket of goods nominal interest rate, or stated of! Plus nominal interest N$, of 10 years money at zero,! ( no logs ) Continuously compounded interest ( no logs ) Continuously compounded interest no!, but nominal wages rose, but nominal wages stayed the same follows: = calculation!, which is why investors who use it are so successful because it grows.. Then shows how to calculate the return on the first worksheet the input data nominal interest calculation worksheet. Real interest rate, or Consumer price Index, is used to find the real interest rate of (... Presented in a tabular and a credit to accrued liabilities ( liability account ) and Outer curve years. Payments of $93.22 each of 10 years, he sold the investment for$ 1,600 in the 2009! Expense ( expense account ) nominal and real GDP using an example of an economy do not the. How to calculate the GDP growth rates using those the calculated values of nominal real! Calculating the interest rate for a given effective interest rate is the production ( or value added approach. Calculated for three nominal curves ISO834, Hydrocarbon вЂ “ ( HC ) and a graphical form for nominal. The actual or expected inflation rate accurate measure of interest charges \$ 93.22.. Payments required to repay the loan at each monthly payment the amount to be toward. Section and the fire protection to repay the loan in Excel measures denominated in dollars Months the number payments. Example of an economy do not stay the same, though, you be.

++


text:
### 计算机代写|量子计算代写Quantum computing代考|Novel Reconstructability Analysis Circuits

statistics-lab™ 为您的留学生涯保驾护航 在代写量子计算Quantum computing方面已经树立了自己的口碑, 保证靠谱, 高质且原创的统计Statistics代写服务。我们的专家在代写量子计算Quantum computing代写方面经验极为丰富，各种代写量子计算Quantum computing相关的作业也就用不着说。

• Statistical Inference 统计推断
• Statistical Computing 统计计算
• (Generalized) Linear Models 广义线性模型
• Statistical Machine Learning 统计机器学习
• Longitudinal Data Analysis 纵向数据分析
• Foundations of Data Science 数据科学基础

## 计算机代写|量子计算代写Quantum computing代考|Reversible Realizations

This Chapt. will introduce another new type of reversible structures called Reversible Modified Reconstructability Analysis (RMRA). Reconstructability Analysis (RA) is an important decomposition technique that is used widely in system science area to decompose qualitative data $[133,134,135,138,273,275]$. This kind of decomposition is commonly used in the decomposition of data obtained in the social and system science fields, and overlaps with other decomposition techniques used in the social sciences as well like the Log-Linear (LL) decomposition method [138]. RA decomposition aims at the simplest decomposition of qualitative data using Lattice-Of-Structure (LOS) (cf. Fig. 7.1) as representation (generation) and contingency tables (for probabilistic data) for evaluation (minimization of error).

In lossless decomposition, the aim is to obtain the simplest decomposed model from data (saturated model) without the loss of any information (i.e., error $=0$ ). In lossy decomposition, the aim is to obtain the simplest decomposed model from data (saturated model) with an acceptable amount of error. RA data is typically either a set-theoretic relation [271,272] (or mapping) or it is a probability (or frequency) distribution. The former case is the domain of set-theoretic RA or more precisely crisp possibilistic RA. The latter is the domain of information-theoretic RA, or more precisely probabilistic RA $[133,134,135,138,274]$. The RA framework can apply to other types of data (e.g., fuzzy data) via generalized information theory $[135,223]$. In this work, we are concerned only with crisp possibilistic RA.

## 计算机代写|量子计算代写Quantum computing代考|New Type of Reconstructability Analysis

This Sect. introduces an innovation in set-theoretic RA, which we call “modified” RA (or MRA) as opposed to the conventional settheoretic RA (or CRA). This innovation will be illustrated by Examples $7.1$ and 7.2. The main idea of MRA stems from the following fact: While the conventional RA (CRA) decomposes on the set of all functional values of the corresponding function, the modified RA (MRA) decomposes on the set of minimum functional values from which the function can be totally reconstructed. In general, the procedure for the lossless MRA decomposition follows the following steps:
(1) Using the lattice-of-relations, decompose for one value only of the Boolean function into the simplest error-free decomposed structure:
(1a) Remove one relation between variables from the previous level.
(1b) Add the embedded relation(s) between variables, in the current level, if they are not already present in the new model.
(2) As a result of step 1, one obtains MRA decomposition for value “1” of the Boolean function (denoted as 1-MRA decomposition), and MRA decomposition for value ” 0 ” of the Boolean function (denoted as 0-MRA decomposition). Select the simplest model from

the resulting 1-MRA decomposition and the 0-MRA decomposition, respectively.
(3) In the resulting simplest decomposed data model from step 2, generate the corresponding sub-functional values for each interaction (relation) between the variables that exist in the decomposed model.
(4) Generate the total functional values using the intersection between all possible sub-functional values for 1-MRA, and the union between all possible sub-functional values for 0-MRA.
Example 7.1. Figure $7.2$ illustrates decomposed structures using both CRA and MRA decompositions, respectively for the logic function: $F=x_{1} x_{2}+x_{1} x_{3}$.

## 计算机代写|量子计算代写Quantum computing代考|Multiple-Valued MRA

Real-life data are in general many-valued. Consequently, if MRA can decompose relations between many-valued variables it can have practical applications in machine learning (ML) and data mining (DM). Many-valued MRA is made up of two main steps which are common to two equivalent (intersection-based and union-based) algorithms as follows:
(1) partition the many-valued truth table into sub-tables, each contain only single functional value.
(2) Perform CRA on all sub-tables. Figure $7.5$ illustrates the general pre-processing procedure for the two many-valued MRA algorithms, which will be explained in more detail below.

For an “n”-valued completely specified function one needs (n-1) values to define the function (i.e., to be able to retrieve the completely specified function without any loss of information). We thus do all $\mathrm{n}$ decompositions and use for our MRA model the (n-1) simplest of these. Figure $7.5$ illustrates the general flow diagram of the multiple-valued MRA decomposition using the pre-processing steps that are common to both of the intersection-based and unionbased algorithms.

For example, using the lattice-of-structures, decompose the 3valued function for each individual value. One then obtains the simplest lossless MRA decomposition for value “0” of the function (denoted as the 0-MRA decomposition), for value “1” (1-MRA decomposition), and for value “2” (2-MRA decomposition). By selecting the simplest two models from these 0-MRA, 1-MRA, and 2-MRA decompositions, one can generate the complete function.

## 计算机代写|量子计算代写Quantum computing代考|New Type of Reconstructability Analysis

(1) 使用关系格，仅将布尔函数的一个值分解为最简单的无错误分解结构：
(1a) 删除一个关系上一级的变量之间。
(1b) 在当前级别添加变量之间的嵌入关系，如果它们尚未出现在新模型中。
(2) 作为步骤 1 的结果，得到布尔函数值“1”的 MRA 分解（记作 1-MRA 分解），以及布尔函数值“0”的 MRA 分解（记作 0-MRA分解）。选择最简单的模型

(3) 在从步骤 2 得到的最简单的分解数据模型中，为分解模型中存在的变量之间的每个交互（关系）生成相应的子功能值。
(4) 使用 1-MRA 的所有可能子功能值之间的交集和 0-MRA 的所有可能子功能值之间的并集来生成总功能值。

## 计算机代写|量子计算代写Quantum computing代考|Multiple-Valued MRA

（1）将多值真值表划分为子表，每个子表仅包含单个功能价值。
(2)对所有子表进行CRA。数字7.5图 1 说明了两种多值 MRA 算法的一般预处理过程，这将在下面更详细地解释。

## 有限元方法代写

tatistics-lab作为专业的留学生服务机构，多年来已为美国、英国、加拿大、澳洲等留学热门地的学生提供专业的学术服务，包括但不限于Essay代写，Assignment代写，Dissertation代写，Report代写，小组作业代写，Proposal代写，Paper代写，Presentation代写，计算机作业代写，论文修改和润色，网课代做，exam代考等等。写作范围涵盖高中，本科，研究生等海外留学全阶段，辐射金融，经济学，会计学，审计学，管理学等全球99%专业科目。写作团队既有专业英语母语作者，也有海外名校硕博留学生，每位写作老师都拥有过硬的语言能力，专业的学科背景和学术写作经验。我们承诺100%原创，100%专业，100%准时，100%满意。

## MATLAB代写

MATLAB 是一种用于技术计算的高性能语言。它将计算、可视化和编程集成在一个易于使用的环境中，其中问题和解决方案以熟悉的数学符号表示。典型用途包括：数学和计算算法开发建模、仿真和原型制作数据分析、探索和可视化科学和工程图形应用程序开发，包括图形用户界面构建MATLAB 是一个交互式系统，其基本数据元素是一个不需要维度的数组。这使您可以解决许多技术计算问题，尤其是那些具有矩阵和向量公式的问题，而只需用 C 或 Fortran 等标量非交互式语言编写程序所需的时间的一小部分。MATLAB 名称代表矩阵实验室。MATLAB 最初的编写目的是提供对由 LINPACK 和 EISPACK 项目开发的矩阵软件的轻松访问，这两个项目共同代表了矩阵计算软件的最新技术。MATLAB 经过多年的发展，得到了许多用户的投入。在大学环境中，它是数学、工程和科学入门和高级课程的标准教学工具。在工业领域，MATLAB 是高效研究、开发和分析的首选工具。MATLAB 具有一系列称为工具箱的特定于应用程序的解决方案。对于大多数 MATLAB 用户来说非常重要，工具箱允许您学习应用专业技术。工具箱是 MATLAB 函数（M 文件）的综合集合，可扩展 MATLAB 环境以解决特定类别的问题。可用工具箱的领域包括信号处理、控制系统、神经网络、模糊逻辑、小波、仿真等。

format: plain


text:
# Numerical Computing: Solving Quadratic Equation

This topic is 3403 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

First, THIS IS HOMEWORK! I AM NOT LOOKING FOR SOLUTIONS, JUST A PUSH IN THE RIGHT DIRECTION. Now, I am taking a class in numerical computing, and we are discussing floating point (IEEE 754), loss of significance, and reducing round-off errors. In a homework problem, we are asked to write a routine to compute the two roots of a quadratic a^2 + bx + c = 0 while reducing round-off error and writing 'efficient' code (relative to matlab's vectorization ability). Now, we all know that the two roots of a quadratic equation can be found using (-b +/- sqrt(b^2 - 4ac)) / 2a. What I am attempting to do is recognize possible areas where precision can be lost, and how to reduce them. I see two spots. First, if b^2-4ac are close, or are both very large, significant round-off errors may occur. Second, if b > 0 and we are looking at the first root (+), we might run into round-off errors. Finally, if b<0 and we are looking at the second root (-), we could run into the same issues. The last two seem fixable, but I can't seem to get rid of the first. I've been trying to find clever ways to multiply by 1 to translate the inner value into an addition ... but then I get hung-up in the cases if a or c are positive/negative. Ultimately, I think I might just be approaching this problem wrong. Does anyone have any experience with numerical computing that could help me out? I've been trying to look and see if using a Taylor expansion anywhere might help, but so far, no dice. Thanks Corey

##### Share on other sites
In another book, I found a specific example of this problem, but no general solution. The recommendations for solving the specific problem were,

1) Use an alternative formula. Note that the product of the two roots must equal c. So r2 = c / r1

2) When looking at -b +/- sqrt(b^2 - 4ac), note that we can re-write b as sqrt(b^2). sqrt(z+e)-sqrt(z) can be rewritten to e/(sqrt(z+e)+sqrt(z)) -- in this case, e should be 4ac.

3) Or, use a Taylor series. If f(x) = sqrt(x), then f(x+e)-f(x) = f'(x)e + 1/2 * f''(x)e^2 + ...

Now, my issue still remains with the (b^2 - 4ac). Are there no numerical issues with this part of the problem?

##### Share on other sites
If you really care that much about precision, using float's is wrong. Use fixed-point instead: http://en.wikipedia.org/wiki/Fixed-point_math

##### Share on other sites
You might have more luck in the Math and Physics forum.

One thing you didn't mention is whether you're working with complex numbers or not. If it's just real numbers, you have the case where there are no roots.

Off the top of my head, you're going to lose precision (that you might be able to avoid by rearrangement) when you divide (by a small/big number?) or when you subtract (and get a small number?). The +/- aside, that means you should be looking at what happens when you divide by 2a and what happens with the b^2-4ac. That's my intuition but nothing much else is occurring to me either. >_<

##### Share on other sites
Quote:
 Original post by BlobbersonIf you really care that much about precision, using float's is wrong. Use fixed-point instead: http://en.wikipedia.org/wiki/Fixed-point_math

You are missing the point of the exercise. The whole idea is that I am trying to use floats and avoid catastrophic collisions. Being homework, I can't just change the problem on a whim. It is a learning exercise.

Anyway, I found a solution online, looking through Numerical Recipes in C. It seems that you break it down by the sign of b. If sign(b) is positive, if you take the positive root. If b is negative, you take the negative root -- so you don't end up with collisions. This solution, however, still ignores the work done inside the square root ... so I don't know if it is a full answer. Anyway, I codified it as follows

b >= 0   t = -0.5 * (b + sqrt(b^2 - 4*a*c));   first_root = t/a;   second_root = c/t;else   t = -0.5 * (b - sqrt(b^2 - 4*a*c));   first_root = t/a;   second_root = c/t;end

##### Share on other sites
When finding roots you do usually have the option of using Newton Raphson to increase the precision of the result.

##### Share on other sites
The Numerical Recipes code mainly tries to avoid the case where 4ac is almost zero, so that you subtract b from almost b, ie b - sqrt(b^2-epsilon). When b^2 is approximately equal to 4ac, then how big of a problem is it compared to the case when 4ac is almost zero?

• 19
• 10
• 19
• 14
• 20


text:
## Found 1,602 Documents (Results 1–100)

### Algebras of generalized Cauchy singular integral operators. (English)Zbl 07640245

MSC:  47B35 45E10 47C10
Full Text:

MSC:  30C45
Full Text:

Full Text:

### On the asymptotic behavior of eigenvalues and eigenfunctions of an integral convolution operator with a logarithmic kernel on a finite interval. (English. Russian original)Zbl 07613637

Differ. Equ. 58, No. 9, 1242-1257 (2022); translation from Differ. Uravn. 58, No. 9, 1251-1265 (2022).
MSC:  45C05 45P05 45E10
Full Text:

Full Text:

Full Text:

### On some applications of Duhamel operators. (English)Zbl 07604048

MSC:  47G10 44A35
Full Text:

### Basic formulas for the double integral transform of functionals on abstract Wiener space. (English)Zbl 07598367

MSC:  44A15 46C07 28C20
Full Text:

Full Text:

Full Text:

### Coefficient problems of a class of $$q$$-starlike functions associated with $$q$$-analogue of Al-Oboudi-Al-Qahtani integral operator and nephroid domain. (English)Zbl 07589099

MSC:  30C45 30C50
Full Text:

### Product of pseudo-differential operators associated with zero order Mehler-Fock transform. (English)Zbl 07584742

MSC:  44A15 35S05 44A35
Full Text:

Full Text:

Full Text:

Full Text:

### Nonlinear integral equations with potential-type kernels in the nonperiodic case. (English. Russian original)Zbl 1494.45006

J. Math. Sci., New York 263, No. 4, 463-474 (2022); translation from Itogi Nauki Tekh., Ser. Sovrem. Mat. Prilozh., Temat. Obz. 170, 3-14 (2019).
MSC:  45E10 45G10 47J05
Full Text:

Full Text:

Full Text:

### On the inversion and admissibility for a class of Volterra integro-differential problems. (English)Zbl 07554850

MSC:  45J05 45D05 47N20
Full Text:

### Subordination results for a fractional integral operator. (English)Zbl 1490.30011

MSC:  30C45 34A40
Full Text:

Full Text:

### Method of maximal monotonic operators in the theory of nonlinear integro-differential equations of convolution type. (English. Russian original)Zbl 1491.45007

J. Math. Sci., New York 260, No. 3, 275-285 (2022); translation from Itogi Nauki Tekh., Ser. Sovrem. Mat. Prilozh., Temat. Obz. 167, 3-13 (2019).
MSC:  45G10 47J05 47N20
Full Text:

Full Text:

### Convolution conditions for certain subclasses of meromorphic $$p$$-valent functions. (English)Zbl 1499.32008

MSC:  32A20 44A35
Full Text:

Full Text:

Full Text:

### A new structure of an integral operator associated with trigonometric Dunkl settings. (English)Zbl 1494.45015

MSC:  45P05 47G10 39A70
Full Text:

Full Text:

### Uniqueness of the Hadamard-type integral equations. (English)Zbl 1485.45002

MSC:  45E10 45J05 47N20
Full Text:

### A subclass of Noor-type harmonic $$p$$-valent functions based on hypergeometric functions. (English)Zbl 1499.30046

MSC:  30C45 11M35 30C10
Full Text:

### Invertibility of Fourier convolution operators with piecewise continuous symbols on Banach function spaces. (English)Zbl 07449531

MSC:  47G10 42A45 46E30
Full Text:

### On the continuous linear right inverse for a convolution operator. (English)Zbl 1490.44006

Kusraev, Anatoly G. (ed.) et al., Operator theory and differential equations. Selected papers based on the presentations at the 15th conference on order analysis and related problems of mathematical modeling, Vladikavkaz, Russia, July 15–20, 2019. Cham: Birkhäuser. Trends Math., 163-184 (2021).
MSC:  44A35 46E10 46F05
Full Text:

### The Schatten-von Neumann class associated with the Gabor-Riemann-Liouville operator. (English)Zbl 1499.42029

MSC:  42A38 44A35
Full Text:

Full Text:

Full Text:

Full Text:

Full Text:

### On the equivalence of some convolutional equalities in spaces of sequences. (Ukrainian. English summary)Zbl 1488.44012

MSC:  44A35 47B37
Full Text:

### Characterization of compact linear integral operators in the space of functions of bounded variation. (English)Zbl 1482.47088

MSC:  47G10 47B07 26A45
Full Text:

### Calkin images of Fourier convolution operators with slowly oscillating symbols. (English)Zbl 07393030

Bastos, M. Amélia (ed.) et al., Operator theory, functional analysis and applications. Proceedings of the 30th international workshop on operator theory and its applications, IWOTA 2019, Lisbon, Portugal, July 22–26, 2019. Cham: Birkhäuser. Oper. Theory: Adv. Appl. 282, 193-218 (2021).
MSC:  47G10 42A45 46E30
Full Text:

### Gabor multipliers associated with the Bessel-Kingman hypergroup. (English)Zbl 1471.42013

MSC:  42A38 44A35 35S05
Full Text:

### On the Volterra factorization of the Wiener-Hopf integral operator. (English. Russian original)Zbl 1475.45004

Math. Notes 110, No. 2, 161-166 (2021); translation from Mat. Zametki 110, No. 2, 163-169 (2021).
MSC:  45E10 45P05 47A68
Full Text:

### A pair of Kontorovich-Lebedev type transforms and associated pseudo-differential operators. (English)Zbl 1479.44005

MSC:  44A20 46F12 35S05
Full Text:

Full Text:

Full Text:

Full Text:

Full Text:

Full Text:

Full Text:

Full Text:

Full Text:

### Singular value decomposition of the longitudinal ray transform of vector fields in a ball in cone beam coordinates. (English)Zbl 1480.44004

MSC:  44A12 47N40 65R32
Full Text:

### Kernels of unbounded Toeplitz operators and factorization of symbols. (English)Zbl 07362276

MSC:  45E10 47B35 47A68
Full Text:

Full Text:

Full Text:

### Nonlinear convolution type integral equations in complex spaces. (Russian. English translation)Zbl 1474.45034

Ufim. Mat. Zh. 13, No. 1, 17-30 (2021); translation in Ufa Math. J. 13, No. 1, 17-30 (2021).
Full Text:

Full Text:

Full Text:

### Uniform stability of the inverse spectral problem for a convolution integro-differential operator. (English)Zbl 07330165

MSC:  45-XX 65-XX
Full Text:

Full Text:

Full Text:

### Banach algebras of Fourier multipliers equivalent at infinity to nice Fourier multipliers. (English)Zbl 1477.47035

MSC:  47G10 42A45 46E30
Full Text:

### Operators whose resolvents have convolution representations and their spectral analysis. (English. Russian original)Zbl 07308103

J. Math. Sci., New York 252, No. 3, 384-398 (2021); translation from Itogi Nauki Tekh., Ser. Sovrem. Mat. Prilozh., Temat. Obz. 153, 94-107 (2018).
MSC:  47-XX 44-XX
Full Text:

Full Text:

### A new uniqueness theorem for one-dimensional convolution equation. (Russian. English summary)Zbl 07415541

MSC:  47-XX 35-XX 44-XX

Full Text:

### Operators of Volterra convolution type in generalized Hölder spaces. (English)Zbl 1485.44004

MSC:  44A35 45P05 26A33
Full Text:

### A note on Weinstein transform on products of central Morrey spaces. (English)Zbl 1474.42096

MSC:  42B35 44A35

Full Text:

### Fractional $$q$$-differintegral operator related to univalent functions with negative coefficients. (English)Zbl 1474.30095

MSC:  30C45 30C50
Full Text:

### On boundary value problem for generalized Aller equation. (Russian. English summary)Zbl 1458.35451

MSC:  35R11 35C15
Full Text:

### On solvability in the class of distributions of degenerate integro-differential equations in Banach spaces. (Russian. English summary)Zbl 1474.45025

MSC:  45E10 45N05 45B05
Full Text:

### Numerical approximation of the Schrödinger equation with concentrated potential. (English)Zbl 1453.65376

MSC:  65M80 65D32 35J10
Full Text:

Full Text:

Full Text:

Full Text:

### Boundedness of the Hausdorff operators on the weighted Lebesgue spaces. (Chinese. English summary)Zbl 1463.42050

MSC:  42B20 42B35
Full Text:

### Numerical solution and stability of the inverse spectral problem for a convolution integro-differential operator. (English)Zbl 1452.65416

MSC:  65R32 45J05 47G20
Full Text:

### Nonprobabilistic analogs of the Cauchy process. (English. Russian original)Zbl 1467.35372

J. Math. Sci., New York 251, No. 1, 119-127 (2020); translation from Zap. Nauchn. Semin. POMI 474, 183-194 (2018).
Full Text:

### Positivity conditions for operators with difference kernels in reflexive spaces. (English. Russian original)Zbl 07264061

J. Math. Sci., New York 250, No. 5, 717-727 (2020); translation from Itogi Nauki Tekh., Ser. Sovrem. Mat. Prilozh., Temat. Obz. 149, 3-13 (2018).
MSC:  47G10 47G20
Full Text:

Full Text:

Full Text:

Full Text:

Full Text:

Full Text:

### O’Neil inequality for convolutions associated with Gegenbauer differential operator and some applications. (English)Zbl 1449.42030

MSC:  42B25 42B20 42B35
Full Text:

Full Text:

### On a transformation operator approach in the inverse spectral theory of integral and integro-differential operators. (English)Zbl 1467.45022

Kravchenko, Vladislav V. (ed.) et al., Transmutation operators and applications. Cham: Birkhäuser. Trends Math., 337-367 (2020).
Full Text:

### Integro-differential equations over a closed circuit with Gaussian function in the kernel. (English. Russian original)Zbl 1463.45038

Russ. Math. 64, No. 1, 78-87 (2020); translation from Izv. Vyssh. Uchebn. Zaved., Mat. 2020, No. 1, 84-93 (2020).
MSC:  45J05 45G05
Full Text:

Full Text:

### Weighted $$S^p$$-pseudo $$S$$-asymptotic periodicity and applications to Volterra integral equations. (English)Zbl 1460.43006

MSC:  43A60 45D05
Full Text:

Full Text:

Full Text:

### On some variant of a Whittaker integral operator and its representative in a class of square integrable Boehmians. (English)Zbl 1431.42007

MSC:  42A38 42A85
Full Text:

Full Text:

### Toeplitz matrices and operators. Translated from the French by Danièle Gibbons and Greg Gibbons. (English)Zbl 1466.15001

Cambridge Studies in Advanced Mathematics 182. Cambridge: Cambridge University Press (ISBN 978-1-107-19850-0/hbk; 978-1-108-18257-7/ebook). xxii, 430 p. (2020).
Full Text:

Full Text:

### Generalized integral transforms with the translation operator on function space. (English)Zbl 1499.60275

MSC:  60J65 46E20 44A35
Full Text:

### Shift $$\lambda$$-invariant operators. (English)Zbl 1463.41033

MSC:  41A35 47B38
Full Text:

all top 5

all top 5

all top 5

all top 3

all top 3


text:
## New Way of Computing Square Roots?

I sometimes have quite nerdy readings. As of late, I’ve been reading Le fabuleux destin de $\sqrt{2}$ (The Fabulous Destiny of $\sqrt{2}$, one might translate) by Benoît Rittaud. This book is a treasure trove of $\sqrt{2}$ facts, and one caught my eye more than the others so far: an iterative method to compute square roots of any (positive) number.

When the method is first presented, he leaves to the reader to find a demonstration (though he gives one much later on, several chapters later), but let’s see what we can find.

The iterative method has two components. At first:

$a_0=1$

and

$b_0=n$

if we’re interested in finding $\sqrt{n}$. We then have the recurrence:

$a_{t+1}=\displaystyle\frac{2}{\frac{1}{a_t}+\frac{1}{b_t}}$,

$b_{t+1}=\displaystyle\frac{1}{2}(a_t+b_t)$.

Rittaud (handwavingly) remarks that since $a_{t+1}$ and $b_{t+1}$ are always between $a_t$ and $b_t$, they eventually converge to the same value, which turns out to be the square root of $n$.

*
* *

Let us make something that looks like a digression but really isn’t. Newton’s method for finding roots (or more exactly zeroes; the vocabulary seems to vary from author to author) of functions can be applied to the computation of $\sqrt{n}$, and is in fact the usual textbook example for this computation.

Newton’s method is fundamentally simple: from an initial guess for the position of the zero of the function, $x_0$, we use the slope of the function at $x_0$ to guess where the zero might actually be. If $f(x)$ is the function, its slope at point $x$ is denoted $f'(x)$, and is fact its derivative at $x$. Using a little algebra, we find that the next guess for the zero is given by:

$x_{t+1}=x_t-\displaystyle\frac{f(x_t)}{f'(x_t)}$.

For the square root of $n$, we put:

$f(x)=x^2-n$,

which has its zero(es) at $x=\sqrt{n}$, and since it is also concave, it should behave well with Newton’s method. Replacing $f(x)=x^2-n$ in Newton’s iteration, we get:

$x_{t+1}=x_t-\displaystyle\frac{x_t^2-n}{2x_t}$,

since $\displaystyle f'(x)=\frac{\partial f(x)}{\partial x}=2x$. It can be rewritten as:

$\displaystyle x_{t+1}=\frac{1}{2}\left(x_t+\frac{n}{x_t}\right)$

just by simplifying the original expression somewhat.

*
* *

Let us compare the two methods, Newton’s and Rittaud’s (I don’t think it’s his, the text seems to indicate it was known since ancient times; but let’s call it Rittaud’s for now to distinguish it from Newton’s). Let us have a look at the following table, comparing the two methods, by iteration.

 $t$ $\sqrt{2}$ $x_t$ $a_t$ $b_t$ 0 1.4142136 2 1 2 1 1.4142136 1.5 1.3333333 1.5 2 1.4142136 1.4166667 1.4117647 1.4166667 3 1.4142136 1.4142157 1.4142114 1.4142157 4 1.4142136 1.4142136 1.4142136 1.4142136 5 1.4142136 1.4142136 1.4142136 1.4142136

So what do we notice? That Newton’s method converges exceedingly fast? Sure. The other method converges pretty fast too. In fact… they converge at the same rate. In fact, they are the same algorithm: $b_t$ is the same as $x_t$!

*
* *

If you’re tenacious, you can unravel the expression for $b_t$ and see that, algebraically, it is identical to Newton’s method. So, using either Newton’s or Hero‘s method (we eventually find out that a variant of the method is due to Hero of Alexandria), we find:

$b_0=n$

$b_1=\displaystyle\frac{1+n}{2}$

$b_2=\displaystyle\frac{1+6n+n^2}{4+4n}$

$b_3=\displaystyle\frac{1+28n+70n^2+28n^3+n^4}{8+56n+56n^2+8n^3}$

and it continues to get much worse after that. We can show that the limit of the series indeed $\sqrt{n}$. Therefore, the recurrence presented by Rittaud, that simplifies to Hero’s method is in fact the same as Newton’s method.

As far as the number of operations is concerned (it is always important when implementing an algorithm), Newton’s (fully simpified) method is more efficient. In its simplified version, it does one addition and two divisions, one of which is the trivial division by 2. The initial recurrence with $a_t$ and $b_t$ need a lot more: three divisions plus one addition in the $a_t$ term, and one more division and addition in the $b_t$ term.

*
* *

So at first, reading of this method in Rittaud’s book, it got me to think whether or not the recurrence using $a_t$ and $b_t$ would be faster or more interesting than Newton’s method. Turns out, it’s an interesting but overly complicated way of computing the same thing. Newton wins again.

### 4 Responses to New Way of Computing Square Roots?

1. […] is used to train neural networks of all kinds. Newton’s method for finding square roots (last week’s post) can be thought of as gradient-descent type algorithm with an expression for that depends […]

2. […] another post, I discussed Newton’s algorithm to extract square roots. Read the previous post for the […]

3. […] have discussed the problem of efficient square root calculation quite a few times. And yet, while reading Rudman’s The Babylonian Theorem, I […]

4. […] stable numerical algorithms is usually hard, even for simple problems like the square root, subject we’ve visited a number of times. One method we haven’t explored yet, is using the Taylor series. […]


text:
# Floating in C++ - part 3 - Integration

Notes published the
5 - 7 minutes to read, 1335 words
Categories: c++ floating point math
Keywords: c++ floating point fma integral approximation math newton-cotes

The introduction to this article series can be found here, whereas here you can find all posts.

A common task in numerical analysis is to approximate the value of an integral. In general, integrals are difficult to calculate, unless the function is a polynomial, therefore there are a lot of different techniques.

Most of those rely on the concept we already used when interpolating functions:

Replace a complex function with a polynomial of lower grade.

The Newton-Cotes formulas are a group of algorithms that use polynomial interpolation in equidistant nodes. The Gaussian quadrature rule uses the nodes of Chebyshev and can give us better results.

## Newton-Cotes

The implementation of a Newton-Cotes formula, for example the trapezoidal rule, is trivial, since all formulas are explicit and do not need any memory allocation

``````double integrate_trapezoidal(std::function<double(double)> f, closed_interval interv){
const double h = length(interv);
double result = (f(interv.a) + f(interv.b))/2;
double x_i = std::fma(i, h, interv.a);
result += f(x_i);
return h*result;
}``````

What we are doing in the piece of code above, is approximating the function on the whole interval with a linear function (a polynomial of degree 1) and calculate its integral. A linear function may not approximate our original function very well, so we can split the interval in multiple subintervals and apply on every subinterval the trapezoidal rule. This is what we have done before when approximating functions with polynomials.

``````double integrate_trapezoidal(std::function<double(double)> f, closed_interval interv, std::size_t subintervals = 1){
assert(subintervals > 0);
const double h = length(interv)/fd(subintervals);
double result = (f(interv.a) + f(interv.b))/2;
for(std::size_t i = 1; i != subintervals; ++i){
double x_i = std::fma(i, h, interv.a);
result += f(x_i);
}
return h*result;
}``````

The usage of this function is also very simple

``````double fun_to_integrate(double x){
return x - std::sin(x);
}

int main(){
const closed_interval close_int_to_integrate{0,10};
auto val1 = integrate_trapezoidal(fun_to_integrate, close_int_to_integrate);
const std::size_t num_of_subintervals = 10;
auto val2 = integrate_trapezoidal(fun_to_integrate, close_int_to_integrate, num_of_subintervals);
}``````

There are two types of Newton-Cotes formulae: open formulae and closed ones. The difference between those two are the points where the function is evaluated.

Given the degree of the formula, and the fact that we want to work on an open or closed interval, we can generate an appropriate algorithm.

We can even implement a single function, that will work for any degree and for both open and closed formulae.

``````template<class intervaltype>
double integrate_newton_cotes(std::function<double(double)> f, const intervaltype& interv, std::size_t degree, std::size_t subintervals = 1){
assert(degree > 0);
assert(subintervals > 0);
double par_sum = 0;

equidistant_nodes_closed ext_nodes(closed_interval{interv.a, interv.b}, subintervals+1);
for(auto it = std::begin(ext_nodes); it != std::end(ext_nodes)-1; ++it){
intervaltype interv2 = {*it, *(it+1)};

auto nodes = make_node_gen(interv2, degree);
std::vector<double> data_x;
data_x.reserve(degree);
std::copy(std::begin(nodes), std::end(nodes), std::back_inserter(data_x));
for(std::size_t i = 0; i != data_x.size(); ++i){
auto weight = integrate(lagr_base_poly(std::begin(data_x), std::end(data_x), i), interv2);
par_sum += f(data_x[i]) * weight;
}
}
return par_sum;
}``````

The template is necessary for passing to the same function definition of both open or closed intervals. Based on that, we can create an appropriate "node generator" with the function `make_node_gen`. The "node generator" will then generate the nodes we need on the interval we want to interpolate the functions with, for example

``````class equidistant_nodes_closed{
closed_interval interv;
std::size_t n;
double h;
public:
equidistant_nodes_closed(const closed_interval& interval, std::size_t num_nodes) : interv(interval), n(num_nodes){
h = length(interv)/(fd(n)-1);
}
double operator[](std::size_t i) const {
assert(i<n);
return std::fma(i, h, interv.a);
}
std::size_t size() const noexcept {
return n;
}
// definition of iterator
iterator begin() const {
return iterator(0, *this);
}
iterator end() const {
return iterator(n, *this);
}
};
inline equidistant_nodes_closed make_node_gen(const closed_interval& interval, std::size_t num_nodes){
return equidistant_nodes_closed(interval, num_nodes);
}
inline equidistant_nodes_open make_node_gen(const open_interval& interval, std::size_t num_nodes){
return equidistant_nodes_open(interval, num_nodes);
}``````

For simplicity, we used `equidistant_nodes_closed` for iterating on every subinterval. Then on every subinterval we created a subinterval of the same type that was passed on to the function and generate the points where we want to interpolate the function. At this point, we can reuse the `lagr_base_poly` functions we defined before in the interpolating functions post for generating the interpolation function. By integrating it over the subinterval we will get the weights. We can at last put all together, multiply the function evaluated in all points with the weights, and sum the resulting values together.

As always, the whole source code is available on github

### Possible optimizations

As with others algorithms, there are different optimizations possibilities. For example, for `degree ⇐ N`, with `N` defined at compile time, we could create a lookup-table, where the weights are saved as constants in order to avoid to calculate them every time. This would probably result in a faster and more precise algorithm. If the values are fixed, we do not need to calculate those values every time, and the values would be as precise as possible, instead of calculating them at runtime, which would generally give us a worse approximation. We can, if the `degree` is above a specific threshold, use as fallback the generic formula provided above.

## Usage of `std::fma`

Attentive readers may have noticed that sometimes I’ve used the function std::fma.

The result of `std::fma(x,y,z)` is equivalent to `(x*y)+z`, but is more precise, since the calculation is done with infinite precision, and rounded only once at the end.

So why not use it every time we need to compute a sum and a multiplication? Unfortunately, there are use cases where using the multiply–accumulate operation may cause an incorrect result.

If you consider the following matrix

$\left[\begin{array}{cc}a& a\\ a& a\end{array}\right]$

For every value of `a` that represents a finite number, you want its determinant to be exactly zero.

The determinant is simply calculated by

$a\cdot a-a\cdot a$

and the result is exactly zero if $a\cdot a$ is equal to itself, which is true for all finite floating point numbers (we are therefore supposing that `a*a` will not overflow).

If we use the multiply–accumulate operation, the value of the determinant would be

$a\cdot a+c$

with `c` being a rounded rappresentation of `-a*a` and therefore with a possible different value than `a*a`! This imprecision comes by the fact that the multiply–accumulate operation is not symmetric to the operation we are performing.

Nevertheless, there are use cases when this higher precision won’t certainly harm, for example, when all addends have the same sign. Therefore, for calculating where the next interval begins, we can safely replace `hn = a+h*n` with `hn = std::fma(h,n,a)`.

Does the difference matter in practice? For my use cases probably not. For others, it might.

Unfortunately, from this discussion, it looks like that the compiler is allowed to rearrange operations in order to produce more accurate results. Therefore, a multiply and add operation might be fused together even if this would change the result of our program. A solution to this particular problem would be to write `STDC FP_CONTRACT OFF`, as described on cppreference, or use other compiler-specific switches. If in doubt, you can use the online compiler explorer for verifying what kind of optimizations the compiler is doing for you.

Do you want to share your opinion? Or is there an error, some parts that are not clear enough?

You can contact me anytime.


text:
# [SOLVED]Quotes when processing a reply

#### ZaidAlyafey

##### Well-known member
MHB Math Helper
It would be so nice if I can quote somebody's comment when processing mine without having to go back to the main thread and finding the desired comment.

#### Ackbach

##### Indicium Physicus
Staff member
It would be so nice if I can quote somebody's comment when processing mine without having to go back to the main thread and finding the desired comment.
You can use the Reply with Quote button or the Multi-Quote This Message button when you reply. I used the former in replying to this thread. Do these buttons not do what you're asking? Do you know how to use the Multi-Quote button?

#### ZaidAlyafey

##### Well-known member
MHB Math Helper
I meant that , if I want to quote your comment I have to press on the reply with quote button then write my comment . Assume that I am writing my comment but I wanted to quote somebody's comment now . Do I have to return back to the thread and press the reply with a comment button ? . It would be nice if we can do so by just scrolling down and quote the reply directly without having to return to the thread .

#### Ackbach

##### Indicium Physicus
Staff member
I meant that , if I want to quote your comment I have to press on the reply with quote button then write my comment . Assume that I am writing my comment but I wanted to quote somebody's comment now . Do I have to return back to the thread and press the reply with a comment button ? . It would be nice if we can do so by just scrolling down and quote the reply directly without having to return to the thread .
So you're saying that you'd like there to be more options available to you when you're replying, with respect to previous posts? Currently, it is true, all you can do is look at them. I suppose you could copy plain text, but you can't copy $\LaTeX$ code.

A work-around for now: if you've started a reply, and want to include more previous posts in your reply, then copy your existing post to the clipboard, go back to the thread, select all posts you want to quote, Multi-Quote, then paste your clipboard contents into your reply.

#### ZaidAlyafey

##### Well-known member
MHB Math Helper
So you're saying that you'd like there to be more options available to you when you're replying, with respect to previous posts? Currently, it is true, all you can do is look at them. I suppose you could copy plain text, but you can't copy $\LaTeX$ code.
Exactly .

#### Jameson

Staff member
I meant that , if I want to quote your comment I have to press on the reply with quote button then write my comment . Assume that I am writing my comment but I wanted to quote somebody's comment now . Do I have to return back to the thread and press the reply with a comment button ? . It would be nice if we can do so by just scrolling down and quote the reply directly without having to return to the thread .
Yes, you do. I don't think this is that big of an inconvenience though. It might take ~10-20 seconds to open another tab, hit the quote button, then copy/paste that into your original post. If there were a way to add this feature for you and everyone, I would do it but it's not available right now as a modification for vBulletin. .

So you're saying that you'd like there to be more options available to you when you're replying, with respect to previous posts? Currently, it is true, all you can do is look at them. I suppose you could copy plain text, but you can't copy $\LaTeX$ code.
You can though! Anytime you see a $\LaTeX$ image on MHB you can see its code by:

1) Right click on the image
2) Click "Show Math As"
3) Click "TeX Commands"

#### Ackbach

##### Indicium Physicus
Staff member
You can though! Anytime you see a $\LaTeX$ image on MHB you can see its code by:

1) Right click on the image
2) Click "Show Math As"
3) Click "TeX Commands"

Ah, I see you can do this even when you're replying. Excellent!

#### Jameson

I'm going to mark this thread as [SOLVED] because it's been answered how one can view previous posts in a thread while replying, including $\LaTeX$.


text:
## 7.7 Generalization

We can see that Poisson regression looks similar to logistic regression. Hence, we can generalize to a class of modeling. Thanks to , we have the generalized linear models (GLMs). Estimation is generalize in these models.

Exponential Family
The theory of GLMs is developed for data with distribution given y the exponential family.
The form of the data distribution that is useful for GLMs is

$f(y;\theta, \phi) = \exp(\frac{\theta y - b(\theta)}{a(\phi)} + c(y, \phi))$

where

• $$\theta$$ is called the natural parameter
• $$\phi$$ is called the dispersion parameter

Note:

This family includes the Gamma, Normal, Poisson, and other. For all parameterization of the exponential family, check this link

Example

if we have $$Y \sim N(\mu, \sigma^2)$$

\begin{aligned} f(y; \mu, \sigma^2) &= \frac{1}{(2\pi \sigma^2)^{1/2}}\exp(-\frac{1}{2\sigma^2}(y- \mu)^2) \\ &= \exp(-\frac{1}{2\sigma^2}(y^2 - 2y \mu +\mu^2)- \frac{1}{2}\log(2\pi \sigma^2)) \\ &= \exp(\frac{y \mu - \mu^2/2}{\sigma^2} - \frac{y^2}{2\sigma^2} - \frac{1}{2}\log(2\pi \sigma^2)) \\ &= \exp(\frac{\theta y - b(\theta)}{a(\phi)} + c(y , \phi)) \end{aligned}

where

• $$\theta = \mu$$
• $$b(\theta) = \frac{\mu^2}{2}$$
• $$a(\phi) = \sigma^2 = \phi$$
• $$c(y , \phi) = - \frac{1}{2}(\frac{y^2}{\phi}+\log(2\pi \sigma^2))$$

Properties of GLM exponential families

1. $$E(Y) = b' (\theta)$$ where $$b'(\theta) = \frac{\partial b(\theta)}{\partial \theta}$$ (here ' is “prime,” not transpose)

2. $$var(Y) = a(\phi)b''(\theta)= a(\phi)V(\mu)$$.

• $$V(\mu)$$ is the variance function; however, it is only the variance in the case that $$a(\phi) =1$$
3. If $$a(), b(), c()$$ are identifiable, we will derive expected value and variance of Y.

Example

Normal distribution

$b'(\theta) = \frac{\partial b(\mu^2/2)}{\partial \mu} = \mu \\ V(\mu) = \frac{\partial^2 (\mu^2/2)}{\partial \mu^2} = 1 \\ \to var(Y) = a(\phi) = \sigma^2$

Poisson distribution

\begin{aligned} f(y, \theta, \phi) &= \frac{\mu^y \exp(-\mu)}{y!} \\ &= \exp(y\log(\mu) - \mu - \log(y!)) \\ &= \exp(y\theta - \exp(\theta) - \log(y!)) \end{aligned}

where

• $$\theta = \log(\mu)$$
• $$a(\phi) = 1$$
• $$b(\theta) = \exp(\theta)$$
• $$c(y, \phi) = \log(y!)$$

Hence,

$E(Y) = \frac{\partial b(\theta)}{\partial \theta} = \exp(\theta) = \mu \\ var(Y) = \frac{\partial^2 b(\theta)}{\partial \theta^2} = \mu$

Since $$\mu = E(Y) = b'(\theta)$$

In GLM, we take some monotone function (typically nonlinear) of $$\mu$$ to be linear in the set of covariates

$g(\mu) = g(b'(\theta)) = \mathbf{x'\beta}$

Equivalently,

$\mu = g^{-1}(\mathbf{x'\beta})$

where $$g(.)$$ is the link function since it links mean response ($$\mu = E(Y)$$) and a linear expression of the covariates

Some people use $$\eta = \mathbf{x'\beta}$$ where $$\eta$$ = the “linear predictor”

GLM is composed of 2 components

The random component:

• is the distribution chosen to model the response variables $$Y_1,...,Y_n$$

• is specified by the choice fo $$a(), b(), c()$$ in the exponential form

• Notation:

• Assume that there are n independent response variables $$Y_1,...,Y_n$$ with densities
$f(y_i ; \theta_i, \phi) = \exp(\frac{\theta_i y_i - b(\theta_i)}{a(\phi)}+ c(y_i, \phi))$ notice each observation might have different densities
• Assume that $$\phi$$ is constant for all $$i = 1,...,n$$, but $$\theta_i$$ will vary. $$\mu_i = E(Y_i)$$ for all i.

The systematic component

• is the portion of the model that gives the relation between $$\mu$$ and the covariates $$\mathbf{x}$$

• consists of 2 parts:

• the link function, $$g(.)$$
• the linear predictor, $$\eta = \mathbf{x'\beta}$$
• Notation:

• assume $$g(\mu_i) = \mathbf{x'\beta} = \eta_i$$ where $$\mathbf{\beta} = (\beta_1,..., \beta_p)'$$
• The parameters to be estimated are $$\beta_1,...\beta_p , \phi$$

To choose $$g(.)$$, we can use canonical link function (Remember: Canonical link is just a special case of the link function)

If the link function $$g(.)$$ is such $$g(\mu_i) = \eta_i = \theta_i$$, the natural parameter, then $$g(.)$$ is the canonical link.

• $$b(\theta)$$ = cumulant moment generating function
• $$g(\mu)$$ is the link function, which relates the linear predictor to the mean and is required to be monotone increasing, continuously differentiable and invertible.

Equivalently, we can think of canonical link function as

$\gamma^{-1} \circ g^{-1} = I$ which is the identity. Hence,

$\theta = \eta$

$$g^{-1}(.)$$ is also known as the mean function, take linear predictor output (ranging from $$-\infty$$ to $$\infty$$) and transform it into a different scale.

• Exponential: converts $$\mathbf{\beta X}$$ into a curve that is restricted between 0 and $$\infty$$ (which you can see that is useful in case you want to convert a linear predictor into a non-negative value). $$\lambda = \exp(y) = \mathbf{\beta X}$$
• Inverse Logit (also known as logistic): converts $$\mathbf{\beta X}$$ into a curve that is restricted between 0 and 1, which is useful in case you want to convert a linear predictor to a probability. $$\theta = \frac{1}{1 + \exp(-y)} = \frac{1}{1 + \exp(- \mathbf{\beta X})}$$
• $$y$$ = linear predictor value
• $$\theta$$ = transformed value

$\eta_i = g(\mu_i) = \mu_i \\ \mu_i = g^{-1}(\eta_i) = \eta_i$

Table 15.1 Generalized Linear Models 15.1 the Structure of Generalized Linear Models

More example on the link functions and their inverses can be found on page 380

Example

Normal random component

• Mean Response: $$\mu_i = \theta_i$$

• Canonical Link: $$g( \mu_i) = \mu_i$$ (the identity link)

Binomial random component

• Mean Response: $$\mu_i = \frac{n_i \exp( \theta)}{1+\exp (\theta_i)}$$ and $$\theta(\mu_i) = \log(\frac{p_i }{1-p_i}) = \log (\frac{\mu_i} {n_i - \mu_i})$$

• Canonical link: $$g(\mu_i) = \log(\frac{\mu_i} {n_i - \mu_i})$$ (logit link)

Poisson random component

• Mean Response: $$\mu_i = \exp(\theta_i)$$

• Canonical Link: $$g(\mu_i) = \log(\mu_i)$$

Gamma random component:

• Mean response: $$\mu_i = -\frac{1}{\theta_i}$$ and $$\theta(\mu_i) = - \mu_i^{-1}$$

• Canonical Link: $$g(\mu\_i) = - \frac{1}{\mu_i}$$

Inverse Gaussian random

• Canonical Link: $$g(\mu_i) = \frac{1}{\mu_i^2}$$

### 7.7.1 Estimation

• MLE for parameters of the systematic component ($$\beta$$)
• Unification of derivation and computation (thanks to the exponential forms)
• No unification for estimation of the dispersion parameter ($$\phi$$)

#### 7.7.1.1 Estimation of $$\beta$$

We have

$f(y_i ; \theta_i, \phi) = \exp(\frac{\theta_i y_i - b(\theta_i)}{a(\phi)}+ c(y_i, \phi)) \\ E(Y_i) = \mu_i = b'(\theta) \\ var(Y_i) = b''(\theta)a(\phi) = V(\mu_i)a(\phi) \\ g(\mu_i) = \mathbf{x}_i'\beta = \eta_i$

If the log-likelihood for a single observation is $$l_i (\beta,\phi)$$. The log-likelihood for all n observations is

\begin{aligned} l(\beta,\phi) &= \sum_{i=1}^n l_i (\beta,\phi) \\ &= \sum_{i=1}^n (\frac{\theta_i y_i - b(\theta_i)}{a(\phi)}+ c(y_i, \phi)) \end{aligned}

Using MLE to find $$\beta$$, we use the chain rule to get the derivatives

\begin{aligned} \frac{\partial l_i (\beta,\phi)}{\partial \beta_j} &= \frac{\partial l_i (\beta, \phi)}{\partial \theta_i} \times \frac{\partial \theta_i}{\partial \mu_i} \times \frac{\partial \mu_i}{\partial \eta_i}\times \frac{\partial \eta_i}{\partial \beta_j} \\ &= \sum_{i=1}^{n}(\frac{ y_i - \mu_i}{a(\phi)} \times \frac{1}{V(\mu_i)} \times \frac{\partial \mu_i}{\partial \eta_i} \times x_{ij}) \end{aligned}

If we let

$w_i \equiv ((\frac{\partial \eta_i}{\partial \mu_i})^2 V(\mu_i))^{-1}$

Then,

$\frac{\partial l_i (\beta,\phi)}{\partial \beta_j} = \sum_{i=1}^n (\frac{y_i \mu_i}{a(\phi)} \times w_i \times \frac{\partial \eta_i}{\partial \mu_i} \times x_{ij})$

We can also get the second derivatives using the chain rule.

Example:

For the Newton-Raphson algorithm, we need

$- E(\frac{\partial^2 l(\beta,\phi)}{\partial \beta_j \partial \beta_k})$

where $$(j,k)$$th element of the Fisher information matrix $$\mathbf{I}(\beta)$$

Hence,

$- E(\frac{\partial^2 l(\beta,\phi)}{\partial \beta_j \partial \beta_k}) = \sum_{i=1}^n \frac{w_i}{a(\phi)}x_{ij}x_{ik}$

for the (j,k)th element

If Bernoulli model with logit link function (which is the canonical link)

$b(\theta) = \log(1 + \exp(\theta)) = \log(1 + \exp(\mathbf{x'\beta})) \\ a(\phi) = 1 \\ c(y_i, \phi) = 0 \\ E(Y) = b'(\theta) = \frac{\exp(\theta)}{1 + \exp(\theta)} = \mu = p \\ \eta = g(\mu) = \log(\frac{\mu}{1-\mu}) = \theta = \log(\frac{p}{1-p}) = \mathbf{x'\beta}$

For $$Y_i$$, i = 1,.., the log-likelihood is

$l_i (\beta, \phi) = \frac{y_i \theta_i - b(\theta_i)}{a(\phi)} + c(y_i, \phi) = y_i \mathbf{x}'_i \beta - \log(1+ \exp(\mathbf{x'\beta}))$

$V(\mu_i) = \mu_i(1-\mu_i)= p_i (1-p_i) \\ \frac{\partial \mu_i}{\partial \eta_i} = p_i(1-p_i)$

Hence,

\begin{aligned} \frac{\partial l(\beta, \phi)}{\partial \beta_j} &= \sum_{i=1}^n[\frac{y_i - \mu_i}{a(\phi)} \times \frac{1}{V(\mu_i)}\times \frac{\partial \mu_i}{\partial \eta_i} \times x_{ij}] \\ &= \sum_{i=1}^n (y_i - p_i) \times \frac{1}{p_i(1-p_i)} \times p_i(1-p_i) \times x_{ij} \\ &= \sum_{i=1}^n (y_i - p_i) x_{ij} \\ &= \sum_{i=1}^n (y_i - \frac{\exp(\mathbf{x'_i\beta})}{1+ \exp(\mathbf{x'_i\beta})})x_{ij} \end{aligned}

then

$w_i = ((\frac{\partial \eta_i}{\partial \mu_i})^2 V(\mu_i))^{-1} = p_i (1-p_i)$

$\mathbf{I}_{jk}(\mathbf{\beta}) = \sum_{i=1}^n \frac{w_i}{a(\phi)} x_{ij}x_{ik} = \sum_{i=1}^n p_i (1-p_i)x_{ij}x_{ik}$

The Fisher-scoring algorithm for the MLE of $$\mathbf{\beta}$$ is

$\left( \begin{array} {c} \beta_1 \\ \beta_2 \\ . \\ . \\ . \\ \beta_p \\ \end{array} \right)^{(m+1)} = \left( \begin{array} {c} \beta_1 \\ \beta_2 \\ . \\ . \\ . \\ \beta_p \\ \end{array} \right)^{(m)} + \mathbf{I}^{-1}(\mathbf{\beta}) \left( \begin{array} {c} \frac{\partial l (\beta, \phi)}{\partial \beta_1} \\ \frac{\partial l (\beta, \phi)}{\partial \beta_2} \\ . \\ . \\ . \\ \frac{\partial l (\beta, \phi)}{\partial \beta_p} \\ \end{array} \right)|_{\beta = \beta^{(m)}}$

Similar to Newton-Raphson expect the matrix of second derivatives by the expected value of the second derivative matrix.

In matrix notation,

\begin{aligned} \frac{\partial l }{\partial \beta} &= \frac{1}{a(\phi)}\mathbf{X'W\Delta(y - \mu)} \\ &= \frac{1}{a(\phi)}\mathbf{F'V^{-1}(y - \mu)} \\ \end{aligned}

$\mathbf{I}(\beta) = \frac{1}{a(\phi)}\mathbf{X'WX} = \frac{1}{a(\phi)}\mathbf{F'V^{-1}F} \\$

where

• $$\mathbf{X}$$ is an n x p matrix of covariates
• $$\mathbf{W}$$ is an n x n diagonal matrix with (i,i)th element given by $$w_i$$
• $$\mathbf{\Delta}$$ an n x n diagonal matrix with (i,i)th element given by $$\frac{\partial \eta_i}{\partial \mu_i}$$
• $$\mathbf{F} = \mathbf{\frac{\partial \mu}{\partial \beta}}$$ an n x p matrix with ith row $$\frac{\partial \mu_i}{\partial \beta} = (\frac{\partial \mu_i}{\partial \eta_i})\mathbf{x}'_i$$
• $$\mathbf{V}$$ an n x n diagonal matrix with (i,i)th element given by $$V(\mu_i)$$

Setting the derivative of the log-likelihood equal to 0, ML estimating equations are

$\mathbf{F'V^{-1}y= F'V^{-1}\mu}$

where all components of this equation expect y depends on the parameters $$\beta$$

Special Cases

If one has a canonical link, the estimating equations reduce to

$\mathbf{X'y= X'\mu}$

If one has an identity link, then

$\mathbf{X'V^{-1}y = X'V^{-1}X\hat{\beta}}$

which gives the generalized least squares estimator

Generally, we can rewrite the Fisher-scoring algorithm as

$\beta^{(m+1)} = \beta^{(m)} + \mathbf{(\hat{F}'\hat{V}^{-1}\hat{F})^{-1}\hat{F}'\hat{V}^{-1}(y- \hat{\mu})}$

Since $$\hat{F},\hat{V}, \hat{\mu}$$ depend on $$\beta$$, we evaluate at $$\beta^{(m)}$$

From starting values $$\beta^{(0)}$$, we can iterate until convergence.

Notes:

• if $$a(\phi)$$ is a constant or of the form $$m_i \phi$$ with known $$m_i$$, then $$\phi$$ cancels.

#### 7.7.1.2 Estimation of $$\phi$$

2 approaches:

1. MLE

$\frac{\partial l_i}{\partial \phi} = \frac{(\theta_i y_i - b(\theta_i)a'(\phi))}{a^2(\phi)} + \frac{\partial c(y_i,\phi)}{\partial \phi}$

the MLE of $$\phi$$ solves

$\frac{a^2(\phi)}{a'(\phi)}\sum_{i=1}^n \frac{\partial c(y_i, \phi)}{\partial \phi} = \sum_{i=1}^n(\theta_i y_i - b(\theta_i))$

• Situation others than normal error case, expression for $$\frac{\partial c(y,\phi)}{\partial \phi}$$ are not simple

• Even for the canonical link and $$a(\phi)$$ constant, there is no nice general expression for $$-E(\frac{\partial^2 l}{\partial \phi^2})$$, so the unification GLMs provide for estimation of $$\beta$$ breaks down for $$\phi$$

1. Moment Estimation (“Bias Corrected $$\chi^2$$”)

• The MLE is not conventional approach to estimation of $$\phi$$ in GLMS.
• For the exponential family $$var(Y) =V(\mu)a(\phi)$$. This implies
$a(\phi) = \frac{var(Y)}{V(\mu)} = \frac{E(Y- \mu)^2}{V(\mu)} \\ a(\hat{\phi}) = \frac{1}{n-p} \sum_{i=1}^n \frac{(y_i -\hat{\mu}_i)^2}{V(\hat{\mu})}$ where p is the dimension of $$\beta$$
• GLM with canonical link function $$g(.)= (b'(.))^{-1}$$
$g(\mu) = \theta = \eta = \mathbf{x'\beta} \\ \mu = g^{-1}(\eta)= b'(\eta)$
• so the method estimator for $$a(\phi)=\phi$$ is

$\hat{\phi} = \frac{1}{n-p} \sum_{i=1}^n \frac{(y_i - g^{-1}(\hat{\eta}_i))^2}{V(g^{-1}(\hat{\eta}_i))}$

### 7.7.2 Inference

We have

$\hat{var}(\beta) = a(\phi)(\mathbf{\hat{F}'\hat{V}\hat{F}})^{-1}$

where

• $$\mathbf{V}$$ is an n x n diagonal matrix with diagonal elements given by $$V(\mu_i)$$
• $$\mathbf{F}$$ is an n x p matrix given by $$\mathbf{F} = \frac{\partial \mu}{\partial \beta}$$
• Both $$\mathbf{V,F}$$ are dependent on the mean $$\mu$$, and thus $$\beta$$. Hence, their estimates ($$\mathbf{\hat{V},\hat{F}}$$) depend on $$\hat{\beta}$$.

$H_0: \mathbf{L\beta = d}$

where $$\mathbf{L}$$ is a q x p matrix with a Wald test

$W = \mathbf{(L \hat{\beta}-d)'(a(\phi)L(\hat{F}'\hat{V}^{-1}\hat{F})L')^{-1}(L \hat{\beta}-d)}$

which follows $$\chi_q^2$$ distribution (asymptotically), where q is the rank of $$\mathbf{L}$$

In the simple case $$H_0: \beta_j = 0$$ gives $$W = \frac{\hat{\beta}^2_j}{\hat{var}(\hat{\beta}_j)} \sim \chi^2_1$$ asymptotically

Likelihood ratio test

$\Lambda = 2 (l(\hat{\beta}_f)-l(\hat{\beta}_r)) \sim \chi^2_q$

where

• q is the number of constraints used to fit the reduced model $$\hat{\beta}_r$$, and $$\hat{\beta}_r$$ is the fit under the full model.

Wald test is easier to implement, but likelihood ratio test is better (especially for small samples).

### 7.7.3 Deviance

Deviance is necessary for goodness of fit, inference and for alternative estimation of the dispersion parameter. We define and consider Deviance from a likelihood ratio perspective.

• Assume that $$\phi$$ is known. Let $$\tilde{\theta}$$ denote the full and $$\hat{\theta}$$ denote the reduced model MLEs. Then, the likelihood ratio (2 times the difference in log-likelihoods) is $2\sum_{i=1}^{n} \frac{y_i (\tilde{\theta}_i- \hat{\theta}_i)-b(\tilde{\theta}_i) + b(\hat{\theta}_i)}{a_i(\phi)}$

• For exponential families, $$\mu = E(y) = b'(\theta)$$, so the natural parameter is a function of $$\mu: \theta = \theta(\mu) = b'^{-1}(\mu)$$, and the likelihood ratio turns into
$2 \sum_{i=1}^m \frac{y_i\{\theta(\tilde{\mu}_i - \theta(\hat{\mu}_i)\} - b(\theta(\tilde{\mu}_i)) + b(\theta(\hat{\mu}_i))}{a_i(\phi)}$

• Comparing a fitted model to “the fullest possible model,” which is the saturated model: $$\tilde{\mu}_i = y_i$$, i = 1,..,n. If $$\tilde{\theta}_i^* = \theta(y_i), \hat{\theta}_i^* = \theta (\hat{\mu})$$, the likelihood ratio is
$2 \sum_{i=1}^{n} \frac{y_i (\tilde{\theta}_i^* - \hat{\theta}_i^* + b(\hat{\theta}_i^*))}{a_i(\phi)}$

• specify $$a(\phi) = \phi$$, then the likelihood ratio can be written as
$D^*(\mathbf{y, \hat{\mu}}) = \frac{2}{\phi}\sum_{i=1}^n\{y_i (\tilde{\theta}_i^*- \hat{\theta}_i^*)- b(\tilde{\theta}_i^*) +b(\hat{\theta}_i^*) \}$ where

• $$D^*(\mathbf{y, \hat{\mu}})$$ = scaled deviance

• $$D(\mathbf{y, \hat{\mu}}) = \phi D^*(\mathbf{y, \hat{\mu}})$$ = deviance

Note:

• in some random component distributions, we can write $$a_i(\phi) = \phi m_i$$, where

• $$m_i$$ is some known scalar that may change with the observations. THen, the scaled deviance components are divided by $$m_i$$:
$D^*(\mathbf{y, \hat{\mu}}) \equiv 2\sum_{i=1}^n\{y_i (\tilde{\theta}_i^*- \hat{\theta}_i^*)- b(\tilde{\theta}_i^*) +b(\hat{\theta}_i^*)\} / (\phi m_i)$
• $$D^*(\mathbf{y, \hat{\mu}}) = \sum_{i=1}^n d_i$$m where $$d_i$$ is the deviance contribution from the ith observation.

• D is used in model selection

• $$D^*$$ is used in goodness of fit tests (as it is a likelihood ratio statistic). $D^*(\mathbf{y, \hat{\mu}}) = 2\{l(\mathbf{y,\tilde{\mu}})-l(\mathbf{y,\hat{\mu}})\}$

• $$d_i$$ are used to form deviance residuals

Example:

Normal

We have

$\theta = \mu \\ \phi = \sigma^2 \\ b(\theta) = \frac{1}{2} \theta^2 \\ a(\phi) = \phi$

Hence,

$\tilde{\theta}_i = y_i \\ \hat{\theta}_i = \hat{\mu}_i = g^{-1}(\hat{\eta}_i)$

And

\begin{aligned} D &= 2 \sum_{1=1}^n Y^2_i - y_i \hat{\mu}_i - \frac{1}{2}y^2_i + \frac{1}{2} \hat{\mu}_i^2 \\ &= \sum_{i=1}^n y_i^2 - 2y_i \hat{\mu}_i + \hat{\mu}_i^2 \\ &= \sum_{i=1}^n (y_i - \hat{\mu}_i)^2 \end{aligned}

which is the residual sum of squares

Poisson

$f(y) = \exp\{y\log(\mu) - \mu - \log(y!)\} \\ \theta = \log(\mu) \\ b(\theta) = \exp(\theta) \\ a(\phi) = 1 \\ \tilde{\theta}_i = \log(y_i) \\ \hat{\theta}_i = \log(\hat{\mu}_i) \\ \hat{\mu}_i = g^{-1}(\hat{\eta}_i)$

Then,

\begin{aligned} D &= 2 \sum_{i = 1}^n y_i \log(y_i) - y_i \log(\hat{\mu}_i) - y_i + \hat{\mu}_i \\ &= 2 \sum_{i = 1}^n y_i \log(\frac{y_i}{\hat{\mu}_i}) - (y_i - \hat{\mu}_i) \end{aligned}

and

$d_i = 2\{y_i \log(\frac{y_i}{\hat{\mu}})- (y_i - \hat{\mu}_i)\}$

#### 7.7.3.1 Analysis of Deviance

The difference in deviance between a reduced and full model, where q is the difference in the number of free parameters, has an asymptotic $$\chi^2_q$$. The likelihood ratio test

$D^*(\mathbf{y;\hat{\mu}_r}) - D^*(\mathbf{y;\hat{\mu}_f}) = 2\{l(\mathbf{y;\hat{\mu}_f})-l(\mathbf{y;\hat{\mu}_r})\}$

this comparison of models is Analysis of Deviance. GLM uses this analysis for model selection.

An estimation of $$\phi$$ is

$\hat{\phi} = \frac{D(\mathbf{y, \hat{\mu}})}{n - p}$

where p = number of parameters fit.

Excessive use of $$\chi^2$$ test could be problematic since it is asymptotic

#### 7.7.3.2 Deviance Residuals

We have $$D = \sum_{i=1}^{n}d_i$$. Then, we define deviance residuals

$r_{D_i} = \text{sign}(y_i -\hat{\mu}_i)\sqrt{d_i}$

Standardized version of deviance residuals is

$r_{s,i} = \frac{y_i -\hat{\mu}}{\hat{\sigma}(1-h_{ii})^{1/2}}$

Let $$\mathbf{H^{GLM} = W^{1/2}X(X'WX)^{-1}X'W^{-1/2}}$$, where $$\mathbf{W}$$ is an n x n diagonal matrix with (i,i)th element given by $$w_i$$ (see Estimation of $$\beta$$). Then Standardized deviance residuals is equivalently

$r_{s, D_i} = \frac{r_{D_i}}{\{\hat{\phi}(1-h_{ii}^{glm}\}^{1/2}}$

where $$h_{ii}^{glm}$$ is the ith diagonal of $$\mathbf{H}^{GLM}$$

#### 7.7.3.3 Pearson Chi-square Residuals

Another $$\chi^2$$ statistic is Pearson $$\chi^2$$ statistics: (assume $$m_i = 1$$)

$X^2 = \sum_{i=1}^{n} \frac{(y_i - \hat{\mu}_i)^2}{V(\hat{\mu}_i)}$

where $$\hat{\mu}_i$$ is the fitted mean response fo the model of interest.

The Scaled Pearson $$\chi^2$$ statistic is given by $$\frac{X^2}{\phi} \sim \chi^2_{n-p}$$ where p is the number of parameters estimated. Hence, the Pearson $$\chi^2$$ residuals are

$X^2_i = \frac{(y_i - \hat{\mu}_i)^2}{V(\hat{\mu}_i)}$

If we have the following assumptions:

• Independent samples
• No over-dispersion: If $$\phi = 1$$, $$\frac{D(\mathbf{y;\hat{\mu}})}{n-p}$$ and $$\frac{X^2}{n-p}$$ have a value substantially larger 1 indicates improperly specified model or overdispersion
• Multiple groups

then $$\frac{X^2}{\phi}$$ and $$D^*(\mathbf{y; \hat{\mu}})$$ both follow $$\chi^2_{n-p}$$

### 7.7.4 Diagnostic Plots

• Standardized residual Plots:

• plot($$r_{s, D_i}$$, $$\hat{\mu}_i$$) or plot($$r_{s, D_i}$$, $$T(\hat{\mu}_i)$$) where $$T(\hat{\mu}_i)$$ is transformation($$\hat{\mu}_i$$) called constant information scale:
• plot($$r_{s, D_i}$$, $$\hat{\eta}_i$$)
Random Component $$T(\hat{\mu}_i)$$
Normal $$\hat{\mu}$$
Poisson $$2\sqrt{\mu}$$
Binomial $$2 \sin^{-1}(\sqrt{\hat{\mu}})$$
Gamma $$2 \log(\hat{\mu})$$
Inverse Gaussian $$-2\hat{\mu}^{-1/2}$$
• If we see:

• Trend, it means we might have a wrong link function, or choice of scale
• Systematic change in range of residuals with a change in $$T(\hat{\mu})$$ (incorrect random component) (systematic $$\neq$$ random)
• plot($$|r_{D_i}|,\hat{\mu}_i$$) to check Variance Function.

### 7.7.5 Goodness of Fit

To assess goodness of fit, we can use

In nested model, we could use likelihood-based information measures:

$AIC = -2l(\mathbf{\hat{\mu}}) + 2p \\ AICC = -2l(\mathbf{\hat{\mu}}) + 2p(\frac{n}{n-p-1}) \\ BIC = 2l(\hat{\mu}) + p \log(n)$

where

• $$l(\hat{\mu})$$ is the log-likelihood evaluated at the parameter estimates
• p is the number of parameters
• n is the number of observations.

Note: you have to use the same data with the same model (i.e., same link function, same random underlying random distribution). but you can have different number of parameters.

Even though statisticians try to come up with measures that are similar to $$R^2$$, in practice, it is not so appropriate. For example, they comapre the log-likelihood of the fitted model against the that of a model with jsut the intercept:

$R^2_p = 1 - \frac{l(\hat{\mu})}{l(\hat{\mu}_0)}$

For certain specific random components such as binary response model, we have **rescaled generalized $$R^2$$:

$\bar{R}^2 = \frac{R^2_*}{\max(R^2_*)} = \frac{1-\exp\{-\frac{2}{n}(l(\hat{\mu}) - l(\hat{\mu}_0) \}}{1 - \exp\{\frac{2}{n}l(\hat{\mu}_0)\}}$

### 7.7.6 Over-Dispersion

Random Components $$var(Y)$$ $$V(\mu)$$
Binomial $$var(Y) = n \mu (1- \mu)$$ $$V(\mu) = \phi n \mu(1- \mu)$$ where $$m_i =n$$
Poisson $$var(Y) = \mu$$ $$V(\mu) = \phi \mu$$

In both cases $$\phi = 1$$. Recall $$b''(\theta)= V(\mu)$$ check Estimation of $$\phi$$.

If we find

• $$\phi >1$$: over-dispersion (i.e., too much variation for an independent binomial or Poisson distribution).
• $$\phi<1$$: under-dispersion (i.e., too little variation for an independent binomial or Poisson distribution).

If we have either over or under-dispersion, it means we might have unspecified random component, we could

• Select a different random component distribution that can accommodate over or under-dispersion (e.g., negative binomial, Conway-Maxwell Poisson)
• use Generalized Linear Mixed Models to handle random effects in generalized linear models.


text:
# (Co)homology of Spectral Categories

Research paper by Jonathan A. Campbell

Indexed on: 23 Dec '15Published on: 23 Dec '15Published in: Mathematics - Algebraic Topology

#### Abstract

In this article we develop the cotangent complex and (co)homology theories for spectral categories. Along the way, we reproduce standard model structures on spectral categories. As applications, we show that the invariants to descend to stable $\infty$-categories and we prove a stabilization result for spectral categories.


text:
# linear algebra solutions

David Poole . Suppose we represent a homogeneous system of equations by $$T\left(\vec{x}\right)=0$$. Applications of Linear Algebra. Suppose a linear system of equations can be written in the form $T\left(\vec{x}\right)=\vec{b}$ If $$T\left(\vec{x}_{p}\right)=\vec{b},$$ then $$\vec{x}_{p}$$ is called a particular solution of the linear system. Also don’t need to give your email address, just enter a school where it asks for your email address.) Definition $$\PageIndex{1}$$: Particular Solution of a System of Equations. Introductory D Principle of Mathematical Induction, Section 1.6 Transpose and Inverse of a matrix examples, Section 1.6 Transpose and Inverse of a Matrix examples II, Section 6.1: Determinant of a 2 by 2 matrix Pages 431 – 438, Notes on the determinant of 2 by 2 matrix, Section 6.2: Determinant and Inverse of a matrix Pages 442 to 452, Notes on Determinant of n by n and inverse matrix, Section 7.1 Introduction to Eigenvalues and Eigenvectors Pages 491 497, Section 7.1 Introduction to Evalues and Evectors Pages 497-502, Online test on eigenvalues and eigenvectors, Section 7.2 Properties of Eigenvalues\vectors Pages 503 – 507, Section 7.2 Properties of Eigenvalues\vectors Pages 507 – 513, Section 7.2 Cayley Hamilton Theorem pages 513-517, Notes on Section 7.2 Cayley Hamilton Theorem Pages 513-517, Section 7.3 Diagonalization pages 518-522, Notes on Section 7.3 Diagonalization Pages 518-522, Section 7.3 Introduction to Diagonalisation page 522 – 526, Section 7.4 Orthogonal Diagonalization pages 537, Notes on Section 7.4 Orthogonal Diagonalization page 537, If you are an academic and would like complete solutions to these problems then email me at k.singh@herts.ac.uk, Challenging Problems on Linear Algebra with complete solutions are Here. Test on Gaussian Elimination – Section 1.2, Systems of Linear Equations 1.1 pages 6-11, Section 1.2 Gaussian Elimination pages 12-15, Section 1.2 Gaussian Elimination pages 16-19, Section 1.2 Gaussian Elimination pages 19-22, Section 1.2 Gaussian Elimination pages 22-25, Section 1.2 Gaussian Elimination Examples, Reduced Row echelon form for a larger system, Chapter 1 Section 1.3 Vector Arithmetic pages 27-30, Chapter 1 Section 1.3 Vector Arithmetic pages 30-33, Chapter 1 Section 1.3 Vector Arithmetic pages 33-37, Chapter 1.4 Arithmetic of Matrices pages 41-46, Chapter 1.4 Arithmetic of Matrices pages 47-52, Chapter 1.4 Arithmetic of Matrices pages 52-55, Section 1.4 Arithmetic of Matrices Examples, Section 1.4 Arithmetic of Matrices Examples II, Test on Arithmetic of Matrices – Section 1.4, Section 1.5 Matrix Algebra another example, Test on Manipulation of Matrices – Section 1.5, Chapter 1.6 The Transpose and Inverse of a Matrix Pages 75-79, Chapter 1.6 The Identity and Inverse Matrix pages 80-82, Section 1.6 The Transpose and Inverse Matrix pages 83-85, Section 1.6 Properties of the Inverse Matrix pages 85-89, Section 1.7 Types of Solutions pages 91-95, Exam questions on sections 1.6 and 1.7.pdf, Section 1.8 Inverse Matrix Method pages 105-108, Section 1.8 Inverse Matrix Method pages 108-110, Section 1.8 The Inverse Matrix Method pages 110-115, Section 1.8 Exercises 1.8 question 4(e) page 118, Section 1.8 Exercises 1.8 Question 4d page 118, Section 1.8 Exercises 1.8 question 4c page 118, Miscellaneous Exercises 1 Question 1.27 page 124, Miscellaneous Exercises 1 Question 16 page 122, Section 2.1 Properties of Vectors pages 129-130, Section 2.1 Properties of Vectors pages 130-36, Section 2.1 Properties of Vectors pages 136-39, Section 2.2 Further Properties of Vectors pages 143-49, Section 2.3 Linear Independence pages 159-165, Section 2.3 Linear Independence pages 165-69, Section 2.3 Linear Independence exercises 2.3, Section 2.4 Basis and Spanning Set pages 178-182, Section 3.1 Introduction to Vector Spaces pages 191-194, Section 3.1 Introduction to Vector Spaces pages 196-200, Section 3.2 Subspace of a Vector Space pages 202-207, Section 3.2 Subspace of a Vector Space pages 208-209, Exercises 3.2 Questions 10 and 12 page 215, Section 3.3 Linear Independence and Basis pages 216-221, Section 3.3 Linear Independence and Basis pages 223-227, 3.6.2 Properties of rank and nullity pages 259-67, Section 4.1 Introduction to I… Product Spaces pages 277-282, Section 4.1 Introduction to I…r Product Spaces pages 282-85, Section 4.1 Introduction to I…r Product Spaces pages 286-88, Exercises 4.1 Inner Product Space pages 288-90, Exam question on Inner Product Spaces pages 335-36, Section 4.2 Inequalities and Orthogonality pages 290-96, Section 4.2 Inequalities and Orthogonality pages 296-98, Section 4.2 Orthogonality, orthonormal set page 299-303, Section 4.3 Orthonormal Basis page 306-311, Section 4.3 Orthonrmal Basis page 312-317, Section 4.3 Orthonormal Basis pages 317-320, Section 4.4 Orthogonal Matrices pages 321-327, Test on Inverse and other properties of a matrix - Section 6.2, Test on Properties of Eigenvalues and Eigenvectors - Section 7.2, Section I: Principle of Mathematical Induction. On the following test enter your truth values in numerical order. Indeed given a system of linear equations of the form $$A\vec{x}=\vec{b}$$, one may rephrase this as $$T(\vec{x})=\vec{b}$$ where $$T$$ is the linear transformation $$T_A$$ induced by the coefficient matrix $$A$$. All the test questions below were developed by Dr Martin Greenhow and his team at Brunel University London. Suppose we look at a system given by $$A\vec{x}=\vec{b}$$, and consider the related homogeneous system. This is the linear system $\begin{array}{c} x+2y+3z=0 \\ 2x+y+z+2w=0 \\ 4x+5y+7z+2w=0 \end{array}$ To solve, set up the augmented matrix and row reduce to find the reduced row-echelon form. This is a much more effective way of learning because you will have an understanding of the material and now what is required of you. Below is a set of supplementary notes on Linear Algebra. Now is the time to redefine your true self using Slader’s Linear Algebra and Its Applications answers. In addition, constraints involving three equa- tions like above and going through the origin (this is eﬀectively a one dimensional line). Since $$\vec{y}$$ and $$\vec{x}_{p}$$ are both solutions to the system, it follows that $$T\left(\vec{y}\right)= \vec{b}$$ and $$T\left(\vec{x}_p\right) = \vec{b}$$. We have spent a lot of time finding solutions to systems of equations in general, as well as homogeneous systems. Linear Algebra 2nd Edition by Kenneth M Hoffman, Ray Kunze (see solutions here) Good Linear Algebra textbooks (not complete) Introduction to Linear Algebra, Fifth Edition by Gilbert Strang, Solution Manual; Linear Algebra and Its Applications (5th Edition) by David C. Lay, Steven R. Lay, Judi J. McDonald For now, we have been speaking about the kernel or null space of a linear transformation $$T$$. Watch the recordings here on Youtube! A good way to revise for examination is to try past examination papers.

Lithium Hexafluorophosphate Solution, Best Soda For Upset Stomach, Godrej Washing Machine Wf Eon 7010 Pasc Price, Korean Vegetable Salad Recipes, 316 Stainless Steel Composition, Ginger Pear Blackberry Cobbler Crisp, Best Shea Moisture Products For Hair Growth, Exponential Growth Function Calculator, Raag Kedar Aaroh Avroh, Windows 1o Forum, Keto Spicy Chicken Marinade, Glen Park Tavern Fish Fry, Calories In Kodiak Waffles, Glen Park Tavern Williamsville, Ny Menu With Prices, Soy Vay Teriyaki Sauce Nutrition Facts, Protein Contact Map Viewer, Peanut Butter Sandwich Cookies With Cream Cheese Filling, Automatic High Beam Headlamp Control Jeep, Acesulfame K Side Effects, Seven Sisters Sussex, Martin Lx1 Little Martin Review, Serta Perfect Sleeper Hybrid Luxury Firm, Polyurethane Plastic Properties, Recorder Vs Flute Sound,


text:
# Given iid samples from the joint distribution $P$ of pair of r.v.'s $(X,Y)$, how to get iid samples from independence coupling $P_X \otimes P_Y$?

Let $$(X,Y)$$ be a pair of random variables on a measure space $$\mathcal T \subseteq \text{"subsets of }\mathbb R^2\text{"}$$, with joint probability distribution $$P$$.

We don't assume $$X$$ and $$Y$$ are independent!

Let $$P_X$$ (resp. $$P_Y$$) be the marginal distribution of $$X$$ (resp. $$Y$$), defined by $$P_X(A) := \int_{p_1(A)} \,dP$$, where $$\mathcal p_k(A) := \{(z_1,z_2) \in \mathcal T \mid z_k \in A\}$$ defines the projection operator unto the $$k$$ coordinate of $$\mathcal T$$. Let $$\Pi(X,Y)$$ be the set of all couplings of $$X$$ and $$Y$$, i.e the set of all probability distributions on $$\mathcal T$$, with same margins as $$P$$. Finally, let $$P_X \otimes P_Y \in \Pi(X,Y)$$ be the independence coupling of $$X$$ and $$Y$$ defined by $$(P_X \otimes P_Y)(U) := P_X(p_1(U))\cdot P_Y(p_2(U)).$$

Let $$k$$ and $$n$$ be positive integers, presumably, with $$n \gg k$$.

Question. Given $$n$$ independent copies $$(X_1,Y_1),\ldots,(X_n,Y_n)$$ of $$(X,Y)$$ (i.e an iid sample of size $$n$$ from the joint distribution $$P$$), what is a principled way to obtain an iid sample from $$P_X \otimes P_Y$$ of size $$k$$ ?

• If you have $2n$ i.i.d. copies $(X_1,Y_1),\ldots,(X_{2n},Y_{2n})$ of $(X,Y)$ you get $n$ i.i.d. randon vectors $(X_1,Y_{n+1}),(X_2,Y_{n+k}),\ldots, (X_n,Y_{2n})$ distributed acording to $P_X\otimes P_Y$. In general, you can't get more, e.g., in the extreme case $X_k=Y_k$. Apr 12, 2022 at 14:11
• Indeed, I should have thought of that. Thanks! Apr 12, 2022 at 14:30
• $$\mathcal T \subseteq \text{"subsets of }\mathbb R^2\text{"}$$ $$\mathcal T \subseteq \text{subsets of }\mathbb R^2\text{''}$$ $$\mathcal T \subseteq \text{“subsets of } \mathbb R^2\text{”}$$ I don't know how the three lines above appear on other people's browsers but on mine they're quite different from each other. I would use the third one. I typed “” in the box used for posting answers, then copied the symbols that consequently appeared and pasted them into \text{}. $\qquad$ Apr 12, 2022 at 18:19
• I would call the tuple of pairs $(X_1,Y_1),\ldots,(X_n,Y_n)$ a "sample of size $n$" rather than "$n$ samples." That is standard usage in statistics, as when one refers to "sample size" or two a "two-sample t-test", etc. Apr 12, 2022 at 18:23

It is unclear to me what "a principled way" could mean.

However, given $$n$$ iid pairs $$(X_1,Y_1),\dots,(X_n,Y_n)$$, it is easy to get $$k:=\lfloor n/2\rfloor$$ iid pairs $$(X_1,Z_1),\dots,(X_k,Z_k)$$ such that, for each $$j\in\{1,\dots,k\}$$, (i) the random variables $$X_j$$ and $$Z_j$$ are independent and (ii) $$Z_j$$ equals $$Y_j$$ in distribution:

Just let $$Z_j:=Y_{k+j}$$ for all $$j\in\{1,\dots,k\}$$.

If the joint probability distribution $$P_{X,Y}$$ of the pair $$(X,Y)$$ is known, then it may be possible to get an iid sample of size $$n$$ from the distribution $$P_X\otimes P_Y$$ using an iid sample of (the same) size $$n$$ from the distribution $$P_{X,Y}$$. This could be done by applying a transformation $$T\colon\mathbb R^2\to\mathbb R^2$$ to the pair $$(X,Y)$$ to get a pair $$(U,V):=T(X,Y)$$ with distribution $$P_X\otimes P_Y$$.

The transformation $$T$$ can apparently be obtained by discrete approximation, as follows. For each natural $$n$$, let $$X_n$$ and $$Y_n$$ be discrete random variables (r.v.'s), say each taking only finitely many values, such that $$X_n\to X$$ and $$Y_n\to X$$ in probability (as $$n\to\infty$$). Then $$P_{X_n,Y_n}\to P_{X,Y}$$, $$P_{X_n}\to P_X$$, $$P_{Y_n}\to P_Y$$, and $$P_{X_n}\otimes P_{Y_n}\to P_X\otimes P_Y$$ weakly.

Then for each natural $$n$$ there is a transformation $$T_n\colon\mathbb R^2\to\mathbb R^2$$ such that the pair $$(U_n,V_n):=T_n(X_n,Y_n)$$ has the distribution $$P_{X_n}\otimes P_{Y_n}$$. This follows because any discrete set can be transformed bijectively to a set on the real line.

If now the set $$\{T_n\colon n\in\mathbb N\}$$ is compact in an appropriate sense, then, passing to a subsequence, from the pairs $$(U_n,V_n)=T_n(X_n,Y_n)$$ with distributions $$P_{X_n}\otimes P_{Y_n}$$ one will get a pair $$(U,V):=T(X,Y)$$ with distribution $$P_X\otimes P_Y$$.

• Indeed, I should have thought of that. Thanks! Please could you clarify what you mean by "can be apparently be done by discrete approximation". Apr 12, 2022 at 14:29
• @dohmatob : I'll explain the discretization idea later. Apr 12, 2022 at 14:35
• Ok, thanks again. Apr 12, 2022 at 14:36
• @dohmatob : I have now added details on the discrete approximation. Apr 12, 2022 at 17:11
• ok, thanks for the construction. Apr 12, 2022 at 18:28