Saturday, 7 March 2020

Latin Cubes

What is Latin Cubes?

The practical applications of Latin crops and related designs are factorial experiment.factorial experiments for meet the expiry mentor to evaluate the combined effect of two or more experimental variable when used simultaneously.and interaction effect is an effect attributable to the combinations of variable above and beyond that which can be predicted from the variable considered single.for example the factors affecting the growth and yield of a crop menu rings, seeds rate methods of cultivation score updates at which various operations are performed and shown are many and the effect of anyone may be dependent upon conditions in respect of others.
Latin cubes
Latin Cubes

Conclusion
Conclusion from an experiment to determine the optimal amount of phosphatic fertilizer to apply to a crop would become useless if the letter word show that the amount of some other fertilizers the death of plugging for the variety used in experiment had bin far from the best, unless there was a strong reason for believing that change in optimal condition in respect of these factors would not be appreciably affect the name of phosphate.
there are three main reasons for including levels of several factors in one experiment are
to obtain informations on the average effect of all the factors economically from a single experiment of motor size.
to broaden the basis of inter France on one factor by testing it under varied conditions of others.
To assess the manner in which the effects of actors interact one another.

Wednesday, 4 March 2020

How to solve linear programming problems

How to solve linear programming problem

There are two methods for solving linear programming problems
1. Graphical methods
2. Simplex method
If the objective function contains only two variables then it can be easily solved by graphical method however if the objective function is a function of three and more valuable than the simplex method is used.
Simplex and graphical method
Simplex and graphical method

Solution
The set of values of unknown X1, X2...... Xn.which satisfy the constraints of general LPP is called solution to the general LPP.

Feasible region
Common region determined by all the constants of L.P.P is called feasible region.
Corner Point
In the visible region the points of intersection of boundary lines are called corner points.
Feasible solutions
Any set of the values of the variables X1 X2..... Which satisfied all the constants and the non negative restrictions of the problems is called feasible solution.
Infeasible solution
any point which lies outside the visible region is called infisible solution.

Optimal feasible solution
Any feasible solutions which optimised the objective functions of the general l p p.
Unbounded solutions
A linear programming problem is said to have an unbounded solution if the feasible region is not bounded in any respect.
Redundant constants
the constants which are less restrictive and do not affect the feasible region.
Convex polygon
Convex polygon is a closed region such that the line segment joining any two ooh arbitrary points of the region is always lies entirely within this region.

Tuesday, 3 March 2020

Advantage of linear programming

How to get advantage of linear programming.

Linear programming is very useful in improving the knowledge and skill of managers and executive. It helps in attending the optimum use of productive factor. It indicates how one can utilise this factors most effectively by a better selection and distribution of these elements.
Linear programming advantage and limitation
Linear programming

Linear programming improve the quality of decisions
A person having clear picture of the relationship within basic equations and inequalities for constants can have a better idea about the programs and its solution.does the individual who makes use the linear programming method becomes more objective than subjective.
Linear programming highlights the problems faced during the production process.there are situation when some machines cannot meet the demand while other remains idle for some period of time. It helps in highlighting this problem and outcoming them.
Conclusion
Linear programming gives possible and practical solution,there might be other constants appearing outside the problem which must be taken into consideration such as sales, demand etc.Linear programming method can handle such situation also because it allows modification of its mathematical solution.

Limitations of linear programming

Linear programming can be used when there is only one objective of the management. This objective may be either maximization of profit on manam minimization of cost. But in case when the management has multiple goals this technique fails.
Linear programming can be used only in the situations where the objective function and the constraints can be expressed in the term of linear equations.Non linear quadratic cubic or higher degree equation cannot be considered in the LPP.
There should be some fixed numbers of constants. Otherwise the calculations will not be correct.
Linear programming is assume that the coefficient of objective function and constraints in linear programming do not change during the period of study, these are assumed to be known with certainty. How is good in real life situation it may not happen.
According to the linear programming problem the solutions variable can have any value, where sometimes it happens that some of the variable can only integral values.

