- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# Evaluation of Risk in Investments in C++

In this problem, we are given two arrays each denoting an investment plan. Our task is to perform the *evaluation of Risk in Investment *and find which of the two investments is more promising.

Both the investments I1[][] and I2[][] has a set of outcomes and the probability of that investment outcome.

Using these values, we need to find the risk in each investment and then print the better investment out of the two investments.

For this, we will be using statistical mathematics and find some values that will help us conclude to the better investment.

We will find these values,

**Mean or average amount form the investment,**the sum of product of investment outcome and probability.**Deviation on the amount earned**

We will find the value of,

*standard Deviation / mean of investment about*

The investment with a lesser value of S.D. / mean is the result.

## Program to illustrate the working of our solution,

## Example

#include <iostream> #include <vector> #include <algorithm> #include <cmath> using namespace std; typedef pair<float,float> Data; typedef vector Vector; float totalProdProbOutcome(const Vector & v) { float sum = 0; for ( auto i : v) { sum += i.first * i.second; } return sum; } float totalProb(const Vector & v) { float sum = 0.0; for ( auto i : v) { sum += i.second; } return sum; } float CalcMeanVal(const Vector & v) { return totalProdProbOutcome(v) / totalProb(v); } float calcStdDevi(const Vector & v) { float mean = CalcMeanVal(v); float sum = 0; for (auto i: v) sum += (i.first-mean)* (i.first-mean)*i.second; return sqrt(sum/totalProb(v)); } int main() { Vector A = { {450,0.3}, {250,0.4}, {100,0.2}, {300,0.1}}; Vector B = { {300,0.2}, {150,0.5}, {500,0.3}}; float meanA = CalcMeanVal(A); float meanB = CalcMeanVal(B); float SdA = calcStdDevi(A); float SdB = calcStdDevi(B); if( (SdA / meanA) > (SdB / meanB)) cout<<"Investment A is Better investment.\n"; else cout<<"Investment B is better investment.\n"; return 0; }

## Output −

Investment B is better investment.

- Related Questions & Answers
- What are the three important steps in the evaluation of investments?
- Evaluation of Expression Tree in C++
- Evaluation of Prefix Expressions in C++
- Evaluation order of operands in C++
- Order of evaluation in C++ function parameters
- Explain the evaluation of expressions of stacks in C language
- What is evaluation order of function parameters in C?
- Principles of Risk Management and Paradigm in C++
- Evaluation of Boolean expression
- What are the three components of cash in investments?
- Types of Investments – Expansion, Diversification, Modernization, Replacement
- Short-circuit evaluation in JavaScript
- What are mutually exclusive investments?
- What is Evaluation, Precedence and Association in C language?
- Risk-averse Investors Vs Risk-neutral Investors

Advertisements