Snippets in category Scientific Computing

  • Support slicing operator

    The snippet shows how to support slicing in a type. Slicing allows you to get for example a 2D sub-matrix of a matrix and is implemented by adding GetSlice member.

    37 people like this
    Posted: 1 years ago by Tomas Petricek

  • Distance between two 3D segments

    The function segmentSegment takes 2 segments (starting and ending points) and computes the shortest distance between them. The function returns a starting and ending point of the shortest segment between the two segments. The function uses a triple type but can be easily rewritten to work with any other type (vector etc).

    23 people like this
    Posted: 1 years ago by Oldrich Svec

  • Get Stock Quote Data and Historical Stock Prices from Yahoo Finance

    Get Stock Quote Data and Historical Stock Prices from Yahoo Finance.

    135 people like this
    Posted: 1 years ago by Tuomas Hietanen

  • Function to get all possible combinations

    Function to get all possible combinations of list items. There are some Euler problems (like 77 & 78) to get total amounts. But e.g. for some card game implementations you will need the real items.

    27 people like this
    Posted: 1 years ago by Tuomas Hietanen

  • Plotting using Chart сontrol

    This snippet shows how to plot data on a form using .NET 4.0 Chart control.

    28 people like this
    Posted: 1 years ago by Dmitry Soshnikov

  • Pascal's Triangle

    Returns the pascal triangle in a 2D list . This snippet computes rows translating the 'visual' method taught at school into Lists and the usage of map2 function. It takes almost 5 seconds to compute 5000 rows.

    12 people like this
    Posted: 1 years ago by Horacio Nuñez

  • Primitive Pythagorean triples

    Primitive Pythagorean triples generator. It uses an Algorithm found on Wolfram MathWorld and the F# PowerPack matrix library.

    31 people like this
    Posted: 1 years ago by Cesar Mendoza

  • Bar chart using chart controls

    The snippet shows how to use Microsoft Chart Controls (available in .NET 4.0 and for .NET 3.5) to draw a Bar chart. The sample shows population sizes in different continents.

    17 people like this
    Posted: 1 years ago by Tomas Petricek

  • Doughnut chart using chart controls

    The snippet shows how to use Microsoft Chart Controls (available in .NET 4.0 and for .NET 3.5) to draw a Doughnut chart. The sample shows proportion of seats taken by parties in UK elections.

    46 people like this
    Posted: 1 years ago by Tomas Petricek

  • Line chart using chart controls

    The snippet shows how to use Microsoft Chart Controls (available in .NET 4.0 and for .NET 3.5) to draw a Line chart. The sample generates a 2D spline calculated using sin and cos functions.

    9 people like this
    Posted: 1 years ago by Tomas Petricek

  • Candlestick chart using chart controls

    The snippet shows how to use Microsoft Chart Controls (available in .NET 4.0 and for .NET 3.5) to draw a Candlestick chart visualizing stock prices. The sample uses price of MSFT stocks over 20 days.

    9 people like this
    Posted: 1 years ago by Tomas Petricek

  • Boxplot diagram using chart controls

    The snippet shows how to use Microsoft Chart Controls (available in .NET 4.0 and for .NET 3.5) to draw a BoxPlot diagram. In this sample, we provide six statistics (Maxmimum, Minimum, Upper quartile, Lower quartile, Average and Median) about observations explicitly.

    14 people like this
    Posted: 1 years ago by Tomas Petricek

  • QR-decomoposition of a square-matrix using the Gram-Schmidt method

    shows a simple implementation of a vector and matrix type together with a QR-decomposition using the Gram-Schmidt method. The algorithms themselfes are rather easy but I think the implementation of the types and the computations using recursive techniques might be interessting

    2 people like this
    Posted: 1 years ago by Carsten König

  • Yahoo Historical Quote Implementation

    F# module to return historical EOD: open | high |low | close | volume quotes from Yahoo. Single day requests only. DataContract provided on the result record for easy serialization.

    10 people like this
    Posted: 1 years ago by akaPhenom

  • Asserting Series Convergence: Ramanujan's 1/pi formula

    Asserting a series convergence using high order functions taking for example the 1/pi formula by Ramanujan. Play with the parameters to see where the numeric data types limits makes the function to return false.

    18 people like this
    Posted: 1 years ago by Horacio Nuñez

  • Compiler Regression in VS2010-SP1

    Compiler regression in VS2010-SP1 ?

    21 people like this
    Posted: 1 years ago by fholm

  • Black Scholes Option Pricing

    The code shows simple implementation of blackscholes algorithm.

    2 people like this
    Posted: 1 years ago by Kishor Aher

  • Historical Volatility

    The code snippet is capable of calculating historical volatility using Close Price, High Low Price and Close High Low Price methods. Simply provide symbol, start date and end date of the specific volatility method and it extracts the market data from the yahoo service and calculated the volatility.

    3 people like this
    Posted: 1 years ago by Kishor Aher

  • How to write a financial contract

    Implements the theory from 'How to write a financial contract' by S.L Peyton Jones and J-M Eber

    7 people like this
    Posted: 1 years ago by Ademar Gonzalez

  • calculating the distance on earth (with units of measure)

    calculating the distance between two locations on earth using haversine formula see http://en.wikipedia.org/wiki/Haversine_formula and implementing it using the posibilities of F#'s unit of measure system to avoid unit-conversion-errors concerning radians convertet the code found here: http://www.movable-type.co.uk/scripts/latlong.html for an concrete implementation

    3 people like this
    Posted: 1 years ago by Carsten König

  • Factorial using Int64, Double and BigInteger

    Recursive Factorial using Int64, Double and BigInteger with execution time.

    0 people like this
    Posted: 1 years ago by Carlos Quintanilla

  • Discount/Zero Curve Construction

    A simplistic discount curve bootstrapping process

    10 people like this
    Posted: 11 months ago by Wayne Bradney

  • Calculating the angle between the hour and minute hand

    This is a response to a Google interview question that someone encountered. A friend of mine was recently hired there and I've heard some thrilling stories of their interview process. So every now and then, I plan to code up a response to one of the hoards of interview questions they have.

    0 people like this
    Posted: 10 months ago by Antwan "A-Dubb" Wimberly

  • Calculating the angle between the hour and minute hand redux

    This snippet introduces a further subtlety into the previous posting, whereby the intra-hour movement of the hour hand is captured.

    0 people like this
    Posted: 10 months ago by HP

  • Prime numbers - Sieve of Eratosthenes

    Basic prime number generator

    1 people like this
    Posted: 8 months ago by d95danb

  • Prime testing

    Simple check if a number is prime. See also http://fssnip.net/2w.

    0 people like this
    Posted: 8 months ago by d95danb

  • RSK algorithm

    Implements a bijective mapping between permutations and pairs of standard Young tableaux, both having the same shape. http://en.wikipedia.org/wiki/Robinson%E2%80%93Schensted_correspondence

    4 people like this
    Posted: 7 months ago by Ademar Gonzalez

  • Compute CC.Net build statistics

    Written against CruiseControl.NET v1.5. Queries a CruiseControl.NET server for a project list and then computes min, max, average, and standard deviation of the build durations based on the statistics.csv CC.NET maintains.

    3 people like this
    Posted: 6 months ago by Matt Wilson

  • University enrollment (CZE vs. EU)

    Using World Bank type provider and FSharpChart to show average university enrollment in Czech Republic, European Union and OECD members.

    6 people like this
    Posted: 6 months ago by Tomas Petricek

  • XNA's Vector3 with units of measure

    A vector type with units of measure built on top of XNA's Vector3. Not complete, the point is mainly to show how to use generic units of measure to adapt an existing type.

    7 people like this
    Posted: 4 months ago by Johann Deneux

  • Discrete Fréchet Distance

    Compute the Discrete Fréchet Distance between two arrays (which may be of different lengths). Based on the 1994 algorithm by Thomas Eiter and Heikki Mannila. Not extensively tested, so use at your peril! (This version with some small fixes.)

    0 people like this
    Posted: 3 months ago by Kit Eason

  • Matrix

    Matrix

    2 people like this
    Posted: 3 months ago by Matrix

  • Factoring out FSharpChart

    Using FSharpChart control. Just call Charting.Plot() to chart series or collections of series. No need to create forms, etc.

    2 people like this
    Posted: 2 months ago by Boris Kogan

  • SIngle Life Annuity

    A single life annuity function in F# including supporting functions such as probability of survival, pure endowment and discounted interest rate calculation.

    0 people like this
    Posted: 1 months ago by Kevin Roche

  • Single Life Annuity

    A single life annuity function in F# including supporting functions such as probability of survival, pure endowment and discounted interest rate calculation. Should add that I'd be interested in making this more "functional"; at the moment it seems like a chunk of procedural code to me - any advice would be very welcome.

    3 people like this
    Posted: 1 months ago by Kevin Roche

  • Bayesian Monte Carlo of Let's Make a Deal

    This code illustrates Bayes' Theorem in action on the Let's Make a Deal problem, which several authors have used to illustrate Bayes' Theorem. (It's easy to search the internet for further explanation.) Run with the audit option to audit up to the first 100 games. Running without audit is faster and can simulate a couple billion games.

    3 people like this
    Posted: 1 months ago by Jack Fox

  • Monotone Chain Convex Hull Algorithm

    Andrew's Monotone Chain Convex Hull algorithm: given points in 2 dimensions, determine their convex hull by constructing the upper and lower hull.

    3 people like this
    Posted: 1 months ago by Mathias Brandewinder