Friday, 21 February 2020

How to understand candlestick charts

Candlesticks Charts

Candlestick chart provides closing price,open, high and low price. There are two two colours of one for up  and other for down.
Candlesticks chart

1.Doji
Doogee is is the part of charts, it indicates the  bull and bear fall. Doji candle gain importance depending on the place where the are formed.it is considered where is if it occur after a long white candle because it indicates that the balls are getting exhausted. Similarly aur doji is formed after a long black candle means the bears are become exhausted and there after it is considered bullish.
Long and short body
Long body long body in a bullish candle means absolute control by bulls. Along bearish candle means beer control and along with bearish.

Wednesday, 22 January 2020

How to solve Fourier Series problem -R

How to solve the Fourier Series problem

 solve the Fourier Series

install.packages("fourierin", dependencies = FALSE)
> library("dplyr", lib.loc="~/R/win-library/3.6")
> library("ggplot2", lib.loc="~/R/win-library/3.6")
 install.packages("purrrlyr", dependencies = FALSE)
 install.packages("purrr", dependencies = FALSE)
library("dplyr", lib.loc="~/R/win-library/3.6")
> library("lattice", lib.loc="C:/Program Files/R/R-3.6.1/library")
> df <- 5
> cf <- function(t) (1 - 2i*t)^(-df/2)
> dens <- function(x) dchisq(x, df)
> ## Set resolutions
> resolutions <- 2^(6:8)
> ## Compute integral given the resoltion
> recover_f <- function(resol){
+     ## Get grid and density values
+     out <- fourierin(f = cf, lower_int = -10, upper_int = 10,
+                      lower_eval = -3, upper_eval = 20,
+                      const_adj = -1, freq_adj = -1,
+                      resolution = resol)
+     ## Return in dataframe format
+     out %>%
+         as_data_frame() %>%
+         transmute(
+             x = w,
+             values = Re(values),
+             resolution = resol)
+ }
> vals <- map_df(resolutions, recover_f)
>
> true <- data_frame(x = seq(min(vals$x), max(vals$x), length = 150),
+                    values = dens(x))
Warning message:
`data_frame()` is deprecated, use `tibble()`.
This warning is displayed once per session.
>
> univ_plot <-
+     vals %>%
+     mutate(resolution = as.character(resolution),
+            resolution = gsub("64", "064", resolution)) %>%
+     ggplot(aes(x, values)) +
+     geom_line(aes(color = resolution)) +
+     geom_line(data = true, aes(color = "true values"))
> univ_plot
> set.seed(666)
> new_grid <- rchisq(n = 3, df = df)
> resolutions <- 2^(6:9)
> fourierin(f = cf, lower_int = -10, upper_int = 10,
+           eval_grid = new_grid,
+           const_adj = -1, freq_adj = -1,
+           resolution = 128) %>%
+     c () %>% Re() %>%
+     data_frame(x = new_grid, fx = .)
# A tibble: 3 x 2
      x     fx
  <dbl>  <dbl>
