2014年7月16日 星期三

【筆記】標準差計算 & 常態分配圖

題目: 5個數值: 15、21、21、25、18 ,求標準差?


Step 1:
            先求平均值 (15+21+21+25+18)/5 = 20
Step 2:            
            在求變異數             
            ((20-15)^2+(21-20)^2+(21-20)^2+(25-20)^2+(20-18)^2)/5   =11.2
Step 3:           
            11.2^(1/2) = 3.35 

如何要求1倍標準差的範圍
          (20-3.35)~(20-3.35) =           16.65 ~ 23.35

如何要求2倍標準差的範圍
          (20-(3.35)*2)~(20-(3.35)*2) = 13.3 ~ 26.7

如何要求3倍標準差的範圍
          (20-3.35)~(20-3.35) =              9.95 ~ 30.05

若有需要寫程式的同學可以看下段程式
/// <summary> 
/// 標準差(StandardDifference) 
/// </summary> 
/// <param name="val"></param> 
/// <returns></returns> 
public double SD(List<double> val)
{
    if (val.Count > 1)
    {
       double avg = AVG(val);                
       double _result = (from a in val select System.Math.Pow(a - avg, 2)).Sum();
       if (avg > 0 && _result > 0)
       {
         double _sum = _result / (double)(val.Count - 1);
         double _Sqrt = System.Math.Sqrt(_sum);
         return _Sqrt;
       }
       else
         return 0;
   }
   else if (val.Count == 1)
   {
      return 0;
   }
   else
   {
      return 0;
   }
}

public double AVG(List<double> val) {
    var sum = val.Sum();
    return sum / val.Count;
}
這樣我們就可以作 "標準常態機率表" ,論理如下:標準常態機率表, z=0.67 之累計機率 0.7486, z=0.68 之累計機率 0.7517故累計機率0.75 (右尾機率0.25) 之 z 值約 0.6745.因此, 從 z=-0.6745 至 z=0.6745 機率約 0.5.即: 在平均數左右(±)0.6745倍標準差範圍內約 50%.同理, 中間 75% 範圍則左右各 12.5%. 查累計機率 0.875 之 z 值, 約 z=1.15.即: 在平均數左右 1.15倍標準差範圍內約 75%.同理, 在平均數左右 1.44倍標準差範圍內約 85%.又: 平均數左右 1倍標準差範圍內約 68.27%平均數左右 2倍標準差範圍內約 95.45%平均數左右 3倍標準差範圍內約 99.73%
引用 https://tw.knowledge.yahoo.com/question/question?qid=1511022801603 文章




2014年5月26日 星期一

修改資料夾/檔案的權限(icacls指令)

資料夾 和 文件檔案的權限 在window 上有時侯會因不知的原因失去了你當初設定的權限,小弟是常常在部署iis上的網站時,常遇到這一個問題(權限遺失)!你當然也可以選擇一個一個檔案加入權限! ^ ^ … 但是這樣子會很累人。有一個dos 的指令可以快速的幫忙完成grant權限的問題就是 icacls 指令。

icacls 的全名是 Change Access Control Lists ,常用的方式有3種如下:

  • 使用法用(1)--設定權限
    • icacls name aclfile [/T] [/C] [/L] [/Q]
      • aclfile 是一個使用者名稱 或 群組名稱 加上一個權限控制符號組成。如canred:F 表canred這一個群組可以完全權限。

  • 使用法用(2)--備儲權限
    • icaclsname /save Save_File_Path  [/T] [/C] [/L] [/Q]
  • 使用法用(3)--還原權限
    • icacls name /restore Save_File_Path  [/T] [/C] [/L] [/Q]

操作方法的參數如下:

  • [/T] 以遞迴的方式執行操作(使用)
  • [/C] 遇到錯誤時仍要繼續執行,當然他也會出錯誤的清單。
  • [/L] 操作在符号链接本身而不是其目标上执行(這一個不常用)。
  • [/Q] 安靜模式。

常用的範例--利用icacls設定權限

格式 icacls name /[grant|deny] groupName|userName:perm 操作符[/T][/C][/L][/Q]

/[grant|deny] : 表示設定權限的方式  , grant 設定權限 ;deny拒絕權限

