>

Danial Khosravi's Blog

Entrepreneur in the making...

Estimating Pi Using Monte Carlo Simulations

| Comments

Pi (3.141593) is one of the few magical numbers in Mathematics that we often trust, accept and use in our calculations. However, you might be curious to know where it comes from. Pi can be obtained analytically which gives us a value equal to 3.141593 but here we’re going to find the value of pi numerically by running Monte Carlo simulations.

Calculating Stocks’ Beta Using R

| Comments

According to Investopedia, Beta is a measure of the volatility, or systematic risk, of a security or a portfolio in comparison to the market as a whole. In this post, we’re going to learn how to calculate beta coefficient of our desired stocks using historical price data that is publicly available.

Below we will be covering

  • R script to calculate beta for Goldman Sachs
  • Maths behind the beta coefficient

R: Fancy Plots Using Ggplot2 and Ggthemes

| Comments

In this post I want to introduce you to a great ggplot2 add-on, ggthemes. ggthemes which is freely available on github, let you turn your current plots to professional looking plots in a matter of a couple of lines of code.

ggthemes has various of different themes such as The Economist, Excel and various other professional themes that makes your current plots much fancier.

Here is a plot that I made for one of my assignments this year using this library.

Check out more examples on its offical Github Repo

Multiline Plots in R Using Ggplot2

| Comments

With the help of ggplot2, creating beautiful charts is an easy task in R. However it can get a little bit tricky when you’re trying to plot a set of data on a single chart, over a shared x axis.

Express 4 Tutorial - Simple Server

| Comments

Express 4 was released a while ago and although the API is pretty much the same as version 3, there are some breaking changes which I recommend you to take a look at this page in case you want to move your express 3 application to express 4.

Version 4 changed to Express core and middleware system. Which means the dependency on Connect framework which was built-in Express is removed and you must separately download and add the middleware you want to your application. Also the routing system has changed and the new router has much more flexibility.

I’m planing to write a tutorial series on Express 4. In this tutorial we’re writing a very basic Express 4 app and connect it to a (dummy)Database and authenticate users.

Source Code

Arduino, ProcessingJS and SocketIO in Action

| Comments

So today I wanted to do something relatively cool(!!) with things that I had around me. There are a lot of examples out there that sends input values from Arduino to Processing and then draw something cool. I wanted to do something a bit cooler and as always I wanted to bring Javascript into the action. In this tutorial i’m showing you how I connected my Arduino to a local NodeJS server and with the use of SocketIO send the value of potentiometer to client side and draw a cool graph with ProcessingJS !!!

Arduino and NodeJS Communication With Serial Ports

| Comments

Hello everyone, 2 days ago I recieved my arduino kit that I had ordered and i’m really excited to tell you that I’ll be posting more arduino tutorials from now on.

One of the cool things that i discoved that i’m sharing with you here, is communication of Arduino and NodeJS using serial ports. Basically what we’re doing is sending some data(zeros and ones) from the arduino to the land of Javascript and NodeJS.

Cordova/PhoneGap Tutorial

| Comments

If you are a web app developer and you care about mobile, you definitely heard of PhoneGap

PhoneGap is a free and open source framework that allows you to create mobile apps using standardized web APIs for the platforms you care about.

Before we ger started let me clarify that PhoneGap and Cordova are same thing so don’t get confused !!!

I needed a small app to play with phonegap and last time I wrote the simple note application in AngularJS immediately I start converting it to a phonegap application, which wasn’t that hard.