First presented at the MSUG Conference on June 4, 2015, this presentation discusses concepts and tools to add to your logistic regression modeling practice and also how to use these concepts and tools.
First presented at the MSUG Conference on June 4, 2015, this presentation discusses concepts and tools to add to your logistic regression modeling practice and also how to use these concepts and tools.
I am Watson A. I am a Statistics Assignment Expert at statisticsassignmenthelp.com. I hold a Masters in Statistics from, Liberty University, USA
I have been helping students with their homework for the past 6 years. I solve assignments related to Statistics.
Visit statisticsassignmenthelp.com or email info@statisticsassignmenthelp.com.
You can also call on +1 678 648 4277 for any assistance with Statistics Assignments.
In this slide, the following topics are discussed. Radix number system, Binary number system, Octal, Hexadecimal, Octal to Binary, Binary to Octal, Hexadecimal to binary, Binary to Hexadecimal, BCD codes, Gray codes, one's complement, two's complement, signed magnitude number system, fixed point representation, floating point representation and their conversion.
Computer graphics lab report with code in cppAlamgir Hossain
This is the lab report for computer graphics in cpp language. Basically this course is only for the computer science and engineering students.
Problem list:
1.Program for the generation of Bresenham Line Drawing.
2. Program for the generation of Digital Differential Analyzer (DDA) Line Drawing.
3. Program for the generation of Midpoint Circle Drawing.
4. Program for the generation of Midpoint Ellipse Drawing.
5. Program for the generation of Translating an object.
6. Program for the generation of Rotating an Object.
7. Program for the generation of scaling an object.
All programs are coaded in cpp language .
This slide contain description about the line, circle and ellipse drawing algorithm in computer graphics. It also deals with the filled area primitive.
Because binary logic is used in all of today´s digital computers and devices, the cost of the circuit that implement it is important factor addressed by designers- be they computer engineers, electrical engineers, or computer scientist.
I am Watson A. I am a Statistics Assignment Expert at statisticsassignmenthelp.com. I hold a Masters in Statistics from, Liberty University, USA
I have been helping students with their homework for the past 6 years. I solve assignments related to Statistics.
Visit statisticsassignmenthelp.com or email info@statisticsassignmenthelp.com.
You can also call on +1 678 648 4277 for any assistance with Statistics Assignments.
In this slide, the following topics are discussed. Radix number system, Binary number system, Octal, Hexadecimal, Octal to Binary, Binary to Octal, Hexadecimal to binary, Binary to Hexadecimal, BCD codes, Gray codes, one's complement, two's complement, signed magnitude number system, fixed point representation, floating point representation and their conversion.
Computer graphics lab report with code in cppAlamgir Hossain
This is the lab report for computer graphics in cpp language. Basically this course is only for the computer science and engineering students.
Problem list:
1.Program for the generation of Bresenham Line Drawing.
2. Program for the generation of Digital Differential Analyzer (DDA) Line Drawing.
3. Program for the generation of Midpoint Circle Drawing.
4. Program for the generation of Midpoint Ellipse Drawing.
5. Program for the generation of Translating an object.
6. Program for the generation of Rotating an Object.
7. Program for the generation of scaling an object.
All programs are coaded in cpp language .
This slide contain description about the line, circle and ellipse drawing algorithm in computer graphics. It also deals with the filled area primitive.
Because binary logic is used in all of today´s digital computers and devices, the cost of the circuit that implement it is important factor addressed by designers- be they computer engineers, electrical engineers, or computer scientist.
I am Samuel H. I am a Mechanical Engineering Assignment Expert at matlabassignmentexperts.com. I hold a Ph.D. Matlab, University of Alberta, Canada. I have been helping students with their homework for the past 12 years. I solve assignments related to Mechanical Engineering.
Visit matlabassignmentexperts.com or email info@matlabassignmentexperts.com.
You can also call on +1 678 648 4277 for any assistance with Mechanical Engineering Assignments.
Determination of Optimal Product Mix for Profit Maximization using Linear Pro...IJERA Editor
This paper demonstrates the use of liner programming methods in order to determine the optimal product mix for
profit maximization. There had been several papers written to demonstrate the use of linear programming in
finding the optimal product mix in various organization. This paper is aimed to show the generic approach to be
taken to find the optimal product mix.
Determination of Optimal Product Mix for Profit Maximization using Linear Pro...IJERA Editor
This paper demonstrates the use of liner programming methods in order to determine the optimal product mix for
profit maximization. There had been several papers written to demonstrate the use of linear programming in
finding the optimal product mix in various organization. This paper is aimed to show the generic approach to be
taken to find the optimal product mix.
Our fall 12-Week Data Science bootcamp starts on Sept 21st,2015. Apply now to get a spot!
If you are hiring Data Scientists, call us at (1)888-752-7585 or reach info@nycdatascience.com to share your openings and set up interviews with our excellent students.
---------------------------------------------------------------
Come join our meet-up and learn how easily you can use R for advanced Machine learning. In this meet-up, we will demonstrate how to understand and use Xgboost for Kaggle competition. Tong is in Canada and will do remote session with us through google hangout.
---------------------------------------------------------------
Speaker Bio:
Tong is a data scientist in Supstat Inc and also a master students of Data Mining. He has been an active R programmer and developer for 5 years. He is the author of the R package of XGBoost, one of the most popular and contest-winning tools on kaggle.com nowadays.
Pre-requisite(if any): R /Calculus
Preparation: A laptop with R installed. Windows users might need to have RTools installed as well.
Agenda:
Introduction of Xgboost
Real World Application
Model Specification
Parameter Introduction
Advanced Features
Kaggle Winning Solution
Event arrangement:
6:45pm Doors open. Come early to network, grab a beer and settle in.
7:00-9:00pm XgBoost Demo
Reference:
https://github.com/dmlc/xgboost
In this paper, we present a complete digital signature message stream, just the way the RSA digital
signature scheme does it. We will focus on the operations with large numbers due to the fact that operating
with large numbers is the essence of RSA that cannot be understood by the usual illustrative examples with
small numbers[1].
Similar to A few solvers for portfolio selection (20)
Dispatching taxi cabs with ridesharing – an efficient implementation of popul...Bogusz Jelinski
The article describes how to effectively dispatch hundreds of thousands
ride requests per hour, with thousands of cabs. Not only which cab should pick up
which passenger, but which passengers should share a ride and what is the best pickup
and drop-off order. An automatic dispatching process has been implemented to
verify feasibility of such cab sharing solution, simulation was used to check quality
of routes. Performance of different programming tools and frameworks has been
tested. Thousands of passengers per minute could be dispatched with basic
algorithms and simple hardware and they can be dispatched in a cab sharing scheme
very effectively, at least 11 passengers per cab per hour. The spotlight is on practical
aspects, not well-known theory. The goal is to verify feasibility of a large-scale
dispatcher and to give its benchmark. Implementation of algorithms including a
dispatcher and simulation environment is available as open source on GitHub.
Dividend portfolio – multi-period performance of portfolio selection based so...Bogusz Jelinski
What will happen to your investment if you ignore change of share prices while calculating both returns and risk during stocks portfolio selection? Is it profitable in long term to
sell a share when its price has started to skyrocket?
Observation of Io’s Resurfacing via Plume Deposition Using Ground-based Adapt...Sérgio Sacani
Since volcanic activity was first discovered on Io from Voyager images in 1979, changes
on Io’s surface have been monitored from both spacecraft and ground-based telescopes.
Here, we present the highest spatial resolution images of Io ever obtained from a groundbased telescope. These images, acquired by the SHARK-VIS instrument on the Large
Binocular Telescope, show evidence of a major resurfacing event on Io’s trailing hemisphere. When compared to the most recent spacecraft images, the SHARK-VIS images
show that a plume deposit from a powerful eruption at Pillan Patera has covered part
of the long-lived Pele plume deposit. Although this type of resurfacing event may be common on Io, few have been detected due to the rarity of spacecraft visits and the previously low spatial resolution available from Earth-based telescopes. The SHARK-VIS instrument ushers in a new era of high resolution imaging of Io’s surface using adaptive
optics at visible wavelengths.
This pdf is about the Schizophrenia.
For more details visit on YouTube; @SELF-EXPLANATORY;
https://www.youtube.com/channel/UCAiarMZDNhe1A3Rnpr_WkzA/videos
Thanks...!
Earliest Galaxies in the JADES Origins Field: Luminosity Function and Cosmic ...Sérgio Sacani
We characterize the earliest galaxy population in the JADES Origins Field (JOF), the deepest
imaging field observed with JWST. We make use of the ancillary Hubble optical images (5 filters
spanning 0.4−0.9µm) and novel JWST images with 14 filters spanning 0.8−5µm, including 7 mediumband filters, and reaching total exposure times of up to 46 hours per filter. We combine all our data
at > 2.3µm to construct an ultradeep image, reaching as deep as ≈ 31.4 AB mag in the stack and
30.3-31.0 AB mag (5σ, r = 0.1” circular aperture) in individual filters. We measure photometric
redshifts and use robust selection criteria to identify a sample of eight galaxy candidates at redshifts
z = 11.5 − 15. These objects show compact half-light radii of R1/2 ∼ 50 − 200pc, stellar masses of
M⋆ ∼ 107−108M⊙, and star-formation rates of SFR ∼ 0.1−1 M⊙ yr−1
. Our search finds no candidates
at 15 < z < 20, placing upper limits at these redshifts. We develop a forward modeling approach to
infer the properties of the evolving luminosity function without binning in redshift or luminosity that
marginalizes over the photometric redshift uncertainty of our candidate galaxies and incorporates the
impact of non-detections. We find a z = 12 luminosity function in good agreement with prior results,
and that the luminosity function normalization and UV luminosity density decline by a factor of ∼ 2.5
from z = 12 to z = 14. We discuss the possible implications of our results in the context of theoretical
models for evolution of the dark matter halo mass function.
Nutraceutical market, scope and growth: Herbal drug technologyLokesh Patil
As consumer awareness of health and wellness rises, the nutraceutical market—which includes goods like functional meals, drinks, and dietary supplements that provide health advantages beyond basic nutrition—is growing significantly. As healthcare expenses rise, the population ages, and people want natural and preventative health solutions more and more, this industry is increasing quickly. Further driving market expansion are product formulation innovations and the use of cutting-edge technology for customized nutrition. With its worldwide reach, the nutraceutical industry is expected to keep growing and provide significant chances for research and investment in a number of categories, including vitamins, minerals, probiotics, and herbal supplements.
Introduction:
RNA interference (RNAi) or Post-Transcriptional Gene Silencing (PTGS) is an important biological process for modulating eukaryotic gene expression.
It is highly conserved process of posttranscriptional gene silencing by which double stranded RNA (dsRNA) causes sequence-specific degradation of mRNA sequences.
dsRNA-induced gene silencing (RNAi) is reported in a wide range of eukaryotes ranging from worms, insects, mammals and plants.
This process mediates resistance to both endogenous parasitic and exogenous pathogenic nucleic acids, and regulates the expression of protein-coding genes.
What are small ncRNAs?
micro RNA (miRNA)
short interfering RNA (siRNA)
Properties of small non-coding RNA:
Involved in silencing mRNA transcripts.
Called “small” because they are usually only about 21-24 nucleotides long.
Synthesized by first cutting up longer precursor sequences (like the 61nt one that Lee discovered).
Silence an mRNA by base pairing with some sequence on the mRNA.
Discovery of siRNA?
The first small RNA:
In 1993 Rosalind Lee (Victor Ambros lab) was studying a non- coding gene in C. elegans, lin-4, that was involved in silencing of another gene, lin-14, at the appropriate time in the
development of the worm C. elegans.
Two small transcripts of lin-4 (22nt and 61nt) were found to be complementary to a sequence in the 3' UTR of lin-14.
Because lin-4 encoded no protein, she deduced that it must be these transcripts that are causing the silencing by RNA-RNA interactions.
Types of RNAi ( non coding RNA)
MiRNA
Length (23-25 nt)
Trans acting
Binds with target MRNA in mismatch
Translation inhibition
Si RNA
Length 21 nt.
Cis acting
Bind with target Mrna in perfect complementary sequence
Piwi-RNA
Length ; 25 to 36 nt.
Expressed in Germ Cells
Regulates trnasposomes activity
MECHANISM OF RNAI:
First the double-stranded RNA teams up with a protein complex named Dicer, which cuts the long RNA into short pieces.
Then another protein complex called RISC (RNA-induced silencing complex) discards one of the two RNA strands.
The RISC-docked, single-stranded RNA then pairs with the homologous mRNA and destroys it.
THE RISC COMPLEX:
RISC is large(>500kD) RNA multi- protein Binding complex which triggers MRNA degradation in response to MRNA
Unwinding of double stranded Si RNA by ATP independent Helicase
Active component of RISC is Ago proteins( ENDONUCLEASE) which cleave target MRNA.
DICER: endonuclease (RNase Family III)
Argonaute: Central Component of the RNA-Induced Silencing Complex (RISC)
One strand of the dsRNA produced by Dicer is retained in the RISC complex in association with Argonaute
ARGONAUTE PROTEIN :
1.PAZ(PIWI/Argonaute/ Zwille)- Recognition of target MRNA
2.PIWI (p-element induced wimpy Testis)- breaks Phosphodiester bond of mRNA.)RNAse H activity.
MiRNA:
The Double-stranded RNAs are naturally produced in eukaryotic cells during development, and they have a key role in regulating gene expression .
What is greenhouse gasses and how many gasses are there to affect the Earth.moosaasad1975
What are greenhouse gasses how they affect the earth and its environment what is the future of the environment and earth how the weather and the climate effects.
Richard's aventures in two entangled wonderlandsRichard Gill
Since the loophole-free Bell experiments of 2020 and the Nobel prizes in physics of 2022, critics of Bell's work have retreated to the fortress of super-determinism. Now, super-determinism is a derogatory word - it just means "determinism". Palmer, Hance and Hossenfelder argue that quantum mechanics and determinism are not incompatible, using a sophisticated mathematical construction based on a subtle thinning of allowed states and measurements in quantum mechanics, such that what is left appears to make Bell's argument fail, without altering the empirical predictions of quantum mechanics. I think however that it is a smoke screen, and the slogan "lost in math" comes to my mind. I will discuss some other recent disproofs of Bell's theorem using the language of causality based on causal graphs. Causal thinking is also central to law and justice. I will mention surprising connections to my work on serial killer nurse cases, in particular the Dutch case of Lucia de Berk and the current UK case of Lucy Letby.
A brief information about the SCOP protein database used in bioinformatics.
The Structural Classification of Proteins (SCOP) database is a comprehensive and authoritative resource for the structural and evolutionary relationships of proteins. It provides a detailed and curated classification of protein structures, grouping them into families, superfamilies, and folds based on their structural and sequence similarities.
1. A few solvers for the Markowitz portfolio selection
problem
September 24, 2016
Abstract
The most commonly suggested tool to solve the Markowitz portfolio selec-
tion problem is Excel, which might be unwieldy for bigger models. The goal
was to verify if other modeling tools can be used for this particular purpose,
both commercial and open-source ones were reviewed including AMPL, Julia,
Python and the C programming language. Some slight differences in numeri-
cal solutions provided by these tools are presented. As some developments in
the modeling of capital markets are attributed to the computational complexity
of the classical Markowitz model, the ease of use and performance were in focus.
The Markowitz (1952) portfolio selection model (see also Markowitz (1959))
was in itself quite simple but the computational part of the problem was so
troublesome that it lead to different simplifications (see Sharpe (1963), Sharpe
(2000)). The development of microcomputers gave mass access to nonlinear
solvers allowing the solution to the original quadratic problem. The most com-
monly suggested tool to solve the problem is Microsoft Excel1 (see Jackson
(2001), Laws (2003)), which might be unwieldy for bigger models and limits
the number of model variables. Let us remind the classic portfolio problem -
let xi be the portfolio weight invested in security i, µi be the mean, σij be the
covariance of securities i and j, then E is the expected return of a portfolio and
1
Microsoft Excel is a registered trademark of Microsoft Corporation
1
2. V is its risk measure:
E =
N
i=1
xiµi (1)
V =
N
i=1
N
j=1
xixjσij (2)
N
i=1
xi = 1 (3)
xi 0 for i = 1..N (4)
As we can see, to solve the problem we have to calculate n(n − 1)/2 covariance
pairs and n variances. Two variants are usually considered - maximize expected
return with variance not greater than an assumed value vmax:
E → MAX (5)
V vmax (6)
or minimize variance with expected return not lesser than an assumed value
emin:
V → MIN (7)
E emin (8)
Below you will find implementations of the second variant (minimize the
risk) in four popular languages. This issue seems to be trivial today in terms
of complexity.
Numerical examples are based on stock prices of Bank of America Corpora-
tion, Ford Motor Company, General Electric and AT&T. Returns include both
price gains and dividends and were calculated for twelve consecutive quarters
starting on Jan 1st 2010.
AMPL
AMPL is a commercial tool (see Fourer (1990)), but it is available for students
and teachers at no charge. The tool is well-established among scientists and
has an extensive documentation2 - Fourer (2002). Input for the solver is split
into the model and the data file. Let us name the model file mps.mod:
2
http://ampl.com/resources/the-ampl-book
2
3. set A; # assets
set T := {1..12};
param Rets {T,A}; # returns on assets
param mean {j in A} = (sum {i in T} Rets[i,j]) / card(T);
param Diff {i in T, j in A} = Rets[i,j] - mean[j];
param Covar {i in A, j in A} =
sum {k in T} (Diff[k,i]*Diff[k,j]) / (card{T}-1);
var X {A} >=0;
var Mean = sum {j in A} mean[j] * X[j];
minimize Risk: sum {i in A} (X[i]*(sum {j in A} Covar[i,j]*X[j]));
subject to TotalOne: sum {j in A} X[j] = 1;
subject to Reve: Mean >= 0.035;
and the data file mps.dat:
set A := BAC F GE T ;
param Rets: BAC F GE T :=
1 0.1383 0.2228 0.1845 -0.0812
2 -0.2029 -0.2019 -0.2079 -0.0574
3 -0.0649 0.158 0.1593 0.1923
4 0.0038 0.3695 0.1265 0.0344
5 -0.0599 -0.1357 0.1045 0.0462
6 -0.1795 -0.0904 -0.0654 0.0398
7 -0.4472 -0.3103 -0.1995 -0.0862
8 0.0072 0.1483 0.2308 0.0891
9 0.6517 0.1258 0.1024 0.0425
10 -0.1539 -0.2361 0.0522 0.1479
11 0.0981 0.0554 0.1166 0.0536
12 0.2969 0.3092 -0.0715 -0.0954
You can now use AMPL graphical user interface - amplide - to run the
following commands:
3
4. model mps.mod;
data mps.dat;
solve;
display X;
You will get the following result:
MINOS 5.51: optimal solution found.
5 iterations, objective 0.01062155067
Nonlin evals: obj = 11, grad = 10.
ampl: display X;
X [*] :=
BAC 0
F 0.0428628
GE 0.437821
T 0.519316
Julia
Julia is a high-level, high-performance dynamic programming
language for technical computing3.
Julia and its packages4 are licensed under MIT, GPL, MPL, BSD and EPL
licenses. Let us put the Julia code into mps.jl. I omitted covariance calculation
for the sake of clarity:
using JuMP
using Ipopt
N=4
r_min=0.035
m = Model()
C = [0.076900 0.039968 0.018111 -0.000288 ; 0.039968 0.050244
3
http://julialang.org/
4
https://jump.readthedocs.io/en/latest
4
5. 0.019033 -0.000060 ; 0.018111 0.019033 0.021381 0.007511 ;
-0.000288 -0.000060 0.007511 0.008542]
Mean = [0.0073 0.0346 0.0444 0.0271]
@variable(m, 0 <= x[i=1:N] <= 1)
@objective(m,Min,sum{x[j]*sum{x[i]*C[i,j],i=1:N},j=1:N})
@constraint(m, sum{x[i]*Mean[i],i=1:N} >=r_min)
@constraint(m, sum{x[i],i=1:N} ==1.0)
status = solve(m)
for i= 1:N
println(getvalue(x[i]))
end
Then after running julia mps.jl we will get:
EXIT: Optimal Solution Found.
1.3095345121754e-7
0.043278618483219226
0.4378847609266113
0.5188364896367182
You will find more details on Julia in Balbaert (2015).
Python
Let us put the Python code into mps.py5:
from cvxopt import matrix
from cvxopt.solvers import qp
import numpy as np
n = 4
Cov = matrix([[0.076900, 0.039968, 0.018111, -0.000288 ],
[ 0.039968, 0.050244, 0.019033, -0.000060 ],
[ 0.018111, 0.019033, 0.021381, 0.007511 ],
5
https://wellecks.wordpress.com/2014/03/23/portfolio-optimization-with-python
5
6. [-0.000288, -0.000060, 0.007511, 0.008542 ]])
Mean = matrix([0.0073, 0.0346, 0.0444, 0.0271])
r_min = 0.035
G=matrix(np.concatenate((-np.transpose(Mean),-np.identity(n)),0))
h=matrix(np.concatenate((-np.ones((1,1))*r_min,np.zeros((n,1))),0))
A = matrix(1.0, (1,n))
b = matrix(1.0)
q = matrix(np.zeros((n, 1)))
sol = qp(Cov, q, G, h, A, b)
print(sol[’x’])
Then after having executed python mps.py we will get:
Optimal solution found.
[ 8.47e-07]
[ 4.33e-02]
[ 4.38e-01]
[ 5.19e-01]
Cvxopt6 and NumPy7 are licensed respectively under GPL and BSD (see
also Boyd (2004) and Idris (2015)). The Python language can be learnt with
Lutz (2003).
C
The Ipopt library8 (see Surhone (2011) and Russell (2012)) is distributed with
an example of usage — the hs071
¯
c.c file — with four variables, two con-
straints and goal minimisation, which perfectly fits our need.
The covariance matrix is symmetric so the gradient of the objective is given
6
http://cvxopt.org
7
http://www.numpy.org
8
https://projects.coin-or.org/Ipopt
6
7. by
2 ∗ N
i=1 xici1
2 ∗ N
i=1 xici2
2 ∗ N
i=1 xici3
2 ∗ N
i=1 xici4
(9)
and the Jacobian of the constraints g(x) is
µ1 µ2 µ3 µ4
1 1 1 1
(10)
With such a gradient of the objective the Hessian of the Lagrangian function
is the covariance matrix multiplied by 2.
Make the following changes to adapt this example file to our optimisation
problem. First remove the whole if-block with the second call to IpoptSolve,
most probably between lines 165 and 206. Then put covariance and mean
matrices somewhere at the beginning making them global:
Number c[4][4] =
{{0.076900, 0.039968, 0.018111, -0.000288},
{0.039968, 0.050244, 0.019033, -0.000060},
{0.018111, 0.019033, 0.021381, 0.007511},
{-0.000288, -0.000060, 0.007511, 0.008542}};
Number MoR[4] = {0.0073, 0.0346, 0.0444, 0.0271};
Secondly move the assignment of the number of stocks/variables to the
beginning of the main function and change the hardcoded values of nonzeros in
the Jacobian and the Hessian:
Index n=4;
Index nele_jac = 2*n;
Index nele_hess = n*(n+1)/2;
Then change the lower and upper limits of variables:
7
8. for (i=0; i<n; i++) {
x_L[i] = 0.0;
x_U[i] = 1.0;
}
and the limits of constraints - the minimum return and the sum of variables:
g_L[0] = 0.035;
g_U[0] = 1e19;
g_L[1] = 1;
g_U[1] = 1;
The eval
¯
f goal function should contain:
Number sum;
int i,j;
*obj_value=0.0;
for (i=0; i<n; i++) {
sum=0.0;
for (j=0; j<n; j++)
sum += x[j] * c[j][i];
*obj_value += x[i]*sum;
}
The eval
¯
grad
¯
f gradient calculation shall change to:
int i,j;
for (i=0; i<n; i++) {
grad_f[i] =0;
for (j=0; j<n; j++)
grad_f[i] += x[j]*c[j][i];
grad_f[i] = grad_f[i] * 2;
}
The two contraints are calculated within eval
¯
g :
8
9. int i;
g[0]=0.0;
for (i=0; i<n; i++) g[0] += x[i]*MoR[i];
g[0] += my_data->g_offset[0];
g[1]=0;
for (i=0; i<n; i++) g[1] += x[i];
g[1] += my_data->g_offset[1];
Finanaly there are two functions left - the Jacobian, eval
¯
jac
¯
g :
int i=0;
if (values == NULL) {
for (i=0; i<n; i++) {
iRow[i] = 0;
jCol[i] = i;
}
for (i=0; i<n; i++) {
iRow[n+i] = 1;
jCol[n+i] = i;
}
}
else {
for (i=0; i<n; i++)
values[i] = MoR[i];
for ( ; i<n+n; i++)
values[i] = 1;
}
and the Hessian, eval
¯
h :
if (values == NULL) {
idx=0;
for (row = 0; row < n; row++) {
9
10. for (col = 0; col <= row; col++) {
iRow[idx] = row;
jCol[idx] = col;
idx++;
}
}
}
else {
idx=0;
for (row = 0; row < n; row++) {
for (col = 0; col <= row; col++) {
values[idx] = obj_factor * (2*c[row][col]);
idx++;
}
}
}
You have to remove -pedantic-errors from the Makefile to compile this if you
have not placed variable definitions at the beginning of each function. Running
the program will give the following result:
x[0] = 0.000000e+00
x[1] = 4.327805e-02
x[2] = 4.378846e-01
x[3] = 5.188373e-01
The C programming language was described by Kernighan (1988).
An example with twenty stocks
Let us see the results for twenty stocks9 selected out of S&P100 for twelve
consecutive quarters starting on Jan 1st 2010. The same input data gave slightly
9
Stocks included: AIG BAC IBM CSCO DELL F GE GOOG HAL JPM KO MCD MS ORCL
PFE S T VZ WFC XOM
10
11. different results for four tools (Julia also uses Ipopt):
Software AMPL Python (Ipopt) C (Ipopt) Excel
Objective (risk) 0.002900 0.002874 0.002898 0.003178
AIG 0.0006 0.0003 0.0209
BAC 0.0067 0.0067 0.0067
IBM 0.1892 0.1890 0.1890 0.2743
KO 0.0718 0.0721 0.0719 0.0989
MCD 0.4291 0.4290 0.4290 0.4852
S 0.0966 0.0965 0.0965 0.1183
VZ 0.2066 0.2060 0.2066 0.0019
Table 1: Portfolio structures computed by different tools
As we can see, Ipopt found the best solution - the portfolio with the lowest risk.
Minor differences for Python and C can be caused by lack of precision in input
data. Excel excludes Verizon (XOM with 0.0005 is not shown in the table).
All tools provide results in the blink of an eye — a model with 200 stocks gets
solved by AMPL within less than one second.
Conclusions
The Markowitz portfolio selection problem is no longer a computational trouble.
There are open-source tools to solve models with hundreds of variables within
milliseconds on a personal computer. You can use the language which suites
you best. Especially Python deserves recommendation as it gets more and
more popular in the scientific community. These tools can be fed with data
in a much more convenient way than editing formulas in an office spreadsheet,
which moreover has the limit of number of variables.
It is found that different tools can suggest different portfolio weights and
greater portfolio variance with the same constraints (see table 1) - another
argument to use open-source tools.
11
12. References
1. Balbaert, Ivo Getting Started with Julia, Packt Publishing, 2015.
2. Boyd, Stephen, L. Vandenberghe Convex Optimization, Cambridge Univer-
sity Press, 2004.
3. Fourer, Robert, D.M. Gay, B.W. Kernighan ”A Modeling Language for
Mathematical Programming” Management Science, 36 (1990), pp. 519–554.
4. Fourer, Robert, D.M. Gay, B.W. Kernighan AMPL: A Modeling Language
for Mathematical Programming, Duxbury Press, 2002.
5. Idris, Ivan NumPy Beginner’s Guide, Packt Publishing, 2015.
6. Jackson, Mary, M. Staunton Advanced Modelling in Finance using Excel
and VBA, Chichester: John Wiley & Sons, 2001.
7. Kernighan, Brian W., D.M. Ritchie The C Programming Language, Prentice
Hall, 1988.
8. Laws, Jason ”Portfolio Analysis Using Excel” In C. L. Dunis, J. Laws P.
Nam, ed., Applied Quantitative Methods for Trading and Investment, John
Wiley & Sons, 2003.
9. Lutz, Mark Learning Python, 2nd ed. Sebastopol: O’Reilly, 2003.
10. Markowitz, Harry M. ”Portfolio Selection” The Journal of Finance, Vol. 7,
No. 1 (1952), pp. 77–91.
11. Markowitz, Harry M. Portfolio Selection: Efficient Diversification of Invest-
ments, NJ: John Wiley & Sons, 1959.
12. Russell, Jesse, R. Cohn IPOPT, Bookvika Publishing, 2012.
13. Sharpe, William F. ”A Simplified Model for Portfolio Analysis”, Manage-
ment Science, Vol. 19, No. 2 (1963), pp 277–293.
14. Sharpe William F. Portfolio Theory and Capital Markets, McGraw-Hill,
2000.
15. Surhone, Lambert M., M.T. Tennoe, S.F. Henssonow Ipopt, Betascript
Publishing, 2011.
12