From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Example Code

Find Pi via Monte Carlo Method

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Download All

Overview

This program calculates an approximation for the value of Pi via Monte Carlo Method by plotting a circle on a 200x200 square area then randomly placing dots on this area.

 

Description

This program calculates an approximation for the value of Pi by plotting a circle on a 200x200 square area then randomly placing dots on this area. By calculating the ratio of points that fall inside versus the number of points that fall outside the circle the value for pi is approximated.

 

Requirements

  • LabVIEW 2012 (or compatible)

 

Steps to Implement or Execute Code

  1.  Run the VI
  2. Slide the pointer on the Speed control to control the speed.

 

Additional Information or References

 

 

Front Panel

1.PNG

 

VI Snippet 

2.png

 

 

**This document has been updated to meet the current required format for the NI Code Exchange.**

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.