1  6.41 0.0874
2 11.7  0.0152
3  3.06 0.154
> approximated_fx <- function (resol) {
+     fourierin(f = cf, lower_int = -10, upper_int = 12,
+               eval_grid = new_grid,
+               const_adj = -1, freq_adj = -1,
+               resolution = resol) %>%
+         c() %>% Re() %>%
+         {data_frame(x = new_grid,
+                     fx = dens(new_grid),
+                     diffs = abs(. - fx),
+                     resolution = resol)}
+ }
>
> tab <-
+     map_df(resolutions, approximated_fx) %>%
+     arrange(x) %>%
+     mutate(diffs = round(diffs, 7)) %>%
+     rename('f(x)' = fx,
+            'absolute difference' = diffs)
> tab
# A tibble: 12 x 4
       x `f(x)` `absolute differe~ resolution
   <dbl>  <dbl>              <dbl>      <dbl>
 1  3.06 0.154           0.000207          64
 2  3.06 0.154           0.0000476        128
 3  3.06 0.154           0.0000472        256
 4  3.06 0.154           0.0000471        512
 5  6.41 0.0874          0.000078          64
 6  6.41 0.0874          0.0000155        128
 7  6.41 0.0874          0.0000148        256
 8  6.41 0.0874          0.0000147        512
 9 11.7  0.0152          0.0000097         64
10 11.7  0.0152          0.0000025        128
11 11.7  0.0152          0.0000022        256
12 11.7  0.0152          0.0000022        512
> library("dplyr", lib.loc="~/R/win-library/3.6")
> library("lattice", lib.loc="C:/Program Files/R/R-3.6.1/library")
 mu <- c(-1, 1)
> sig <- matrix(c(3, -1, -1, 2), 2, 2)
> f <- function(x) {
+     ## Auxiliar values
+     d <- ncol(x)
+     z <- sweep(x, 2, mu, "-")
+     ## Get numerator and denominator of normal density
+     num <- exp(-0.5*rowSums(z * (z %*% solve(sig))))
+     denom <- sqrt((2*pi)^d*det(sig))
+     return(num/denom)
+ }
>
> ## Characteristic function, s is n x d
> phi <- function (s) {
+     complex(modulus = exp(-0.5*rowSums(s*(s %*% sig))),
+             argument = s %*% mu)
+ }
> ## Evaluate characteristic function for a given resolution.
> eval <- fourierin(f,
+                   lower_int = c(-8, -6), upper_int = c(6, 8),
+                   lower_eval = c(-4, -4), upper_eval = c(4, 4),
+                   const_adj = 1, freq_adj = 1,
+                   resolution = 2*c(64, 64),
+                   use_fft = T)
> ## Evaluate true and approximated values of Fourier integral
> dat <- eval %>%
+     with(crossing(y = w2, x = w1) %>%
+              mutate(approximated = c(values))) %>%
+     mutate(true = phi(matrix(c(x, y), ncol = 2)),
+            difference = approximated - true) %>%
+     gather(value, z, -x, -y) %>%
+     mutate(real = Re(z), imaginary = Im(z)) %>%
+     select(-z) %>%
+     gather(part, z, -x, -y, -value)
Error in crossing(y = w2, x = w1) : could not find function "crossing"
> wireframe(z ~ x*y | value*part, data = dat,
+           scales =
+               list(arrows=FALSE, cex= 0.45,
+                    col = "black", font = 3, tck = 1),
+           screen = list(z = 90, x = -74),
+           colorkey = FALSE,
+           shade=TRUE,
+           light.source= c(0,10,10),
+           shade.colors = function(irr, ref,
+                                   height, w = 0.4)
+               grey(w*irr + (1 - w)*(1 - (1 - ref)^0.4)),
+           aspect = c(1, 0.65))
Error in wireframe.formula(z ~ x * y | value * part, data = dat, scales = list(arrows = FALSE,  :
  object 'dat' not found
>
> mu <- c(-1, 1)
> sig <- matrix(c(3, -1, -1, 2), 2, 2)
> f <- function(x) {
+     ##-Auxiliar values
+     d <- ncol(x)
+     z <- sweep(x, 2, mu, "-")
+ ##-Get numerator and denominator of normal density
+ num <- exp(-0.5*rowSums(z * (z %*% solve(sig))))
+ denom <- sqrt((2*pi)^d*det(sig))
+
+ return(num/denom)
+ }
> phi <- function(s) {
+     complex(modulus = exp(- 0.5*rowSums(s*(s %*% sig))),
+             argument = s %*% mu)
+ }
>
> eval <- fourierin_2d(f, lower_int = c(-8, -6), upper_int = c(6, 8),
+                      lower_eval = c(-4, -4), upper_eval = c(4, 4),
+                      const_adj = 1, freq_adj =  1,
+                      resolution = c(128, 128))
>
> t1 <- eval$w1
> t2 <- eval$w2
> t <- as.matrix(expand.grid(t1 = t1, t2 = t2))
> approx <- eval$values
> true <- matrix(phi(t), 128, 128)        # Compute true values
>
> i <- 65
> plot(t2, Re(approx[i, ]), type = "l", col = 2,
+      ylab = "",
+      xlab = expression(t[2]),
+      main = expression(paste("Real part section at ",
+                              t[1], "= 0")))
> lines(t2, Re(true[i, ]), col = 3)
> legend("topleft", legend = c("true", "approximation"),
+        col = 3:2, lwd = 1)
> plot(t1, Im(approx[, i]), type = "l", col = 2,
+      ylab = "",
+      xlab = expression(t[1]),
+      main = expression(paste("Imaginary part section at ",
+                              t[2], "= 0")))
> lines(t1, Im(true[, i]), col = 3)
> legend("topleft", legend = c("true", "approximation"),
+        col = 3:2, lwd = 1)

Friday, 20 December 2019

Relative strength in stock speed

Relative strength index (RSI)

RSI
NSEI


RSI is one of the most popular technical indicators in the stock market. It is computed based on the speed and direction of the stock price movement.RSI is calculated for the two-step process. First, the average gains and losses are identified for a specified time period. You can consider any time period but 14 days RSI is commonly used. Suppose that the stock went off on nine days and fail on five days. The absolute stock price gain on each of these nine days are are added up and divided by 14 to get the average gains. Similarly, the absolute loss on each of the five days are added up and divided by 14 to get the average losses. The ratio between these values is known as relative strength.
Second, the indicator is normalized later to make sure that RSI always moves between 0 and 100 the value will be 0 if the stock fell in all the 14 days and will be 100 if the price move of on all the 14 days.
Formula
RSI=100-[100/(1+RS)].
Oversold and overbought levels
RSI value is designed to move between zero and hundred always it can be used to identify the overbought and oversold level in a counter above 70 as an overbought zone and below 30 age oversold.

Friday, 29 November 2019

Greeks in the option market

How to calculate greeks in the option market


 plotbullcall(s= 100, x1 = 95, x2 = 105, t = (45/365), r = 0.02,sigma = 0.20, sigma2 = 0.20, d = 0, ll = 0.75, ul = 1.25)
> plotbullput(s= 100, x1 = 95, x2 = 105, t = (45/365), r = 0.02,
+             sigma = 0.20, sigma2 = 0.20, d = 0, ll = 0.75, ul = 1.25)
> plotbullput(s= 100, x1 = 95, x2 = 105, t = (45/365), r = 0.02,
+             sigma = 0.20, sigma2 = 0.20, d = 0, ll = 0.75, ul = 1.25)
> puttheta(100, 100, 0.20, (45/365), 0.02, 0.02)
[1] -0.02979083
> optiongamma(100, 100, 0.20, (45/365), 0.02, 0.02)
[1] 0.05663458
> calleval(100, 100, 0.20, (45/365), 0.02, 0.02)
   Premium     Delta      Gamma      Vega       Theta
1 2.794086 0.5127391 0.05663458 0.1396469 -0.02979083
         Rho
1 0.05976964
> callgreek("delta", 100, 100, 0.20, (45/365), 0.02, 0.02)
[1] 0.5127391
> callgreek("gamma", 100, 100, 0.20, (45/365), 0.02, 0.02)
[1] 0.05663458
> callgreek("vega", 100, 100, 0.20, (45/365), 0.02, 0.02)
[1] 0.1396469
> callgreek("theta", 100, 100, 0.20, (45/365), 0.02, 0.02)
[1] -0.02979083

Latin Cubes

What is Latin Cubes? The practical applications of Latin crops and related designs are factorial experiment.factorial experiments for me...