groupName|userName:是群組名稱 或 使用者名稱

perm :權限操作符號,在一般的操作大家可用簡單的方式即可。

  • 簡單的權限操作符號:
    • F - 完全訪問權限
    • M - 修改權限
    • RX - 讀取和執行的權限
    • R - 只讀的權限
    • W - 可寫的權限
  • 進階的權限操作符號:
    • D - 删除
    • RC - 读取控制
    • WDAC - 写入 DAC
    • WO - 写入所有者
    • S - 同步
    • AS - 访问系统安全性
    • MA - 允许的最大值
    • GR - 一般性读取
    • GW - 一般性写入
    • GE - 一般性执行
    • GA - 全为一般性
    • RD - 读取数据/列出目录
    • WD - 写入数据/添加文件
    • AD - 附加数据/添加子目录
    • REA - 读取扩展属性
    • WEA - 写入扩展属性
    • X - 执行/遍历
    • DC - 删除子项
    • RA - 读取属性
    • WA - 写入属性

範列一:我要設定在c:/test資料夾所有文件的權限,讓canred帳號可以完全控制

  • icacls c:/test /grant canred:F /T
    當然如果以只要設定讀的權限你可以使用canred:R來取代canred:F啦!

範列二:我要拒絕canred帳號使用c:/test的權限

  • icacls c:/test /deny canred /T

範列三:我要備儲c:來的所有檔案權限,存儲到c:/c.perm中

  • icacls c:/ /save c.perm

範列四:我要還原c:的檔案權限

  • icacls c:/ /restore c.perm

2013年10月27日 星期日

10個磁碟空間掃描/統計的工具

來源: http://www.howtogeek.com/113012/10-best-free-tools-to-analyze-hard-drive-space-on-your-windows-pc/


The 10 Best Free Tools to Analyze Hard Drive Space on Your Windows PC

00_lead_image_orig
So, you bought yourself a new 2 TB hard drive thinking, “I’ll never use this much space.” Well, think again. It’s amazing how fast photos, videos, music, and other files start to use up any hard drive space we have.
Then, you think, “How am I going to sort through all these files and figure out what is taking up the most space?” Luckily, we’ve gathered information about 10 free tools to help you do just that.

SpaceSniffer

SpaceSniffer is a portable, freeware program that helps you understand the structure of the folders and files on your hard drives. The Treemap visualization layout SpaceSniffer uses helps you to immediately visualize where big folders and files are placed on your devices. The area of each rectangle is proportional to that file’s size. You can double-click on any item to see more detail.
If you’re searching for specific file types, such as all .jpg files, or for files older than a year, or any other condition, use the Filter field to limit the results to only those files. For help with how to use the filtering feature, select Filtering help from the Help menu.

WinDirStat

When WinDirStat starts, it reads the whole directory tree once and presents it in three useful views. The directory list, which resembles the tree view in Windows Explorer, displays on the upper left and is sorted by file/subtree size.
The extension list is a legend that displays on the upper right and shows statistics about the different files types.
The treemap takes up the bottom of the WinDirStat window. Each colored rectangle represents a file or directory, and the rectangles are nested, representing subdirectories and files within the directories. The area of each rectangle is proportional to the size of the files or subtrees. The colors of the rectangles for files indicate the file extensions that correspond to the extension list.

TreeSize Free

TreeSize Free allows you to start the program normally or from the context menu for a folder or a drive. It shows you the size of the selected folder, including its subfolders. The tree is like Windows Explorer in that you can expand every subfolder within the selected folder or drive and drill down to the file level. The results are visible as TreeSize Free scans the selected folder or drive.
You can download TreeSize Free as a portable program or as an installable file. To get the option on the context menu, you must download the installable file and install the program.

Disktective

Disktective is a free, portable utility that reports the real size of your directories and the distribution of the subdirectories and files inside them. You are asked to select a directory or drive when Disktective opens. The selected folder or drive is analyzed and a tree view displays on the left side of the window and a pie chart with percentages displays on the right.
Because Disktective doesn’t need to be installed, you can take it with you on a USB flash drive to analyze the flash drive or any Windows computer you come across.

DiskSavvy

DiskSavvy is a fast, easy-to-use disk space analyzer that allows you to analyze disk usage for your hard disks, network share drives, and NAS storage devices. The main window shows you the percentage of disk space used by each directory and file. You can also easily view pie charts or bar charts showing the results in graphical format.
DiskSavvy is available as a freeware version, a Pro version, and an Ultimate version, each successive version providing additional features. The freeware version allows for a maximum number of files of 500,000 and a maximum storage capacity of 2 TB. It has support for long filenames, Unicode filenames, and UNC network path names and allows you to copy, move, and delete files directly within the program.

JDiskReport

JDiskReport is another free tool that presents an analysis of the selected folder or drive as a pie chart, ring chart, bar chart, or in a detailed table. Click the Scan a file tree button (magnifying glass) on the toolbar to select a drive or folder and start the scan. The Folders tree view in the left pane presents a Windows Explorer-like tree allowing you to easily access all the subfolders in the selected folder or drive. Multiple tabs at the top of the right pane provide different ways to view the results of the scan. Each tab also has options at the bottom for additional different views. There are buttons on the toolbar that allow you to sort by size or name and to show the file size or number of files on the selected tab as appropriate.

GetFoldersize

For each folder in the selected folder or drive, GetFoldersize displays the total size for all the files in that folder or drive and the number of files and subfolders within the folder or drive. You can use GetFoldersize to scan an unlimited number of files and folders on internal and external hard drives, CDs and DVDs, and network share drives. It supports long file and folder names and Unicode characters and the ability to display the file size in bytes, kilobytes, megabytes, and gigabytes. GetFoldersize allows you to print the folder tree and to save the folder tree and information to a text file.
GetFoldersize is available in a portable version, so you can carry it around with you on a USB flash drive or other external drive. However, if you install GetFoldersize, an option is added to the context menu in Windows Explorer allowing you to start GetFoldersize and scan a folder by right-clicking on it.

RidNacs

RidNacs is a fast disk space analyzer that scans local drives, network drives, or a single directory and shows the results in a tree view with a bar chart displaying percentages. You can save the results of the scan in multiple formats (.txt, .csv, .html, or .xml). Files can be opened and deleted directly within RidNacs. During installation, you can choose to add an option to the Windows Explorer context menu that allows you to right-click on a folder or drive, open RidNacs, and start a scan on the selected folder or drive immediately. When you scan a folder, it’s added to the list of Favorites under a list of available drives on your computer. You can also change the look of the bars on the bar chart with skins.

Scanner

Scanner uses an extended pie chart with concentric rings to display the usage of the space on your hard drive, external drive, network drive, etc. The outer segments of the rings represent deeper directory levels. Moving your mouse over a segment of the chart displays the full path at the top of the window and the size of the directory and the number of files in the directory below the path. Right-clicking on a segment provides additional options. The Zoom option allows you to zoom into the selected directory and is also available by clicking on the segment. You can also Open, Recycle (delete by moving to the Recycle Bin), and Remove and file or directory directly within Scanner.
Scanner comes with two .reg files that allow you to add Scanner to the Windows Explorer context menu and remove it again. It is a portable program and comes with two text files (one of them in English) that describes the usage of the program.

Free Disk Analyzer

Free Disk Analyzer displays a tree of all your drives on the left like Windows Explorer, allowing you to drill down to deeper folders and files. The right side of the window displays all the subfolders and files in the currently selected folder or drive, the size and the percentage of disk space each subfolder and file uses. Free Disk Analyzer also displays your disk usage as a pie chart at the bottom of the right side of the window. Tabs at the bottom of the right side of the window allow you to view the contents of the selected folder or drive or view the largest files or largest folders. Click the column headings to sort by different criteria. You can also manage your files directly within the program and view, open, delete, copy, and move files the same as you would in Windows Explorer.
For additional ideas on how to regain hard disk space in Windows 7, see our article aboutsimple tips to reduce disk usage. Two Windows files, pagefile.sys and hiberfil.sys, take up a lot of room on your hard drive. You can’t delete pagefile.sys, but you can delete the hiberfil.sys file and also learn more about it.